This is the mail archive of the binutils@sourceware.org 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]

linker script variables


Hey!

i'm working on a hobby kernel, and am now facing some troubles with
linker script defined variables... i must be doing something wrong (or
there is a bug - this is what i'm longing to find out ;)).

i'm trying to get static c++ constructors to work, so i collect all the
.ctor* and .dtor* sections from all objects into the .data section of my
kernel (the linker script is attached: uTachyon.ld.bz2).

one of the object files i'm linking in is a C++ object containing a
global c++ object. the .ctors section contains the apropriate
initializer address to be called (see dump of object:
multiboot.dmp.bz2). this looks good.

now when looking at the attached linker script, i would think, that the
final binary should contain two symbols uTachyonCtors and
uTachyonCtorsEnd, whos abs value differs by 4 bytes (the single ctor
address), right? it doesn't (see attached executable dump:
uTachyon.dmp.bz2), even though the .ctors data _is_ there, the two
symbols have the same address!

in fact, after sitting in front of the dumps for an hour i realized that
_none_ of the linker script defined symbols value is correct:

it seems that each and every linker script defined symbol has the
highest address assigned that the corresponding section has (or better:
the scope it is defined in...). for example, uTachyonCodeStart should
have the value 0x00100000 if i'm not completely mistaken, since it
should point to the start of .text, but in fact it has the value
0x00100799, which seems to be the end of the .text section (interesting
enough: it is _not_ the end of the last .text.* section, but really only
the first .text section...).

Any ideas? i can provide more info if you like...

mduft@s01en22 ~/Projects/tachyon/uTachyon $ ld --version
GNU ld (GNU Binutils) 2.18
...

Hope somebody knows what i'm doing wrong :)

P.S.: i removed some debug related output from the dumps - hope nobody
misses it ;) if you do, tell me...

Cheers, Markus

Attachment: uTachyon.ld.bz2
Description: application/bzip

Attachment: multiboot.dmp.bz2
Description: application/bzip

Attachment: uTachyon.dmp.bz2
Description: application/bzip


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