[PATCH] D31659: [LLD][ELF] Be more precise about Thumb state bit in ARM thunks

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 04:06:24 PDT 2017


peter.smith created this revision.
Herald added subscribers: rengolin, aemerson.

When we are able to reuse a Thumb thunk from ARM and vice versa the thumb state bit needs to be set to make sure that the bl is converted to a blx.


https://reviews.llvm.org/D31659

Files:
  ELF/Thunks.cpp


Index: ELF/Thunks.cpp
===================================================================
--- ELF/Thunks.cpp
+++ ELF/Thunks.cpp
@@ -157,7 +157,7 @@
 void ThumbV7ABSLongThunk<ELFT>::addSymbols(ThunkSection &IS) {
   this->ThunkSym = addSyntheticLocal<ELFT>(
       Saver.save("__Thumbv7ABSLongThunk_" + this->Destination.getName()),
-      STT_FUNC, this->Offset, size(), &IS);
+      STT_FUNC, this->Offset | 1, size(), &IS);
   addSyntheticLocal<ELFT>("$t", STT_NOTYPE, this->Offset, 0, &IS);
 }
 
@@ -206,7 +206,7 @@
       0x60, 0x47,             //     bx   r12
   };
   uint64_t S = getARMThunkDestVA(this->Destination);
-  uint64_t P = this->ThunkSym->getVA();
+  uint64_t P = this->ThunkSym->getVA() & ~0x1;
   memcpy(Buf, Data, sizeof(Data));
   Target->relocateOne(Buf, R_ARM_THM_MOVW_PREL_NC, S - P - 12);
   Target->relocateOne(Buf + 4, R_ARM_THM_MOVT_PREL, S - P - 8);
@@ -216,7 +216,7 @@
 void ThumbV7PILongThunk<ELFT>::addSymbols(ThunkSection &IS) {
   this->ThunkSym = addSyntheticLocal<ELFT>(
       Saver.save("__ThumbV7PILongThunk_" + this->Destination.getName()),
-      STT_FUNC, this->Offset, size(), &IS);
+      STT_FUNC, this->Offset | 1, size(), &IS);
   addSyntheticLocal<ELFT>("$t", STT_NOTYPE, this->Offset, 0, &IS);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31659.94038.patch
Type: text/x-patch
Size: 1250 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170404/a1659a07/attachment.bin>


More information about the llvm-commits mailing list