[PATCH] D48929: [ELF] Update addends in non-allocatable sections for REL targets when creating a relocatable output.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 11 05:05:42 PDT 2018


ikudrin added inline comments.


================
Comment at: ELF/InputSection.cpp:744
+    Target->relocateOne(BufLoc, Rel.Type, TargetVA);
+  }
+}
----------------
grimar wrote:
> Maybe I would make it even shorter:
> 
> ```
>   const unsigned Bits = Config->Is64 ? 64 : 32;
>   for (const Relocation &Rel : Sec->Relocations) {
>     assert(Rel.Expr == R_ABS);
>     Target->relocateOne(Buf + Rel.Offset + Sec->OutSecOff, Rel.Type,
>                         SignExtend64(Rel.Sym->getVA(Rel.Addend), Bits));
>   }
> ```
Thanks for the suggestion, but I prefer to stay with the original version. I believe that the shortened variant is more complicated while giving distinct names to different things improves readability.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D48929





More information about the llvm-commits mailing list