[lld] r349216 - ELF: Handle R_ARM_V4BX correctly in PIC output files.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 14 16:20:17 PST 2018
Author: pcc
Date: Fri Dec 14 16:20:17 2018
New Revision: 349216
URL: http://llvm.org/viewvc/llvm-project?rev=349216&view=rev
Log:
ELF: Handle R_ARM_V4BX correctly in PIC output files.
Previously we considered R_ARM_V4BX to be an absolute relocation,
which meant that we rejected it in read-only sections in PIC output
files. Instead, treat it as a hint relocation so that relocation
processing ignores it entirely.
Also fix a problem with the test case where it was never being run
because it has a .yaml extension and we don't run tests with that
extension.
Differential Revision: https://reviews.llvm.org/D55728
Added:
lld/trunk/test/ELF/arm-v4bx.test
Removed:
lld/trunk/test/ELF/v4bx.yaml
Modified:
lld/trunk/ELF/Arch/ARM.cpp
Modified: lld/trunk/ELF/Arch/ARM.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/ARM.cpp?rev=349216&r1=349215&r2=349216&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/ARM.cpp (original)
+++ lld/trunk/ELF/Arch/ARM.cpp Fri Dec 14 16:20:17 2018
@@ -134,6 +134,12 @@ RelExpr ARM::getRelExpr(RelType Type, co
return R_NONE;
case R_ARM_TLS_LE32:
return R_TLS;
+ case R_ARM_V4BX:
+ // V4BX is just a marker to indicate there's a "bx rN" instruction at the
+ // given address. It can be used to implement a special linker mode which
+ // rewrites ARMv4T inputs to ARMv4. Since we support only ARMv4 input and
+ // not ARMv4 output, we can just ignore it.
+ return R_HINT;
default:
return R_ABS;
}
@@ -514,12 +520,6 @@ void ARM::relocateOne(uint8_t *Loc, RelT
((Val << 4) & 0x7000) | // imm3
(Val & 0x00ff)); // imm8
break;
- case R_ARM_V4BX:
- // V4BX is just a marker to indicate there's a "bx rN" instruction at the
- // given address. It can be used to implement a special linker mode which
- // rewrites ARMv4T inputs to ARMv4. Since we support only ARMv4 input and
- // not ARMv4 output, we can just ignore it.
- break;
default:
error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
}
Added: lld/trunk/test/ELF/arm-v4bx.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-v4bx.test?rev=349216&view=auto
==============================================================================
--- lld/trunk/test/ELF/arm-v4bx.test (added)
+++ lld/trunk/test/ELF/arm-v4bx.test Fri Dec 14 16:20:17 2018
@@ -0,0 +1,40 @@
+# REQUIRES: arm
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-readelf -sections %t | FileCheck %s
+# RUN: ld.lld -shared %t.o -o %t
+# RUN: llvm-readelf -sections %t | FileCheck %s
+
+# CHECK: .text
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_ARM
+ Flags: [ EF_ARM_EABI_VER5 ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000004
+ Content: 1EFF2F01
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ AddressAlign: 0x0000000000000004
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000000
+ Symbol: ''
+ Type: R_ARM_V4BX
+Symbols:
+ Global:
+ - Name: _start
+ Section: .text
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+DynamicSymbols:
Removed: lld/trunk/test/ELF/v4bx.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/v4bx.yaml?rev=349215&view=auto
==============================================================================
--- lld/trunk/test/ELF/v4bx.yaml (original)
+++ lld/trunk/test/ELF/v4bx.yaml (removed)
@@ -1,38 +0,0 @@
-# REQUIRES: arm
-# RUN: yaml2obj %s -o %t.o
-# RUN: ld.lld %t.o -o %t
-# RUN: llvm-readelf -sections %t | FileCheck %s
-
-# CHECK: .text
-
---- !ELF
-FileHeader:
- Class: ELFCLASS32
- Data: ELFDATA2LSB
- Type: ET_REL
- Machine: EM_ARM
- Flags: [ EF_ARM_EABI_VER5 ]
-Sections:
- - Name: .text
- Type: SHT_PROGBITS
- Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
- AddressAlign: 0x0000000000000004
- Content: 1EFF2F01
- - Name: .rel.text
- Type: SHT_REL
- Link: .symtab
- AddressAlign: 0x0000000000000004
- Info: .text
- Relocations:
- - Offset: 0x0000000000000000
- Symbol: ''
- Type: R_ARM_V4BX
-Symbols:
- Global:
- - Name: _start
- Section: .text
- Local:
- - Name: .text
- Type: STT_SECTION
- Section: .text
-DynamicSymbols:
More information about the llvm-commits
mailing list