This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC and PATCH - Defining variables in the linker script without defining them as symbols on the file


Nick Clifton <nickc@redhat.com> writes:

> > While testing if it's working, I found out that if I have a script with
> > those lines inside SECTIONS{
> > lixo = lixo_1;
> > TEMPORARY( lixo_1 = 0x1);
> > }
> > I have as result:
> > make ok;readelf -a ok|grep lixo
> > cc -Wl,-T -Wl,script -Wl,--deftmp -Wl,lixo1=0x19  -Wl,--deftmp
> > -Wl,lixo2=0x29    ok.c   -o ok
> >     49: 00000001     0 NOTYPE  GLOBAL DEFAULT  ABS lixo
> >     59: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND lixo_1
> > As you can see, lixo_1 ends up as undefined.
> > The parser accept the variable, but in the tree used to construct the
> > sentence lixo = lixo_1; lixo_1 is not defined yet.	Why the parser accept
> > a variable that wasn't defined yet?
> 
> Because it was never programmed not to.  There is no good reason to
> accept this, and in fact I agree that the parser ought to issue an
> error message.  It is just that I doubt if anyone has ever done this
> with a linker script before.

Note that there is a very good reason to accept
    foo = bar
if bar is defined in some .o file.  I don't think you can report an
error in the parser.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]