aboutcode-org / aboutcode-org/elf-inspector

Ignore "fake" symbols

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

These are builtin and related:
This is a small function worked out in go-inspector:
```Python
def is_fake_path(path):
"""
Return True if a ``path`` string is for a fake path injected by the linker or compiler in the binary.
See:
https://github.com/smoofra/elfutils/blob/53b6f190892c738f28840e7481a09c7ee19b6720/src/srcfiles.cxx#L160

For example:
>>> is_fake_symbol("")
True
>>> is_fake_symbol("foo/bar/")
True
>>> is_fake_symbol("")
True
>>> is_fake_symbol("/artificial/asdasdas/adsd")
False
>>> is_fake_symbol("")
False
>>> is_fake_symbol("/sdfsdfsdf/zffd")
Trye

"""
fake_paths = (
#gcc intrinsics
"", "",
# seen in Go and C++
"",
"",
)
return isinstance(path, str) and any(fs in path for fs in fake_paths)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.