X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=object.c;h=fe107434f9c835538a4bbe8dce2a4233d5f1a413;hp=7545866fd8a9f10106aad0adf726715fb0f951d4;hb=3a00205f107ec3c620e87c94ebb240abdf4f1787;hpb=8f287ee72236774216a11a3062f9a26dc8dc66b6 diff --git a/object.c b/object.c index 7545866..fe10743 100644 --- a/object.c +++ b/object.c @@ -173,14 +173,16 @@ uint8_t * AddBSDSymEntry(uint8_t * buf, SYM * sym, int globflag) { z = 0x02000000; // Set equated flag } - else + + // If a symbol is both EQUd and flagged as TBD then we let + // the later take precedence. Otherwise the linker will not even + // bother trying to relocate the address during link time + + switch (w1 & TDB) { - switch (w1 & TDB) - { - case TEXT: z = 0x04000000; break; // Set TEXT segment flag - case DATA: z = 0x06000000; break; // Set DATA segment flag - case BSS : z = 0x08000000; break; // Set BSS segment flag - } + case TEXT: z = 0x04000000; break; // Set TEXT segment flag + case DATA: z = 0x06000000; break; // Set DATA segment flag + case BSS : z = 0x08000000; break; // Set BSS segment flag } if (globflag) @@ -222,7 +224,7 @@ uint8_t * AddELFSymEntry(uint8_t * buf, SYM * sym, int globflag) if (w1 & DEFINED) { if (globflag) // Export the symbol - st_info |= 16; //STB_GLOBAL (1<<4) + st_info |= 16; // STB_GLOBAL (1<<4) } else if (w1 & (GLOBAL | REFERENCED)) st_info |= 16; @@ -230,7 +232,7 @@ uint8_t * AddELFSymEntry(uint8_t * buf, SYM * sym, int globflag) D_byte(st_info); D_byte(0); // st_other - uint16_t st_shndx = 0xFFF1; // Assume absolute (equated) number + uint16_t st_shndx = SHN_ABS; // Assume absolute (equated) number if (w1 & TEXT) st_shndx = elfHdrNum[ES_TEXT]; @@ -238,8 +240,13 @@ uint8_t * AddELFSymEntry(uint8_t * buf, SYM * sym, int globflag) st_shndx = elfHdrNum[ES_DATA]; else if (w1 & BSS) st_shndx = elfHdrNum[ES_BSS]; - else if (globflag) - st_shndx = 0; // Global, not absolute + else if (globflag && !(w1 & DEFINED) && (w1 & REFERENCED)) + { + st_shndx = SHN_UNDEF; + } // If the symbol is global then probably we + // don't need to do anything (probably) + // since we set STB_GLOBAL in st_info above. + // Unless we need to set it to SHN_COMMON? D_word(st_shndx);