1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:17:57 -07:00

ld: Fix exported dynamic symbols on 386 Mach-O.

R=rsc
CC=golang-dev
https://golang.org/cl/3948043
This commit is contained in:
Ian Lance Taylor 2011-01-11 14:43:28 -08:00
parent cc928b7b6e
commit ac1c09458c

View File

@ -174,7 +174,7 @@ adddynrel(Sym *s, Reloc *r)
// Handle relocations found in ELF object files.
case 256 + R_386_PC32:
if(targ->dynimpname)
if(targ->dynimpname != nil && !targ->dynexport)
diag("unexpected R_386_PC32 relocation for dynamic symbol %s", targ->name);
if(targ->type == 0 || targ->type == SXREF)
diag("unknown symbol %s in pcrel", targ->name);
@ -185,7 +185,7 @@ adddynrel(Sym *s, Reloc *r)
case 256 + R_386_PLT32:
r->type = D_PCREL;
r->add += 4;
if(targ->dynimpname != nil) {
if(targ->dynimpname != nil && !targ->dynexport) {
addpltsym(targ);
r->sym = lookup(".plt", 0);
r->add += targ->plt;
@ -193,7 +193,7 @@ adddynrel(Sym *s, Reloc *r)
return;
case 256 + R_386_GOT32:
if(targ->dynimpname == nil) {
if(targ->dynimpname == nil || targ->dynexport) {
// have symbol
// turn MOVL of GOT entry into LEAL of symbol itself
if(r->off < 2 || s->p[r->off-2] != 0x8b) {
@ -221,19 +221,19 @@ adddynrel(Sym *s, Reloc *r)
return;
case 256 + R_386_32:
if(targ->dynimpname)
if(targ->dynimpname != nil && !targ->dynexport)
diag("unexpected R_386_32 relocation for dynamic symbol %s", targ->name);
r->type = D_ADDR;
return;
case 512 + MACHO_GENERIC_RELOC_VANILLA*2 + 0:
r->type = D_ADDR;
if(targ->dynimpname)
if(targ->dynimpname != nil && !targ->dynexport)
diag("unexpected reloc for dynamic symbol %s", targ->name);
return;
case 512 + MACHO_GENERIC_RELOC_VANILLA*2 + 1:
if(targ->dynimpname) {
if(targ->dynimpname != nil && !targ->dynexport) {
addpltsym(targ);
r->sym = lookup(".plt", 0);
r->add = targ->plt;
@ -241,12 +241,10 @@ adddynrel(Sym *s, Reloc *r)
return;
}
r->type = D_PCREL;
if(targ->dynimpname)
diag("unexpected pc-relative reloc for dynamic symbol %s", targ->name);
return;
case 512 + MACHO_FAKE_GOTPCREL:
if(targ->dynimpname == nil) {
if(targ->dynimpname == nil || targ->dynexport) {
// have symbol
// turn MOVL of GOT entry into LEAL of symbol itself
if(r->off < 2 || s->p[r->off-2] != 0x8b) {
@ -265,7 +263,7 @@ adddynrel(Sym *s, Reloc *r)
}
// Handle references to ELF symbols from our own object files.
if(targ->dynimpname == nil)
if(targ->dynimpname == nil || targ->dynexport)
return;
switch(r->type) {