1
0
mirror of https://github.com/golang/go synced 2024-11-22 01:34:41 -07:00

cmd/5l: dwarf line number support for Linux/ARM

Part of issue 3747.

R=dave, lvd, rsc
CC=golang-dev
https://golang.org/cl/6084044
This commit is contained in:
Shenghou Ma 2012-08-07 10:09:24 +08:00
parent df623d03ab
commit 0cb04168d3
7 changed files with 33 additions and 44 deletions

View File

@ -33,6 +33,7 @@
#include "l.h" #include "l.h"
#include "../ld/lib.h" #include "../ld/lib.h"
#include "../ld/elf.h" #include "../ld/elf.h"
#include "../ld/dwarf.h"
static Prog *PP; static Prog *PP;
@ -509,6 +510,7 @@ doelf(void)
if(!debug['s']) { if(!debug['s']) {
elfstr[ElfStrSymtab] = addstring(shstrtab, ".symtab"); elfstr[ElfStrSymtab] = addstring(shstrtab, ".symtab");
elfstr[ElfStrStrtab] = addstring(shstrtab, ".strtab"); elfstr[ElfStrStrtab] = addstring(shstrtab, ".strtab");
dwarfaddshstrings(shstrtab);
} }
elfstr[ElfStrShstrtab] = addstring(shstrtab, ".shstrtab"); elfstr[ElfStrShstrtab] = addstring(shstrtab, ".shstrtab");
@ -723,12 +725,11 @@ asmb(void)
cflush(); cflush();
cwrite(elfstrdat, elfstrsize); cwrite(elfstrdat, elfstrsize);
// if(debug['v']) if(debug['v'])
// Bprint(&bso, "%5.2f dwarf\n", cputime()); Bprint(&bso, "%5.2f dwarf\n", cputime());
// dwarfemitdebugsections(); dwarfemitdebugsections();
} }
cflush(); cflush();
} }
cursym = nil; cursym = nil;
@ -989,7 +990,7 @@ asmb(void)
sh->size = elfstrsize; sh->size = elfstrsize;
sh->addralign = 1; sh->addralign = 1;
// dwarfaddelfheaders(); dwarfaddelfheaders();
} }
/* Main header */ /* Main header */
@ -2317,9 +2318,3 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*))
Bprint(&bso, "symsize = %ud\n", symsize); Bprint(&bso, "symsize = %ud\n", symsize);
Bflush(&bso); Bflush(&bso);
} }
void
setpersrc(Sym *s)
{
USED(s);
}

View File

@ -401,6 +401,9 @@ void span(void);
void strnput(char*, int); void strnput(char*, int);
int32 symaddr(Sym*); int32 symaddr(Sym*);
void undef(void); void undef(void);
void vputb(uint64);
void vputl(uint64);
void wputb(uint16);
void wput(int32); void wput(int32);
void wputl(ushort w); void wputl(ushort w);
void xdefine(char*, int, int32); void xdefine(char*, int, int32);
@ -428,3 +431,9 @@ vlong adduintxx(Sym *s, uint64 v, int wid);
#define VPUT(a) abort() #define VPUT(a) abort()
#endif #endif
/* Used by ../ld/dwarf.c */
enum
{
DWARFREGSP = 13
};

View File

@ -365,11 +365,7 @@ noops(void)
q1 = p; q1 = p;
/* MOV a,4(SP) */ /* MOV a,4(SP) */
q = prg(); p = appendp(p);
q->link = p->link;
p->link = q;
p = q;
p->as = AMOVW; p->as = AMOVW;
p->line = q1->line; p->line = q1->line;
p->from.type = D_REG; p->from.type = D_REG;
@ -379,11 +375,7 @@ noops(void)
p->to.offset = 4; p->to.offset = 4;
/* MOV b,REGTMP */ /* MOV b,REGTMP */
q = prg(); p = appendp(p);
q->link = p->link;
p->link = q;
p = q;
p->as = AMOVW; p->as = AMOVW;
p->line = q1->line; p->line = q1->line;
p->from.type = D_REG; p->from.type = D_REG;
@ -395,11 +387,7 @@ noops(void)
p->to.offset = 0; p->to.offset = 0;
/* CALL appropriate */ /* CALL appropriate */
q = prg(); p = appendp(p);
q->link = p->link;
p->link = q;
p = q;
p->as = ABL; p->as = ABL;
p->line = q1->line; p->line = q1->line;
p->to.type = D_BRANCH; p->to.type = D_BRANCH;
@ -424,11 +412,7 @@ noops(void)
} }
/* MOV REGTMP, b */ /* MOV REGTMP, b */
q = prg(); p = appendp(p);
q->link = p->link;
p->link = q;
p = q;
p->as = AMOVW; p->as = AMOVW;
p->line = q1->line; p->line = q1->line;
p->from.type = D_REG; p->from.type = D_REG;
@ -438,12 +422,9 @@ noops(void)
p->to.reg = q1->to.reg; p->to.reg = q1->to.reg;
/* ADD $8,SP */ /* ADD $8,SP */
q = prg(); p = appendp(p);
q->link = p->link;
p->link = q;
p = q;
p->as = AADD; p->as = AADD;
p->line = q1->line;
p->from.type = D_CONST; p->from.type = D_CONST;
p->from.reg = NREG; p->from.reg = NREG;
p->from.offset = 8; p->from.offset = 8;

View File

@ -34,6 +34,7 @@
#include "l.h" #include "l.h"
#include "../ld/lib.h" #include "../ld/lib.h"
#include "../ld/elf.h" #include "../ld/elf.h"
#include "../ld/dwarf.h"
#include <ar.h> #include <ar.h>
#ifndef DEFAULT #ifndef DEFAULT
@ -481,6 +482,7 @@ loop:
histfrogp++; histfrogp++;
} else } else
collapsefrog(s); collapsefrog(s);
dwarfaddfrag(s->value, s->name);
} }
goto loop; goto loop;
} }

View File

@ -76,6 +76,7 @@ softfloat(void)
p->to.type = D_BRANCH; p->to.type = D_BRANCH;
p->to.sym = symsfloat; p->to.sym = symsfloat;
p->cond = psfloat; p->cond = psfloat;
p->line = next->line;
p = next; p = next;
wasfloat = 1; wasfloat = 1;

View File

@ -288,12 +288,20 @@ flushpool(Prog *p, int skip, int force)
q->to.type = D_BRANCH; q->to.type = D_BRANCH;
q->cond = p->link; q->cond = p->link;
q->link = blitrl; q->link = blitrl;
q->line = p->line;
blitrl = q; blitrl = q;
} }
else if(!force && (p->pc+pool.size-pool.start < 2048)) else if(!force && (p->pc+pool.size-pool.start < 2048))
return 0; return 0;
elitrl->link = p->link; elitrl->link = p->link;
p->link = blitrl; p->link = blitrl;
// BUG(minux): how to correctly handle line number for constant pool entries?
// for now, we set line number to the last instruction preceding them at least
// this won't bloat the .debug_line tables
while(blitrl) {
blitrl->line = p->line;
blitrl = blitrl->link;
}
blitrl = 0; /* BUG: should refer back to values until out-of-range */ blitrl = 0; /* BUG: should refer back to values until out-of-range */
elitrl = 0; elitrl = 0;
pool.size = 0; pool.size = 0;

View File

@ -474,14 +474,7 @@ static struct {
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a", "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a",
}}, }},
{"cmd/5l", { {"cmd/5l", {
"../ld/data.c", "../ld/*",
"../ld/elf.c",
"../ld/go.c",
"../ld/ldelf.c",
"../ld/ldmacho.c",
"../ld/ldpe.c",
"../ld/lib.c",
"../ld/symtab.c",
"enam.c", "enam.c",
}}, }},
{"cmd/6l", { {"cmd/6l", {