[PATCH] D61629: [ELF] Try placing newly created ThunkSection at the end of the InputSection first

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 01:06:34 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: ruiu, peter.smith, sfertile.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

Inspired by PR40740.

It increases the probability that the thunk section can be shared by a
subsequent InputSection, thus potentially decreases the total number of
thunk sections.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D61629

Files:
  ELF/Relocations.cpp


Index: ELF/Relocations.cpp
===================================================================
--- ELF/Relocations.cpp
+++ ELF/Relocations.cpp
@@ -1455,9 +1455,9 @@
   // many Thunks. Create a new ThunkSection as close to the InputSection as
   // possible. Error if InputSection is so large we cannot place ThunkSection
   // anywhere in Range.
-  uint64_t ThunkSecOff = IS->OutSecOff;
+  uint64_t ThunkSecOff = IS->OutSecOff + IS->getSize();
   if (!Target->inBranchRange(Type, Src, OS->Addr + ThunkSecOff)) {
-    ThunkSecOff = IS->OutSecOff + IS->getSize();
+    ThunkSecOff = IS->OutSecOff;
     if (!Target->inBranchRange(Type, Src, OS->Addr + ThunkSecOff))
       fatal("InputSection too large for range extension thunk " +
             IS->getObjMsg(Src - (OS->Addr + IS->OutSecOff)));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61629.198406.patch
Type: text/x-patch
Size: 794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190507/c135b5ed/attachment.bin>


More information about the llvm-commits mailing list