1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[MC][ARM] Support .reloc *, BFD_RELOC_{NONE,8,16,32}, *

BFD_RELOC_NONE is useful for ld --gc-sections: it provides a generic way indicating a dependency between two sections.
This commit is contained in:
Fangrui Song 2021-03-05 21:39:15 -08:00
parent b781b17cdc
commit 6bc3220cd9
2 changed files with 17 additions and 0 deletions

View File

@ -55,6 +55,10 @@ Optional<MCFixupKind> ARMAsmBackend::getFixupKind(StringRef Name) const {
#define ELF_RELOC(X, Y) .Case(#X, Y)
#include "llvm/BinaryFormat/ELFRelocs/ARM.def"
#undef ELF_RELOC
.Case("BFD_RELOC_NONE", ELF::R_ARM_NONE)
.Case("BFD_RELOC_8", ELF::R_ARM_ABS8)
.Case("BFD_RELOC_16", ELF::R_ARM_ABS16)
.Case("BFD_RELOC_32", ELF::R_ARM_ABS32)
.Default(-1u);
if (Type == -1u)
return None;

View File

@ -21,6 +21,11 @@
.reloc 0, R_ARM_LDR_PC_G0, foo+3
.reloc 0, R_ARM_THM_ALU_PREL_11_0, 5
.reloc 0, BFD_RELOC_NONE, 9
.reloc 0, BFD_RELOC_8, 9
.reloc 0, BFD_RELOC_16, 9
.reloc 0, BFD_RELOC_32, 9
.data
.globl foo
foo:
@ -34,6 +39,10 @@ foo:
# PRINT: .reloc 0, R_ARM_ALU_PC_G0, .data+2
# PRINT: .reloc 0, R_ARM_LDR_PC_G0, foo+3
# PRINT: .reloc 0, R_ARM_THM_ALU_PREL_11_0, 5
# PRINT: .reloc 0, BFD_RELOC_NONE, 9
# PRINT-NEXT: .reloc 0, BFD_RELOC_8, 9
# PRINT-NEXT: .reloc 0, BFD_RELOC_16, 9
# PRINT-NEXT: .reloc 0, BFD_RELOC_32, 9
# ARM relocations use the Elf32_Rel format. Addends are neither stored in the
# relocation entries nor applied in the referenced locations.
@ -43,5 +52,9 @@ foo:
# CHECK-NEXT: 0x0 R_ARM_ALU_PC_G0 .data
# CHECK-NEXT: 0x0 R_ARM_LDR_PC_G0 foo
# CHECK-NEXT: 0x0 R_ARM_THM_ALU_PREL_11_0 -
# CHECK-NEXT: 0x0 R_ARM_NONE -
# CHECK-NEXT: 0x0 R_ARM_ABS8 -
# CHECK-NEXT: 0x0 R_ARM_ABS16 -
# CHECK-NEXT: 0x0 R_ARM_ABS32 -
# HEX: 0x00000000 00000000 00000000