Commit 825b1e15 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/ld: emit relocs for DWARF info when doing an external link

I would like opinions on whether this is a good idea for 1.1.
On the one hand it's a moderately important issue.  On the
other hand this introduces at least the possibility of
external linker errors due to the additional relocations and
it may be better to wait.

I'm fairly confident that the behaviour is unchanged when not
using an external linker.

Update #5221

This CL is tested lightly on 386 and amd64 and fixes the cases
I tested.  I have not tested it on Darwin or Windows.

R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/8858047
parent b461c94c
This diff is collapsed.
......@@ -1421,9 +1421,7 @@ elfobj:
sh->size = elfstrsize;
sh->addralign = 1;
// TODO(rsc): Enable for linkmode == LinkExternal too, once we know it works.
if(linkmode != LinkExternal)
dwarfaddelfheaders();
dwarfaddelfheaders();
}
/* Main header */
......
......@@ -855,7 +855,8 @@ struct Elf64_Shdr {
Elf64_Xword addralign; /* Alignment in bytes. */
Elf64_Xword entsize; /* Size of each entry in section. */
int shnum; /* section number, not stored on disk */
int shnum; /* section number, not stored on disk */
Sym* secsym; /* section symbol, if needed; not on disk */
};
/*
......@@ -998,6 +999,7 @@ void phsh(ElfPhdr*, ElfShdr*);
void doelf(void);
void elfsetupplt(void);
void dwarfaddshstrings(Sym*);
void dwarfaddelfsectionsyms(void);
void dwarfaddelfheaders(void);
void asmbelf(vlong symo);
void asmbelfsetup(void);
......@@ -1006,6 +1008,7 @@ extern char freebsddynld[];
extern char netbsddynld[];
extern char openbsddynld[];
int elfreloc1(Reloc*, vlong sectoff);
void putelfsectionsyms(void);
EXTERN int elfstrsize;
EXTERN char* elfstrdat;
......
......@@ -249,6 +249,8 @@ void setuint64(Sym*, vlong, uint64);
void asmsym(void);
void asmelfsym(void);
void asmplan9sym(void);
void putelfsectionsym(Sym*, int);
void putelfsymshndx(vlong, int);
void strnput(char*, int);
void dodata(void);
void dosymtype(void);
......
......@@ -142,6 +142,31 @@ putelfsym(Sym *x, char *s, int t, vlong addr, vlong size, int ver, Sym *go)
x->elfsym = numelfsym++;
}
void
putelfsectionsym(Sym* s, int shndx)
{
putelfsyment(0, 0, 0, (STB_LOCAL<<4)|STT_SECTION, shndx, 0);
s->elfsym = numelfsym++;
}
void
putelfsymshndx(vlong sympos, int shndx)
{
vlong here;
here = cpos();
switch(thechar) {
case '6':
cseek(sympos+6);
break;
default:
cseek(sympos+14);
break;
}
WPUT(shndx);
cseek(here);
}
void
asmelfsym(void)
{
......@@ -150,6 +175,8 @@ asmelfsym(void)
// the first symbol entry is reserved
putelfsyment(0, 0, 0, (STB_LOCAL<<4)|STT_NOTYPE, 0, 0);
dwarfaddelfsectionsyms();
elfbind = STB_LOCAL;
genasmsym(putelfsym);
......
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