This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: RFH: Assignments folded too early
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: Daniel Jacobowitz <dan at codesourcery dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 7 Apr 2010 18:14:23 -0400 (EDT)
- Subject: Re: RFH: Assignments folded too early
- References: <20100407164206.GA6029@caradoc.them.org>
On Wed, 7 Apr 2010, Daniel Jacobowitz wrote:
> In the ld manual there's an example that's just perfect for the
> problem I'm working on:
>
> `DEFINED(SYMBOL)'
> Return 1 if SYMBOL is in the linker global symbol table and is
> defined before the statement using DEFINED in the script, otherwise
> return 0. You can use this function to provide default values for
> symbols.
> And this linker script:
>
> SECTIONS
> {
> .text :
> {
> *(.text)
> *(.text1)
> begin = DEFINED(begin) ? begin : fallback ;
> }
> }
>
> Works fine:
> But move the assignment higher, and it blows up:
>
> SECTIONS
> {
> .text :
> {
> *(.text)
> begin = DEFINED(begin) ? begin : fallback ;
> *(.text1)
> }
> }
>
> 0000000000000004 T begin
> 0000000000000008 T fallback
> 0000000000000000 t padding
>
> See how begin has moved into the middle of the .text input section?
Yes, and I also see that it isn't "defined *before* the
statement using DEFINED in the script" any more (my emphasis),
but it seems you read those words differently from how I do?
I remember this being sanitized some time ago, from some
semantics that tried to cater to the symbol being defined
*anywhere* in the program or if it included the current
assignment (I don't remember). If you're trying to do that,
please add something with a different name, like
DEFINED_ANYWHERE, so you don't change semantics of the existing
DEFINED.
brgds, H-P