Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
glog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
glog
Commits
f174cba0
Commit
f174cba0
authored
Jul 14, 2016
by
Fumitoshi Ukai
Committed by
GitHub
Jul 14, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #115 from pcc/fix1
symbolize: Calculate a module's zero VA using program headers.
parents
de6149ef
a93a4511
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
symbolize.cc
src/symbolize.cc
+24
-3
No files found.
src/symbolize.cc
View file @
f174cba0
...
...
@@ -327,7 +327,7 @@ FindSymbol(uint64_t pc, const int fd, char *out, int out_size,
// false.
static
bool
GetSymbolFromObjectFile
(
const
int
fd
,
uint64_t
pc
,
char
*
out
,
int
out_size
,
uint64_t
map_
start
_address
)
{
uint64_t
map_
base
_address
)
{
// Read the ELF header.
ElfW
(
Ehdr
)
elf_header
;
if
(
!
ReadFromOffsetExact
(
fd
,
&
elf_header
,
sizeof
(
elf_header
),
0
))
{
...
...
@@ -336,7 +336,28 @@ static bool GetSymbolFromObjectFile(const int fd, uint64_t pc,
uint64_t
symbol_offset
=
0
;
if
(
elf_header
.
e_type
==
ET_DYN
)
{
// DSO needs offset adjustment.
symbol_offset
=
map_start_address
;
ElfW
(
Phdr
)
phdr
;
// We need to find the PT_LOAD segment corresponding to the read-execute
// file mapping in order to correctly perform the offset adjustment.
for
(
unsigned
i
=
0
;
i
!=
elf_header
.
e_phnum
;
++
i
)
{
if
(
!
ReadFromOffsetExact
(
fd
,
&
phdr
,
sizeof
(
phdr
),
elf_header
.
e_phoff
+
i
*
sizeof
(
phdr
)))
return
false
;
if
(
phdr
.
p_type
==
PT_LOAD
&&
(
phdr
.
p_flags
&
(
PF_R
|
PF_X
))
==
(
PF_R
|
PF_X
))
{
// Find the mapped address corresponding to virtual address zero. We do
// this by first adding p_offset. This gives us the mapped address of
// the start of the segment, or in other words the mapped address
// corresponding to the virtual address of the segment. (Note that this
// is distinct from the start address, as p_offset is not guaranteed to
// be page aligned.) We then subtract p_vaddr, which takes us to virtual
// address zero.
symbol_offset
=
map_base_address
+
phdr
.
p_offset
-
phdr
.
p_vaddr
;
break
;
}
}
if
(
symbol_offset
==
0
)
return
false
;
}
ElfW
(
Shdr
)
symtab
,
strtab
;
...
...
@@ -782,7 +803,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
}
}
if
(
!
GetSymbolFromObjectFile
(
wrapped_object_fd
.
get
(),
pc0
,
out
,
out_size
,
start
_address
))
{
out
,
out_size
,
base
_address
))
{
return
false
;
}
...
...
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