Completely stymied by COFF link editor command language!
Ronald Cole
ronald at cvms.uucp
Tue Aug 8 10:11:35 AEST 1989
Wizards of the Net:
I have a wizard-type problem requiring wizard-type expertise for the
solution, which currently eludes me due to the skimpy nature of the
link editor documentation...
Please, please, email replies to me because I only get the gnu.* groups
(due to the rather prohibitive cost of getting netnews long distance).
Here's the beef...in making GNU C++ work with COFF, the compiler was
patched to make static global constructor addresses live in a .ctors section
(by way of .section .ctors,"x") and static global destructor addresses live
in a .dtors section (also, by way of .section .dtors,"x"). These two
user-defined sections are to be grouped in with .text but placed after
the .text section through the use of link editor directives file.
I am using System V/386 Release 3.2, and the link editor manual states that
the default allocation algorithm of ld(1) is:
SECTIONS
{
.text sizeof_headers : { *(.init) *(.text) *(.fini)}
GROUP BIND( NEXT(align_value) +
((SIZEOF(.text) + ADDR(.text)) % 0x2000)) :
{
.data : { }
.bss : { }
}
}
where "align_value" is a machine-dependent constant and "sizeof_headers"
is the size of *all* headers in the output file. Hmm, kinda vague thought I!
No indication of how to calculate the "sizeof_headers" or the "align_value"!!
After a few days of pumping lots of executables through nm late at night,
examining the output and then some trial and error, I came up with this:
SECTIONS
{
.text 0xD0: { *(.init) *(.text) *(.ctors) *(.dtors) *(.fini) }
GROUP BIND(0x3FE000 + ADDR(.text) + SIZEOF(.text)):
{ .data : { } .bss : { } }
}
and it allowed me to build the GNU libg++ class library and everything else
I had written in C++ with the GNU C++ compiler. I thought life was all rosy
until I got the GNU C++ test suite and these hard-coded constants jumped up
and bit me in the ass pretty good! The size of all the headers in certain
output files changed to 0x120, as did the address .data should have gotten
bound to! (probably not *too* surprising, though)
Could some ld guru help me fill in the blanks in the manual and tell me
how to correctly do the "sizeof_headers" and the "align_value" in the link
editor command language? (remember, email please)
--
Ronald Cole | uucp: cvms!ronald voice: +1 916 895 8321
Senior Software Engineer | internet: csusac!cvms!ronald at ucdavis.edu
CVM Systems +----------------------------------------------------
"SCCS, the source motel! Programs check in and never check out!" - Ken Thompson
More information about the Comp.unix.wizards
mailing list