Commit 4566868b authored by Mikkel Krautz's avatar Mikkel Krautz Committed by Russ Cox

6l, 8l: emit macho dwarf info before linkedit section

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5272050
parent c7cf56be
......@@ -703,7 +703,7 @@ asmb(void)
{
int32 magic;
int a, dynsym;
vlong vl, startva, symo, machlink;
vlong vl, startva, symo, dwarfoff, machlink;
ElfEhdr *eh;
ElfPhdr *ph, *pph;
ElfShdr *sh;
......@@ -738,8 +738,19 @@ asmb(void)
datblk(segdata.vaddr, segdata.filelen);
machlink = 0;
if(HEADTYPE == Hdarwin)
if(HEADTYPE == Hdarwin) {
if(debug['v'])
Bprint(&bso, "%5.2f dwarf\n", cputime());
dwarfoff = rnd(HEADR+segtext.len, INITRND) + rnd(segdata.filelen, INITRND);
cseek(dwarfoff);
segdwarf.fileoff = cpos();
dwarfemitdebugsections();
segdwarf.filelen = cpos() - segdwarf.fileoff;
machlink = domacholink();
}
switch(HEADTYPE) {
default:
......@@ -811,7 +822,6 @@ asmb(void)
dwarfemitdebugsections();
}
break;
case Hdarwin:
case Hwindows:
if(debug['v'])
Bprint(&bso, "%5.2f dwarf\n", cputime());
......
......@@ -660,7 +660,7 @@ asmb(void)
{
int32 v, magic;
int a, dynsym;
uint32 symo, startva, machlink;
uint32 symo, startva, dwarfoff, machlink;
ElfEhdr *eh;
ElfPhdr *ph, *pph;
ElfShdr *sh;
......@@ -691,8 +691,19 @@ asmb(void)
datblk(segdata.vaddr, segdata.filelen);
machlink = 0;
if(HEADTYPE == Hdarwin)
if(HEADTYPE == Hdarwin) {
if(debug['v'])
Bprint(&bso, "%5.2f dwarf\n", cputime());
dwarfoff = rnd(HEADR+segtext.len, INITRND) + rnd(segdata.filelen, INITRND);
cseek(dwarfoff);
segdwarf.fileoff = cpos();
dwarfemitdebugsections();
segdwarf.filelen = cpos() - segdwarf.fileoff;
machlink = domacholink();
}
if(iself) {
/* index of elf text section; needed by asmelfsym, double-checked below */
......@@ -772,7 +783,6 @@ asmb(void)
cflush();
}
break;
case Hdarwin:
case Hwindows:
if(debug['v'])
Bprint(&bso, "%5.2f dwarf\n", cputime());
......
......@@ -129,6 +129,7 @@ EXTERN int havedynamic;
EXTERN Segment segtext;
EXTERN Segment segdata;
EXTERN Segment segsym;
EXTERN Segment segdwarf;
void addlib(char *src, char *obj);
void addlibpath(char *srcref, char *objref, char *file, char *pkg);
......
......@@ -505,7 +505,7 @@ domacholink(void)
size = s1->size + s2->size + s3->size + s4->size;
if(size > 0) {
linkoff = rnd(HEADR+segtext.len, INITRND) + rnd(segdata.filelen, INITRND);
linkoff = rnd(HEADR+segtext.len, INITRND) + rnd(segdata.filelen, INITRND) + rnd(segdwarf.filelen, INITRND);
cseek(linkoff);
cwrite(s1->p, s1->size);
......
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