<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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);">
Sorry I wasn't clear. I am not talking about moving .nv_fatbin in its entirety. Although we are also doing it with linker script INSERT AFTER .bss.<br>
I was referring to re-arranging input sections within the .nv_fatbin output section.<br>
<br>
So, we have in .text*<br>
relocation into .nv_fatbin input section from foo3.o<br>
<br>
In output .nv_fatbin without any changes we will have<br>
foo1.o input section (some cuda code)<br>
foo2.o input section <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">(some cuda code)</span><br>
foo3.o input section (has relocation in to)<br>
<br>
With this layout we get relocation overflow.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
if we shuffle things<br>
foo3.o <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">(has relocation in to from .text*)</span><br>
foo1.o <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">(some cuda code)</span><br>
foo2.o <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">(some cuda code)<br>
</span><br>
It shortens the distance from src to dst fo relocation, and all other cuda sections can grow.<br>
<br>
Hopefully, this clarifies things.<br>
Alex<br>
<br>
<br>
<br>
<br>
</div>
<div id="appendonsend"></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size: 11pt;"><b>From:</b> Fangrui Song <maskray@google.com><br>
<b>Sent:</b> Wednesday, September 8, 2021 12:01 PM<br>
<b>To:</b> Alexander Yermolovich <ayermolo@fb.com><br>
<b>Cc:</b> llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> Re: [llvm-dev] [LLD] Relocation overflows and .nv_fatbin</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">On 2021-09-08, Alexander Yermolovich via llvm-dev wrote:<br>
>Hello<br>
><br>
>I am seeing relocation overflows from .text section in to .nv_fatbin. The whole thing, nv_fatbin, is a bit of a black box, but there does appear to be only one. We have a downstream patch in LLD, that moves .nv_fatbin section(s) that have relocations in to
 to the "top". Looking around at what's in .nv_fartbin the rest of the code should be bunch of cuda stuff. So, in theory that can grow, and we shouldn't get any more relocation overflows. At least due to the size of .nv_fatbin.<br>
><br>
>I was wondering if there is a better way of doing it. Maybe with a linker script? I investigated it, and that answer seems to be no, but I am not an expert in linker scripts.<br>
><br>
>Thank You<br>
>Alex<br>
<br>
I implemented INSERT [AFTER|BEFORE] for orphan sections in <a href="https://reviews.llvm.org/D74375">https://reviews.llvm.org/D74375</a>
<br>
You may consider moving .nv* and __nv* sections after .bss<br>
<br>
But linker synthesized etext/_etext may be in a weird position.<br>
To fix that, use the OVERWRITE_SECTIONS feature I added for LLD 13.0.0<br>
<br>
OVERWRITE_SECTIONS {<br>
   .tdata : { etext = .; _etext = .; *(.tdata) }<br>
}<br>
</div>
</span></font></div>
</body>
</html>