Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
b433552e
Commit
b433552e
authored
Aug 30, 2010
by
Luuk van Dijk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
8l: emit DWARF in ELF.
R=rsc, r, ken2 CC=golang-dev
https://golang.org/cl/2004046
parent
5c603dbb
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
514 additions
and
449 deletions
+514
-449
src/cmd/6l/asm.c
src/cmd/6l/asm.c
+1
-2
src/cmd/6l/l.h
src/cmd/6l/l.h
+1
-1
src/cmd/8l/Makefile
src/cmd/8l/Makefile
+4
-1
src/cmd/8l/asm.c
src/cmd/8l/asm.c
+18
-2
src/cmd/8l/l.h
src/cmd/8l/l.h
+1
-0
src/cmd/8l/obj.c
src/cmd/8l/obj.c
+2
-0
src/cmd/ld/dwarf.c
src/cmd/ld/dwarf.c
+487
-443
No files found.
src/cmd/6l/asm.c
View file @
b433552e
...
...
@@ -641,8 +641,7 @@ asmb(void)
dwarfemitdebugsections
();
}
}
else
if
(
dlm
){
}
else
if
(
dlm
){
seek
(
cout
,
HEADR
+
textsize
+
datsize
,
0
);
asmdyn
();
cflush
();
...
...
src/cmd/6l/l.h
View file @
b433552e
...
...
@@ -394,9 +394,9 @@ Prog* brchain(Prog*);
Prog
*
brloop
(
Prog
*
);
void
buildop
(
void
);
void
cflush
(
void
);
vlong
cpos
(
void
);
void
ckoff
(
Sym
*
,
int32
);
Prog
*
copyp
(
Prog
*
);
vlong
cpos
(
void
);
double
cputime
(
void
);
void
datblk
(
int32
,
int32
);
void
deadcode
(
void
);
...
...
src/cmd/8l/Makefile
View file @
b433552e
...
...
@@ -9,8 +9,10 @@ TARG=8l
OFILES
=
\
asm.
$O
\
dwarf.
$O
\
elf.
$O
\
enam.
$O
\
go.
$O
\
lib.
$O
\
list.
$O
\
macho.
$O
\
...
...
@@ -19,11 +21,12 @@ OFILES=\
pass.
$O
\
pe.
$O
\
span.
$O
\
go.
$O
\
HFILES
=
\
l.h
\
../8l/8.out.h
\
../ld/dwarf.h
\
../ld/elf.h
\
../ld/macho.h
\
../ld/pe.h
\
...
...
src/cmd/8l/asm.c
View file @
b433552e
...
...
@@ -31,6 +31,7 @@
#include "l.h"
#include "../ld/lib.h"
#include "../ld/elf.h"
#include "../ld/dwarf.h"
#include "../ld/macho.h"
#include "../ld/pe.h"
...
...
@@ -293,6 +294,7 @@ doelf(void)
elfstr
[
ElfStrGosymcounts
]
=
addstring
(
shstrtab
,
".gosymcounts"
);
elfstr
[
ElfStrGosymtab
]
=
addstring
(
shstrtab
,
".gosymtab"
);
elfstr
[
ElfStrGopclntab
]
=
addstring
(
shstrtab
,
".gopclntab"
);
dwarfaddshstrings
(
shstrtab
);
}
elfstr
[
ElfStrShstrtab
]
=
addstring
(
shstrtab
,
".shstrtab"
);
...
...
@@ -649,8 +651,13 @@ asmb(void)
lputl
(
symsize
);
lputl
(
lcsize
);
cflush
();
if
(
!
debug
[
's'
])
{
seek
(
cout
,
symo
+
8
+
symsize
+
lcsize
,
0
);
if
(
debug
[
'v'
])
Bprint
(
&
bso
,
"%5.2f dwarf
\n
"
,
cputime
());
dwarfemitdebugsections
();
}
else
if
(
dlm
){
}
else
if
(
dlm
){
seek
(
cout
,
HEADR
+
textsize
+
datsize
,
0
);
asmdyn
();
cflush
();
...
...
@@ -1042,6 +1049,8 @@ asmb(void)
sh
->
size
=
w
;
sh
->
addralign
=
1
;
sh
->
addr
=
symdatva
+
8
+
symsize
;
dwarfaddheaders
();
}
sh
=
newElfShstrtab
(
elfstr
[
ElfStrShstrtab
]);
...
...
@@ -1118,6 +1127,13 @@ cflush(void)
cbc
=
sizeof
(
buf
.
cbuf
);
}
/* Current position in file */
vlong
cpos
(
void
)
{
return
seek
(
cout
,
0
,
1
)
+
sizeof
(
buf
.
cbuf
)
-
cbc
;
}
void
datblk
(
int32
s
,
int32
n
)
{
...
...
src/cmd/8l/l.h
View file @
b433552e
...
...
@@ -345,6 +345,7 @@ Prog* brloop(Prog*);
void
cflush
(
void
);
void
ckoff
(
Sym
*
,
int32
);
Prog
*
copyp
(
Prog
*
);
vlong
cpos
(
void
);
double
cputime
(
void
);
void
datblk
(
int32
,
int32
);
void
diag
(
char
*
,
...);
...
...
src/cmd/8l/obj.c
View file @
b433552e
...
...
@@ -33,6 +33,7 @@
#include "../ld/lib.h"
#include "../ld/elf.h"
#include "../ld/macho.h"
#include "../ld/dwarf.h"
#include "../ld/pe.h"
#include <ar.h>
...
...
@@ -604,6 +605,7 @@ loop:
histfrogp
++
;
}
else
collapsefrog
(
s
);
dwarfaddfrag
(
s
->
value
,
s
->
name
);
}
goto
loop
;
}
...
...
src/cmd/ld/dwarf.c
View file @
b433552e
...
...
@@ -39,6 +39,7 @@ enum
{
DW_ABRV_NULL
,
DW_ABRV_COMPUNIT
,
DW_ABRV_FUNCTION
,
DW_NABRV
};
...
...
@@ -60,6 +61,14 @@ struct DWAbbrev {
DW_AT_stmt_list
,
DW_FORM_data4
,
0
,
0
},
/* FUNCTION */
{
DW_TAG_subprogram
,
DW_CHILDREN_no
,
DW_AT_name
,
DW_FORM_string
,
DW_AT_low_pc
,
DW_FORM_addr
,
DW_AT_high_pc
,
DW_FORM_addr
,
0
,
0
},
};
/*
...
...
@@ -116,6 +125,18 @@ newattr(DWDie *die, uint8 attr, int cls, vlong value, char *data)
return
a
;
}
static
void
addrput
(
vlong
addr
)
{
switch
(
PtrSize
)
{
case
4
:
LPUT
(
addr
);
break
;
case
8
:
VPUT
(
addr
);
break
;
}
}
static
void
uleb128put
(
uvlong
v
)
{
...
...
@@ -149,7 +170,7 @@ putattr(int form, int cls, vlong value, char *data)
{
switch
(
form
)
{
case
DW_FORM_addr
:
// address
VPUT
(
value
);
addrput
(
value
);
break
;
case
DW_FORM_block1
:
// block
...
...
@@ -280,6 +301,17 @@ reverselist(DWDie** list)
*
list
=
prev
;
}
static
void
reversetree
(
DWDie
**
list
)
{
DWDie
*
die
;
reverselist
(
list
);
if
(
*
list
!=
nil
&&
abbrevs
[(
*
list
)
->
abbrev
].
children
)
for
(
die
=
*
list
;
die
!=
nil
;
die
=
die
->
link
)
reversetree
(
&
die
->
child
);
}
/*
* Filename fragments for the line history stack.
*/
...
...
@@ -320,7 +352,7 @@ decodez(char *s)
return
0
;
}
f
=
ftab
[
o
];
if
(
!
f
)
{
if
(
f
==
nil
)
{
diag
(
"corrupt z entry"
);
return
0
;
}
...
...
@@ -667,24 +699,34 @@ writelines(void)
strnput
(
histfile
[
i
],
strlen
(
histfile
[
i
])
+
4
);
// 4 zeros: the string termination + 3 fields.
}
pc
=
p
->
pc
;
currfile
=
1
;
lc
=
1
;
llc
=
1
;
cput
(
0
);
// start extended opcode
uleb128put
(
1
+
sizeof
pc
);
uleb128put
(
1
+
PtrSize
);
cput
(
DW_LNE_set_address
);
VPUT
(
pc
);
addrput
(
pc
);
}
if
(
!
p
->
from
.
sym
->
reachable
)
continue
;
if
(
unitstart
<
0
)
{
diag
(
"R
eachable code before seeing any history: %P"
,
p
);
diag
(
"r
eachable code before seeing any history: %P"
,
p
);
continue
;
}
dwinfo
->
child
=
newdie
(
dwinfo
->
child
,
DW_ABRV_FUNCTION
);
newattr
(
dwinfo
->
child
,
DW_AT_name
,
DW_CLS_STRING
,
strlen
(
s
->
name
),
s
->
name
);
newattr
(
dwinfo
->
child
,
DW_AT_low_pc
,
DW_CLS_ADDRESS
,
p
->
pc
,
0
);
if
(
debug
[
'v'
]
>
1
)
print
(
"frame offset: %d
\n
"
,
p
->
to
.
offset
);
// newattr(dwinfo->child, DW_AT_return_addr, DW_CLS_BLOCK, p->to.offset, 0);
for
(
q
=
p
;
q
!=
P
&&
(
q
==
p
||
q
->
as
!=
ATEXT
);
q
=
q
->
link
)
{
lh
=
searchhist
(
q
->
line
);
if
(
!
lh
)
{
if
(
lh
==
nil
)
{
diag
(
"corrupt history or bad absolute line: %P"
,
q
);
continue
;
}
...
...
@@ -704,6 +746,7 @@ writelines(void)
lc
=
q
->
line
;
llc
=
lline
;
}
newattr
(
dwinfo
->
child
,
DW_AT_high_pc
,
DW_CLS_ADDRESS
,
pc
,
0
);
}
flushunit
(
pc
,
unitstart
);
linesize
=
cpos
()
-
lineo
;
...
...
@@ -718,7 +761,7 @@ writeinfo(void)
DWDie
*
compunit
;
vlong
unitstart
;
reverselist
(
&
dwinfo
);
reversetree
(
&
dwinfo
);
infoo
=
cpos
();
...
...
@@ -730,7 +773,7 @@ writeinfo(void)
LPUT
(
0
);
// unit_length (*), will be filled in later.
WPUT
(
3
);
// version
LPUT
(
0
);
// debug_abbrev_offset (*)
cput
(
8
);
// address_size
cput
(
PtrSize
);
// address_size
putdie
(
compunit
);
...
...
@@ -749,7 +792,8 @@ writeinfo(void)
/*
* Elf sections.
*/
enum
{
enum
{
ElfStrDebugAbbrev
,
ElfStrDebugAranges
,
ElfStrDebugFrame
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment