[llvm-dev] [RFC] Changing .llvm.call-graph-profile to use relocations

Alexander Yermolovich via llvm-dev llvm-dev at lists.llvm.org
Wed May 26 16:26:32 PDT 2021


Currently when .llvm.call-graph-profile is created by llvm it explicitly encodes the symbol indices. This section is basically a black box for post processing tools. For example, if we run strip -s on the object files the symbol table changes, but indices in that section do not.

We propose to change this section to use relocations. The Frequency will still be in the .llvm.call-graph-profile, but symbol information will be in relocation section. In LLD information from both sections is used to reconstruct call graph profile. Relocations themselves will never be applied.

With this approach post processing tools that handle relocations correctly work for this section also.

One thing is section is marked with SHF_EXCLUDE.
>From spec
"This section is excluded from input to the link-edit of an executable or shared object. This flag is ignored if the SHF_ALLOC flag is also set, or if relocations exist against the section."

So technically speaking it needs to be kept, and presumably relocations applied, but LLD follows gold and ld and discards sections marked as SHF_EXCLUDE even with relocations. So, I think this approach should be fine. https://reviews.llvm.org/D24966

Finally, this bug seems similar to https://sourceware.org/bugzilla/show_bug.cgi?id=23817. Proposed solution for that was also to use relocations.

Implementation: https://reviews.llvm.org/D103212
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210526/d7824ccf/attachment.html>


More information about the llvm-dev mailing list