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
34691ccd
Commit
34691ccd
authored
Jun 13, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support symbol tables and line numbers in 6.out executables
SVN=122700
parent
e9c9c9ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletion
+50
-1
src/libmach_amd64/executable.c
src/libmach_amd64/executable.c
+48
-1
src/make.bash
src/make.bash
+2
-0
No files found.
src/libmach_amd64/executable.c
View file @
34691ccd
...
...
@@ -626,7 +626,8 @@ elf64dotout(int fd, Fhdr *fp, ExecHdr *hp)
ushort
(
*
swab
)(
ushort
);
Ehdr64
*
ep
;
Phdr64
*
ph
;
int
i
,
it
,
id
,
is
,
phsz
;
Shdr64
*
sh
;
int
i
,
it
,
id
,
is
,
phsz
,
shsz
;
/* bitswap the header according to the DATA format */
ep
=
&
hp
->
e
.
elfhdr64
;
...
...
@@ -711,6 +712,17 @@ print("entry: 0x%x\n", ep->elfentry);
}
hswal
(
ph
,
phsz
/
sizeof
(
ulong
),
swal
);
shsz
=
sizeof
(
Shdr64
)
*
ep
->
shnum
;
sh
=
malloc
(
shsz
);
if
(
sh
)
{
seek
(
fd
,
ep
->
shoff
,
0
);
if
(
read
(
fd
,
sh
,
shsz
)
<
0
)
{
free
(
sh
);
sh
=
0
;
}
else
hswal
(
ph
,
phsz
/
sizeof
(
ulong
),
swal
);
}
/* find text, data and symbols and install them */
it
=
id
=
is
=
-
1
;
for
(
i
=
0
;
i
<
ep
->
phnum
;
i
++
)
{
...
...
@@ -748,7 +760,9 @@ print("entry: 0x%x\n", ep->elfentry);
}
werrstr
(
"No TEXT or DATA sections"
);
error:
free
(
ph
);
free
(
sh
);
return
0
;
}
...
...
@@ -756,7 +770,40 @@ print("entry: 0x%x\n", ep->elfentry);
setdata
(
fp
,
ph
[
id
].
vaddr
,
ph
[
id
].
filesz
,
ph
[
id
].
offset
,
ph
[
id
].
memsz
-
ph
[
id
].
filesz
);
if
(
is
!=
-
1
)
setsym
(
fp
,
ph
[
is
].
filesz
,
0
,
ph
[
is
].
memsz
,
ph
[
is
].
offset
);
else
if
(
ep
->
machine
==
AMD64
&&
sh
!=
0
){
char
*
buf
;
uvlong
symsize
=
0
;
uvlong
symoff
=
0
;
uvlong
pclnsz
=
0
;
/* load shstrtab names */
buf
=
malloc
(
sh
[
ep
->
shstrndx
].
size
);
if
(
buf
==
0
)
goto
done
;
memset
(
buf
,
0
,
sizeof
buf
);
seek
(
fd
,
sh
[
ep
->
shstrndx
].
offset
,
0
);
read
(
fd
,
buf
,
sh
[
ep
->
shstrndx
].
size
);
for
(
i
=
0
;
i
<
ep
->
shnum
;
i
++
)
{
if
(
sh
[
i
].
type
==
2
&&
strcmp
(
&
buf
[
sh
[
i
].
name
],
".gosymtab"
)
==
0
)
{
symsize
=
sh
[
i
].
size
;
symoff
=
sh
[
i
].
offset
;
}
if
(
sh
[
i
].
type
==
2
&&
strcmp
(
&
buf
[
sh
[
i
].
name
],
".gopclntab"
)
==
0
)
{
if
(
sh
[
i
].
offset
!=
symoff
+
symsize
)
{
werrstr
(
"pc line table not contiguous with symbol table"
);
free
(
buf
);
goto
error
;
}
pclnsz
=
sh
[
i
].
size
;
}
}
setsym
(
fp
,
symsize
,
0
,
pclnsz
,
symoff
);
free
(
buf
);
}
done:
free
(
ph
);
free
(
sh
);
return
1
;
}
...
...
src/make.bash
View file @
34691ccd
...
...
@@ -3,6 +3,8 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
bash clean.bash
for
i
in
lib9 libbio libmach_amd64
do
cd
$i
...
...
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