Commit ac1c0945 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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

R=rsc
CC=golang-dev
https://golang.org/cl/3948043
parent cc928b7b
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment