<div dir="ltr">We are refactoring the relocation generation code, but currently Writer::scanReloc adds relocation entries for the dynamic relocations. If "Out<ELFT>::RelaDyn->addReloc({&C, &RI});" is not called for your relocation, then no dynamic relocation will be created for that.<div><br></div><div>What do you currently get? You didn't see any dynamic relocations for R_AACH_ABS64 relocs, do you?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 3, 2016 at 5:50 AM, Adhemerval Zanella via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
Working on lld aarch64 support I came across an issue where I am not sure which<br>
would be best design approach to solve.<br>
<br>
The aarch64 R_AARCH64_ABS64 relocation for PIC/PIE build requires a dynamic<br>
relocation (R_AARCH64_RELATIVE) with the value set as the addend of the<br>
relocation. For instance, when linking the crtbeginS.o which contains:<br>
<br>
Relocation section '.rela.init_array' at offset 0xd28 contains 1 entries:<br>
Offset Info Type Sym. Value Sym. Name + Addend<br>
000000000000 000200000101 R_AARCH64_ABS64 0000000000000000 .text + d4<br>
<br>
The resulting dynamic relocation on the shared object should be:<br>
<br>
Relocation section '.rela.dyn' at offset 0x548 contains 10 entries:<br>
Offset Info Type Sym. Value Sym. Name + Addend<br>
000000010dc0 000000000403 R_AARCH64_RELATIV 7a8<br>
<br>
Where 0x7a8 (dynamic relocation r_addend) points to a function at<br>
.text segment (in this case frame_dummy).<br>
<br>
I am trying to made this on lld, but current step sequence is:<br>
<br>
- Write::run<br>
\_ Write::createSections<br>
\_ Write::scanRelocs<br>
\_ Write::addReloc // Dynamic Relocation creation<br>
\_ Write::writeSections<br>
\_ OutputSectionBase::writeTo<br>
\_ InputSection::writeTo<br>
\_ InputSection::relocate<br>
\_ TargetInfo::relocateOne<br>
<br>
The problem is only at TargetInfo::relocate the target (aarch64) will see<br>
that the relocation is a R_AARCH64_ABS64 one and thus will need to create<br>
a dynamic R_AARCH64_RELATIVE relocation.<br>
<br>
Also from comments at ELF/Writer.cpp:243 I noted that scanRelocs is done<br>
early as a design choice. So I am not sure if it would be best to follow<br>
the second idea of the comment (and do the scan later *after* the relocations<br>
is computed) or if it would be better to allow the TargetInfo add a scan<br>
phase to handle such things (as other linker does).<br>
<br>
Suggestions, tips, advices?<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>