Commit ca9098ee authored by Luuk van Dijk's avatar Luuk van Dijk

Dwarf output for 6l.

Part 1, general scaffolding and pc/lc sections.

R=rsc, r, ken2
CC=golang-dev
https://golang.org/cl/1987042
parent 632417e5
......@@ -9,6 +9,7 @@ TARG=\
OFILES=\
asm.$O\
dwarf.$O\
elf.$O\
enam.$O\
go.$O\
......@@ -26,6 +27,7 @@ HFILES=\
../ld/lib.h\
../ld/elf.h\
../ld/macho.h\
../ld/dwarf.h\
$(TARG): $(OFILES)
$(LD) -o $(TARG) -L"$(GOROOT)"/lib $(OFILES) -lbio -l9
......
......@@ -31,6 +31,7 @@
#include "l.h"
#include "../ld/lib.h"
#include "../ld/elf.h"
#include "../ld/dwarf.h"
#include "../ld/macho.h"
#define Dbufslop 100
......@@ -300,10 +301,9 @@ doelf(void)
elfstr[ElfStrGosymcounts] = addstring(shstrtab, ".gosymcounts");
elfstr[ElfStrGosymtab] = addstring(shstrtab, ".gosymtab");
elfstr[ElfStrGopclntab] = addstring(shstrtab, ".gopclntab");
if(debug['e']) {
elfstr[ElfStrSymtab] = addstring(shstrtab, ".symtab");
elfstr[ElfStrStrtab] = addstring(shstrtab, ".strtab");
}
dwarfaddshstrings(shstrtab);
}
elfstr[ElfStrShstrtab] = addstring(shstrtab, ".shstrtab");
......@@ -546,7 +546,7 @@ asmb(void)
seek(cout, v, 0);
/* index of elf text section; needed by asmelfsym, double-checked below */
/* debug['d'] causes 8 extra sections before the .text section */
/* !debug['d'] causes 8 extra sections before the .text section */
elftextsh = 1;
if(!debug['d'])
elftextsh += 8;
......@@ -627,7 +627,7 @@ asmb(void)
lputl(symsize);
lputl(lcsize);
cflush();
if(!debug['s'] && debug['e']) {
if(!debug['s']) {
elfsymo = symo+8+symsize+lcsize;
seek(cout, elfsymo, 0);
asmelfsym();
......@@ -635,6 +635,11 @@ asmb(void)
elfstro = seek(cout, 0, 1);
elfsymsize = elfstro - elfsymo;
write(cout, elfstrdat, elfstrsize);
if(debug['v'])
Bprint(&bso, "%5.2f dwarf\n", cputime());
dwarfemitdebugsections();
}
} else
if(dlm){
......@@ -911,7 +916,6 @@ asmb(void)
sh->addralign = 1;
sh->addr = symdatva + 8 + symsize;
if(debug['e']) {
sh = newElfShdr(elfstr[ElfStrSymtab]);
sh->type = SHT_SYMTAB;
sh->off = elfsymo;
......@@ -925,7 +929,8 @@ asmb(void)
sh->off = elfstro;
sh->size = elfstrsize;
sh->addralign = 1;
}
dwarfaddheaders();
}
sh = newElfShstrtab(elfstr[ElfStrShstrtab]);
......@@ -977,6 +982,13 @@ cflush(void)
cbc = sizeof(buf.cbuf);
}
/* Current position in file */
vlong
cpos(void)
{
return seek(cout, 0, 1) + sizeof(buf.cbuf) - cbc;
}
void
outa(int n, uchar *cast, uchar *map, vlong l)
{
......@@ -1322,4 +1334,3 @@ rnd(vlong v, vlong r)
v -= c;
return v;
}
......@@ -394,6 +394,7 @@ Prog* brchain(Prog*);
Prog* brloop(Prog*);
void buildop(void);
void cflush(void);
vlong cpos(void);
void ckoff(Sym*, int32);
Prog* copyp(Prog*);
double cputime(void);
......
......@@ -33,6 +33,7 @@
#include "../ld/lib.h"
#include "../ld/elf.h"
#include "../ld/macho.h"
#include "../ld/dwarf.h"
#include <ar.h>
char *noname = "<none>";
......@@ -575,6 +576,7 @@ loop:
histfrogp++;
} else
collapsefrog(s);
dwarfaddfrag(s->value, s->name);
}
goto loop;
}
......@@ -1058,4 +1060,3 @@ doprof2(void)
}
}
}
This diff is collapsed.
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
* Register 'f' symbol file fragments. Doing this while parsing the
* .6 input saves a pass over the symbol table later.
*/
void dwarfaddfrag(int n, char* frag);
/*
* Add the dwarf section names to the ELF
* s[ection]h[eader]str[ing]tab.
*/
void dwarfaddshstrings(Sym *shstrtab);
/*
* Emit debug_abbrevs, debug_info and debug_line sections to current
* offset in cout.
*/
void dwarfemitdebugsections(void);
/*
* Add ELF section headers pointing to the sections emitted in
* dwarfemitdebugsections.
*/
void dwarfaddheaders(void);
This diff is collapsed.
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