KEMBAR78
Detect and parse the loader in parseLibraries. by krk · Pull Request #1263 · async-profiler/async-profiler · GitHub
Skip to content

Conversation

@krk
Copy link
Contributor

@krk krk commented Apr 24, 2025

Use AT_BASE from auxv to get loader base address and parse it regardless of dlopen/dlerror results.

Related issues

#1250

Motivation and context

The loader itself cannot be unloaded, so what dlopen/dlerror returns is not relevant. This simplifies and corrects the condition of calling parseProgramHeaders.

How has this been tested?

make test


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Use AT_BASE from auxv to get loader base address and parse it regardless
of dlopen/dlerror results.
@krk
Copy link
Contributor Author

krk commented Apr 24, 2025

std::unordered_map<u64, SharedLibrary> libs;
collectSharedLibraries(libs, MAX_NATIVE_LIBS - array->count());

const char* ld_base = (const char*)getauxval(AT_BASE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! TIL

Signed-off-by: Andrei Pangin <1749416+apangin@users.noreply.github.com>
@apangin apangin merged commit fdaf195 into async-profiler:master Apr 24, 2025
10 checks passed
krk added a commit to krk/async-profiler that referenced this pull request Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants