llvm.org GIT mirror llvm / 5e3c87e
ARM: add support for segment base relocations (SBREL) This adds support for parsing and emitting the SBREL relocation variant for the ARM target. Handling this relocation variant is necessary for supporting the full ARM ELF specification. Addresses PR22128. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225595 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 5 years ago
6 changed file(s) with 47 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
193193 VK_ARM_TARGET1,
194194 VK_ARM_TARGET2,
195195 VK_ARM_PREL31,
196 VK_ARM_SBREL, // symbol(sbrel)
196197 VK_ARM_TLSLDO, // symbol(tlsldo)
197198 VK_ARM_TLSCALL, // symbol(tlscall)
198199 VK_ARM_TLSDESC, // symbol(tlsdesc)
196196 case VK_ARM_TARGET1: return "target1";
197197 case VK_ARM_TARGET2: return "target2";
198198 case VK_ARM_PREL31: return "prel31";
199 case VK_ARM_SBREL: return "sbrel";
199200 case VK_ARM_TLSLDO: return "tlsldo";
200201 case VK_ARM_TLSCALL: return "tlscall";
201202 case VK_ARM_TLSDESC: return "tlsdesc";
363364 .Case("target1", VK_ARM_TARGET1)
364365 .Case("target2", VK_ARM_TARGET2)
365366 .Case("prel31", VK_ARM_PREL31)
367 .Case("sbrel", VK_ARM_SBREL)
366368 .Case("tlsldo", VK_ARM_TLSLDO)
367369 .Case("tlscall", VK_ARM_TLSCALL)
368370 .Case("tlsdesc", VK_ARM_TLSDESC)
199199 case MCSymbolRefExpr::VK_ARM_PREL31:
200200 Type = ELF::R_ARM_PREL31;
201201 break;
202 case MCSymbolRefExpr::VK_ARM_SBREL:
203 Type = ELF::R_ARM_SBREL32;
204 break;
202205 case MCSymbolRefExpr::VK_ARM_TLSLDO:
203206 Type = ELF::R_ARM_TLS_LDO32;
204207 break;
552552 /// necessary.
553553 void EmitValueImpl(const MCExpr *Value, unsigned Size,
554554 const SMLoc &Loc) override {
555 if (const MCSymbolRefExpr *SRE = dyn_cast_or_null(Value))
556 if (SRE->getKind() == MCSymbolRefExpr::VK_ARM_SBREL && !(Size == 4))
557 getContext().FatalError(Loc, "relocated expression must be 32-bit");
558
555559 EmitDataMappingSymbol();
556560 MCELFStreamer::EmitValueImpl(Value, Size);
557561 }
0 @ RUN: not llvm-mc -triple armv7-eabi -filetype obj -o - %s 2>&1 \
1 @ RUN: | FileCheck %s
2 @ RUN: not llvm-mc -triple thumbv7-eabi -filetype obj -o - %s 2>&1 \
3 @ RUN: | FileCheck %s
4
5 .byte target(sbrel)
6 @ CHECK: error: relocated expression must be 32-bit
7 @ CHECK: .byte target(sbrel)
8 @ CHECK: ^
9
10 @ TODO: enable these negative test cases
11 @ .hword target(sbrel)
12 @ @ CHECK-SBREL-HWORD: error: relocated expression must be 32-bit
13 @ @ CHECK-SBREL-HWORD: .hword target(sbrel)
14 @ @ CHECK-SBREL-HWORD: ^
15 @
16 @ .short target(sbrel)
17 @ @ CHECK-SBREL-SHORT: error: relocated expression must be 32-bit
18 @ @ CHECK-SBREL-SHORT: .short target(sbrel)
19 @ @ CHECK-SBREL-SHORT: ^
20 @
21 @ .quad target(sbrel)
22 @ @ CHECK-SBREL-SHORT: error: relocated expression must be 32-bit
23 @ @ CHECK-SBREL-SHORT: .quad target(sbrel)
24 @ @ CHECK-SBREL-SHORT: ^
25
26
2424 @ CHECK: 0x2 R_ARM_ABS16 abs16_1 0x0
2525 @ CHECK: }
2626
27 .section .text.r_arm_sbrel32
28
29 .word target(sbrel)
30 .word target(SBREL)
31
32 @ CHECK: Section {{.*}} .rel.text.r_arm_sbrel32 {
33 @ CHECK: 0x0 R_ARM_SBREL32 target 0x0
34 @ CHECK: 0x4 R_ARM_SBREL32 target 0x0
35 @ CHECK: }
36