<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thank you for feedback, let me try to use <span style="color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important;">R_X86_64_NONE,
 and introduce another type. . I thought <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">R_X86_64_32 would be less impactful as structure of is preserved, but it is space wasteful. <br>
For type name: <span style="font-family: "Helvetica Neue"; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal;">ELF::SHT_LLVM_CALL_GRAPH_PROFILE_RELA ?</span></span></span></div>
<div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;"><font face="Helvetica Neue"><span style="font-size: 13px;"><br>
</span></font><span style="font-size: 14.6667px;">Alex</span></span></span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> maskray@google.com <maskray@google.com><br>
<b>Sent:</b> Wednesday, May 26, 2021 5:03 PM<br>
<b>To:</b> Alexander Yermolovich <ayermolo@fb.com><br>
<b>Cc:</b> llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org>; Wenlei He <wenlei@fb.com>; Modi Mo <modimo@fb.com>; dblaikie@gmail.com <dblaikie@gmail.com><br>
<b>Subject:</b> Re: [RFC] Changing .llvm.call-graph-profile to use relocations</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 2021-05-26, Alexander Yermolovich wrote:<br>
>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.<br>
><br>
>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.<br>
<br>
Yes, a relocation based approach will be more robust and can fix the<br>
.llvm_addrsig issue <a href="https://sourceware.org/bugzilla/show_bug.cgi?id=23817">https://sourceware.org/bugzilla/show_bug.cgi?id=23817</a>
<br>
<br>
The relocation type doesn't matter. Your implementation uses R_X86_64_32 and from/to/value/from/to/value/from/to/value<br>
An alternative design is R_X86_64_NONE + value/value/value, i.e. from/to do not occupy space in the content.<br>
We will get a 3x space saving.<br>
<br>
We need to change the section type since changing representation is incompatible<br>
and the sections from old object files should be ignored.<br>
The new section type will be ignored by old LLVM tools as well.<br>
<br>
>With this approach post processing tools that handle relocations correctly work for this section also.<br>
><br>
>One thing is section is marked with SHF_EXCLUDE.<br>
>From spec<br>
>"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."<br>
><br>
>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.
<a href="https://reviews.llvm.org/D24966">https://reviews.llvm.org/D24966</a>
<br>
<br>
This is Solaris's spec (since 1996), not standard ELF's.  It can be advisory but<br>
our behavior (mostly GNU ABI+Linux ABI+LLVM extensions) does not necessarily<br>
follow it.  I cannot find a definition in the x86-64 psABI or a GNU ABI<br>
document.<br>
<br>
I think the behavior as implemented in gold and LLD is more useful.<br>
<br>
>Finally, this bug seems similar to <a href="https://sourceware.org/bugzilla/show_bug.cgi?id=23817">https://sourceware.org/bugzilla/show_bug.cgi?id=23817</a> . Proposed solution for that was also to use relocations.<br>
><br>
>Implementation: <a href="https://reviews.llvm.org/D103212">https://reviews.llvm.org/D103212</a>
<br>
</div>
</span></font></div>
</body>
</html>