Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Caren Kresse
callgraph
Commits
309927e5
Commit
309927e5
authored
May 13, 2021
by
Carsten Emde
Browse files
Renamed 'skipfile' to 'notarget' in order to avoid confusion with
'skipdirs'
parent
7cf0624e
Changes
1
Hide whitespace changes
Inline
Side-by-side
generatecypher.py
View file @
309927e5
...
...
@@ -52,7 +52,7 @@ import elftools.elf.elffile
import
elftools.elf.dynamic
import
elftools.elf.sections
def
skipfile
(
filename
,
limitsearch
):
def
notarget
(
filename
,
limitsearch
):
if
limitsearch
is
None
:
return
False
filefound
=
False
...
...
@@ -161,7 +161,7 @@ def createoutput(outputdir, outputformat, machine_to_binary, linked_libraries,
# first add all the ELF files as nodes to the graph
if
outputformat
!=
'text'
:
for
filename
in
machine_to_binary
[
architecture
][
o
][
endian
][
elfclass
]:
if
skipfile
(
filename
,
limitsearch
):
if
notarget
(
filename
,
limitsearch
):
continue
if
seenfirst
:
outputfileopen
.
write
(
newline
)
...
...
@@ -184,7 +184,7 @@ def createoutput(outputdir, outputformat, machine_to_binary, linked_libraries,
# then add all the links
for
filename
in
machine_to_binary
[
architecture
][
o
][
endian
][
elfclass
]:
if
skipfile
(
filename
,
limitsearch
):
if
notarget
(
filename
,
limitsearch
):
continue
if
linked_libraries
[
filename
]
!=
[]:
# record the dependencies that are linked with
...
...
@@ -219,6 +219,8 @@ def createoutput(outputdir, outputformat, machine_to_binary, linked_libraries,
if
fl
not
in
linked_from
:
linked_from
[
fl
]
=
set
()
linked_from
[
fl
].
add
(
filename
)
if
notarget
(
fl
,
limitsearch
):
print
(
"Warning: Found linked library '%s', but it was skipped"
%
(
fl
))
if
outputformat
==
'gexf'
:
outputfileopen
.
write
(
"
\n
</edges>"
)
...
...
@@ -230,7 +232,7 @@ def createoutput(outputdir, outputformat, machine_to_binary, linked_libraries,
tmpexportsymbols
=
set
()
for
filename
in
machine_to_binary
[
architecture
][
o
][
endian
][
elfclass
]:
if
skipfile
(
filename
,
limitsearch
):
if
notarget
(
filename
,
limitsearch
):
continue
for
exp
in
elf_to_exported_symbols
[
filename
]:
# remove a few symbols that are not needed
...
...
@@ -263,7 +265,7 @@ def createoutput(outputdir, outputformat, machine_to_binary, linked_libraries,
# then declare for all the symbols which are exported
for
filename
in
machine_to_binary
[
architecture
][
o
][
endian
][
elfclass
]:
if
skipfile
(
filename
,
limitsearch
):
if
notarget
(
filename
,
limitsearch
):
continue
exportedsymbols
=
0
for
exp
in
elf_to_exported_symbols
[
filename
]:
...
...
@@ -276,7 +278,7 @@ def createoutput(outputdir, outputformat, machine_to_binary, linked_libraries,
continue
symbolinuse
=
False
for
otherfilename
in
machine_to_binary
[
architecture
][
o
][
endian
][
elfclass
]:
if
otherfilename
==
filename
or
skipfile
(
otherfilename
,
limitsearch
):
if
otherfilename
==
filename
or
notarget
(
otherfilename
,
limitsearch
):
continue
for
imp
in
elf_to_imported_symbols
[
otherfilename
]:
if
imp
[
'bind'
]
!=
'LOCAL'
and
imp
[
'bind'
]
!=
'WEAK'
and
exp
[
'name'
]
==
imp
[
'name'
]:
...
...
@@ -293,7 +295,7 @@ def createoutput(outputdir, outputformat, machine_to_binary, linked_libraries,
files_without_exports
.
add
(
filename
)
for
l
in
linked_libraries
[
filename
]:
for
otherfilename
in
machine_to_binary
[
architecture
][
o
][
endian
][
elfclass
]:
if
otherfilename
==
filename
or
skipfile
(
otherfilename
,
limitsearch
)
or
otherfilename
in
targets
:
if
otherfilename
==
filename
or
notarget
(
otherfilename
,
limitsearch
)
or
otherfilename
in
targets
:
continue
if
filename
in
linked_from
[
otherfilename
]
and
len
(
linked_from
[
otherfilename
])
==
1
:
if
otherfilename
not
in
files_without_exports
:
...
...
@@ -304,7 +306,7 @@ def createoutput(outputdir, outputformat, machine_to_binary, linked_libraries,
# store which files use which symbols
for
filename
in
machine_to_binary
[
architecture
][
o
][
endian
][
elfclass
]:
if
skipfile
(
filename
,
limitsearch
):
if
notarget
(
filename
,
limitsearch
):
continue
for
imp
in
elf_to_imported_symbols
[
filename
]:
if
imp
[
'bind'
]
==
'LOCAL'
:
...
...
@@ -460,8 +462,11 @@ def main(argv):
skipdirs
=
defaultskipdirs
else
:
skipdirs
+=
','
+
defaultskipdirs
skipdirs
=
skipdirs
.
split
(
","
)
skipdirs
=
skipdirs
.
split
(
','
)
print
(
"Info: Skipping directories %s"
%
(
skipdirs
))
for
s
in
skipdirs
:
if
not
s
.
endswith
(
'/'
):
skipdirs
[
skipdirs
.
index
(
s
)]
+=
'/'
for
dirtoscan
in
dirstoscan
:
# store the length of the top level directory, as everything
...
...
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