[Issue 3453] Linking order affects proper execution (Mac OSX only)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 30 18:41:13 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3453



--- Comment #3 from Michel Fortin <michel.fortin at michelf.com> 2010-01-30 21:41:11 EST ---
I think I figured out what's happening. Indeed, the linker doesn't put the
sections in the right order. The reason seems to be because dmd generates empty
sections in all but the main object file, and those empty sections are skipped.

With the second "simplified" test case, if I compile other.d and use dumpobj to
check the content of other.o, I get this:

[12] 000f4 0000 000564    2 0000   0 00000000 00 00 __minfo_beg __DATA
[13] 000f4 0004 000564    2 05e0   1 00000000 00 00 __minfodata __DATA
 0000:  20  0  0  0                                        ...            
  [0] address x0000 section 2 pcrel 0 length 2 extern 0 type 0 RELOC_VANILLA
[14] 000f8 0000 000568    2 0000   0 00000000 00 00 __minfo_end __DATA

If on the other hand I take the "objdump -s" tool that comes with the developer
tools, I see that it only sees __minfodata:

Contents of section LC_SEGMENT.__DATA.__minfodata:
 00f4 20000000                              ...            

Looks like sections with no data in them are ignored. The reason it works when
main.o is linked first is because in main.o sections __minfo_beg and
__minfo_end are not empty.

So a solution could be to never leave a section empty. I hope this helps.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list