Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
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
bcc
Commits
37633800
Commit
37633800
authored
Jan 12, 2018
by
4ast
Committed by
GitHub
Jan 12, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1529 from iovisor/yhs_dev
usdt: ignore location with incorrect probe virtual address
parents
19c84593
bf2a8111
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
4 deletions
+27
-4
src/cc/bcc_elf.c
src/cc/bcc_elf.c
+27
-4
No files found.
src/cc/bcc_elf.c
View file @
37633800
...
...
@@ -85,7 +85,7 @@ static const char *parse_stapsdt_note(struct bcc_elf_usdt *probe,
static
int
do_note_segment
(
Elf_Scn
*
section
,
int
elf_class
,
bcc_elf_probecb
callback
,
const
char
*
binpath
,
void
*
payload
)
{
uint64_t
first_inst_offset
,
void
*
payload
)
{
Elf_Data
*
data
=
NULL
;
while
((
data
=
elf_getdata
(
section
,
data
))
!=
0
)
{
...
...
@@ -110,8 +110,14 @@ static int do_note_segment(Elf_Scn *section, int elf_class,
desc
=
(
const
char
*
)
data
->
d_buf
+
desc_off
;
desc_end
=
desc
+
hdr
.
n_descsz
;
if
(
parse_stapsdt_note
(
&
probe
,
desc
,
elf_class
)
==
desc_end
)
callback
(
binpath
,
&
probe
,
payload
);
if
(
parse_stapsdt_note
(
&
probe
,
desc
,
elf_class
)
==
desc_end
)
{
if
(
probe
.
pc
<
first_inst_offset
)
fprintf
(
stderr
,
"WARNING: invalid address 0x%lx for probe (%s,%s) in binary %s
\n
"
,
probe
.
pc
,
probe
.
provider
,
probe
.
name
,
binpath
);
else
callback
(
binpath
,
&
probe
,
payload
);
}
}
}
return
0
;
...
...
@@ -122,10 +128,26 @@ static int listprobes(Elf *e, bcc_elf_probecb callback, const char *binpath,
Elf_Scn
*
section
=
NULL
;
size_t
stridx
;
int
elf_class
=
gelf_getclass
(
e
);
uint64_t
first_inst_offset
=
0
;
if
(
elf_getshdrstrndx
(
e
,
&
stridx
)
!=
0
)
return
-
1
;
// Get the offset to the first instruction
while
((
section
=
elf_nextscn
(
e
,
section
))
!=
0
)
{
GElf_Shdr
header
;
if
(
!
gelf_getshdr
(
section
,
&
header
))
continue
;
// The elf file section layout is based on increasing virtual address,
// getting the first section with SHF_EXECINSTR is enough.
if
(
header
.
sh_flags
&
SHF_EXECINSTR
)
{
first_inst_offset
=
header
.
sh_addr
;
break
;
}
}
while
((
section
=
elf_nextscn
(
e
,
section
))
!=
0
)
{
GElf_Shdr
header
;
char
*
name
;
...
...
@@ -138,7 +160,8 @@ static int listprobes(Elf *e, bcc_elf_probecb callback, const char *binpath,
name
=
elf_strptr
(
e
,
stridx
,
header
.
sh_name
);
if
(
name
&&
!
strcmp
(
name
,
".note.stapsdt"
))
{
if
(
do_note_segment
(
section
,
elf_class
,
callback
,
binpath
,
payload
)
<
0
)
if
(
do_note_segment
(
section
,
elf_class
,
callback
,
binpath
,
first_inst_offset
,
payload
)
<
0
)
return
-
1
;
}
}
...
...
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