cmd/5l,6l,8l: remove bogus dynsym section indexes

Previously, this code generated bogus section indexes for dynamic
symbols.  It turns out this didn't matter, since we only emit these
when generating an executable and in an executable it only matters
whether a symbol is defined or undefined, but it leads to perplexing
code full of mysterious constants.

Unfortunately, this happens too early to put in real section indexes,
so just use section index 1 to distinguish the symbol from an
undefined symbol.

Change-Id: I0e514604bf31f21683598ebd3e020b66acf767ef
Reviewed-on: https://go-review.googlesource.com/1720
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Austin Clements 2014-12-16 15:59:05 -05:00
parent 326ceeabc4
commit 7e424ecdc1
3 changed files with 6 additions and 54 deletions

View File

@ -510,24 +510,8 @@ adddynsym(Link *ctxt, LSym *s)
/* shndx */ /* shndx */
if(s->type == SDYNIMPORT) if(s->type == SDYNIMPORT)
adduint16(ctxt, d, SHN_UNDEF); adduint16(ctxt, d, SHN_UNDEF);
else { else
switch(s->type) { adduint16(ctxt, d, 1);
default:
case STEXT:
t = 11;
break;
case SRODATA:
t = 12;
break;
case SDATA:
t = 13;
break;
case SBSS:
t = 14;
break;
}
adduint16(ctxt, d, t);
}
} else { } else {
diag("adddynsym: unsupported binary format"); diag("adddynsym: unsupported binary format");
} }

View File

@ -548,24 +548,8 @@ adddynsym(Link *ctxt, LSym *s)
/* section where symbol is defined */ /* section where symbol is defined */
if(s->type == SDYNIMPORT) if(s->type == SDYNIMPORT)
adduint16(ctxt, d, SHN_UNDEF); adduint16(ctxt, d, SHN_UNDEF);
else { else
switch(s->type) { adduint16(ctxt, d, 1);
default:
case STEXT:
t = 11;
break;
case SRODATA:
t = 12;
break;
case SDATA:
t = 13;
break;
case SBSS:
t = 14;
break;
}
adduint16(ctxt, d, t);
}
/* value */ /* value */
if(s->type == SDYNIMPORT) if(s->type == SDYNIMPORT)

View File

@ -516,24 +516,8 @@ adddynsym(Link *ctxt, LSym *s)
/* shndx */ /* shndx */
if(s->type == SDYNIMPORT) if(s->type == SDYNIMPORT)
adduint16(ctxt, d, SHN_UNDEF); adduint16(ctxt, d, SHN_UNDEF);
else { else
switch(s->type) { adduint16(ctxt, d, 1);
default:
case STEXT:
t = 11;
break;
case SRODATA:
t = 12;
break;
case SDATA:
t = 13;
break;
case SBSS:
t = 14;
break;
}
adduint16(ctxt, d, t);
}
} else if(HEADTYPE == Hdarwin) { } else if(HEADTYPE == Hdarwin) {
diag("adddynsym: missed symbol %s (%s)", s->name, s->extname); diag("adddynsym: missed symbol %s (%s)", s->name, s->extname);
} else if(HEADTYPE == Hwindows) { } else if(HEADTYPE == Hwindows) {