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 withoutdefining them as symbols on the file


Hi Guilherme,

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.



It is OK to left a small amount of memory allocated, like this patch and
the lang_memory_region_list does?

Not really. If it is going to be very difficult to recover the memory then it can be permitted, but a decent effort ought to be made to avoid memory leaks. Just because leaks are present in old code, it does not excuse leaks in new code. In fact really the old code ought to be fixed as well.


Cheers
  Nick



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