This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ld - access a memory address from linker script
- From: Erik Christiansen <dvalin at internode dot on dot net>
- To: binutils at sourceware dot org
- Date: Sat, 27 Jun 2015 00:13:24 +1000
- Subject: Re: ld - access a memory address from linker script
- Authentication-results: sourceware.org; auth=none
- References: <CAB-o4CxnB2oRDwZab9BzaO5hb_baZCM8_EeJ_0vzfwVpwctijQ at mail dot gmail dot com>
- Reply-to: dvalin at internode dot on dot net
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