ld - access a memory address from linker script
Erik Christiansen
dvalin@internode.on.net
Fri Jun 26 14:05:00 GMT 2015
On 26.06.15 14:16, Martin Velek wrote:
> I am writing a small bootloader (about 8 KB max) for the LPC1788
> microcontroller (Cortex M3) however the LPC1788 has a functionality
> that if there is a predefined value at the address 0x2FC, the cpu will
> block access to the JTAG. I would like to check the address in the
> linker script to avoid generating elf if there is such value.
> Something like ASSERT(0xXXX != VMA[0x2fc], "Wrong code....").
Have you considered using a source code macro to place the value at the
address 0x2FC, and also set a global symbol, e.g. a "JTAG_OFF" symbol,
which _can_ be tested:
x = ASSERT (JTAG_OFF != 0, "Error: Wrong code....")
Even in assembler, a macro can easily test a provided parameter, and
conditionally code a ".org 0x2FC", ".word xxxx", as well as a
"JTAG_OFF = 1", so the two will always correlate.
> I have tried to reserve a space in the .text output section
> /* Code Read Protect data */
> /*. = 0x000002FC ;*/
> KEEP(*(.crp))
>
> but it means to calculate manually the function between 0 â 2FC. As
> far as I know the linker cannot put a variable at a given address and
> then place the code around automatically.
The latest confirmation I've seen is:
https://sourceware.org/ml/binutils/2013-03/msg00006.html
But in any event, I've not seen any input section byte scanning
constructs in the ld manual.
Erik
More information about the Binutils
mailing list