[llvm] r206047 - Don't lose the thumb bit by using relocations with sections.
Rafael Espindola
rafael.espindola at gmail.com
Fri Apr 11 12:18:02 PDT 2014
Author: rafael
Date: Fri Apr 11 14:18:01 2014
New Revision: 206047
URL: http://llvm.org/viewvc/llvm-project?rev=206047&view=rev
Log:
Don't lose the thumb bit by using relocations with sections.
This fixes a regression from r205076.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=206047&r1=206046&r2=206047&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Apr 11 14:18:01 2014
@@ -813,6 +813,13 @@ bool ELFObjectWriter::shouldRelocateWith
if (Flags & ELF::SHF_TLS)
return true;
+ // If the symbol is a thumb function the final relocation must set the lowest
+ // bit. With a symbol that is done by just having the symbol have that bit
+ // set, so we would lose the bit if we relocated with the section.
+ // FIXME: We could use the section but add the bit to the relocation value.
+ if (SD->getFlags() & ELF_Other_ThumbFunc)
+ return true;
+
if (TargetObjectWriter->needsRelocateWithSymbol(Type))
return true;
return false;
Modified: llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.s?rev=206047&r1=206046&r2=206047&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.s (original)
+++ llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.s Fri Apr 11 14:18:01 2014
@@ -5,7 +5,6 @@
.syntax unified
.text
- .globl f
.align 2
.type f,%function
.code 16
@@ -16,9 +15,21 @@ f:
bl g
pop {r7, pc}
+ .section .data.rel.local,"aw",%progbits
+ptr:
+ .long f
+
+
@@ make sure an R_ARM_THM_CALL relocation is generated for the call to g
@CHECK: Relocations [
@CHECK-NEXT: Section (2) .rel.text {
@CHECK-NEXT: 0x4 R_ARM_THM_CALL g 0x0
@CHECK-NEXT: }
+
+
+@@ make sure the relocation is with f. That is one way to make sure it includes
+@@ the thumb bit.
+ at CHECK-NEXT: Section (6) .rel.data.rel.local {
+ at CHECK-NEXT: 0x0 R_ARM_ABS32 f 0x0
+ at CHECK-NEXT: }
@CHECK-NEXT: ]
More information about the llvm-commits
mailing list