llvm.org GIT mirror llvm / 0f9d1b3
ARM: when falling back to scattered relocs, keep the type. The linker relies on relocation type info (e.g. is it a branch?) to perform the correct actions, so we should keep that even when we end up using a scattered relocation for whatever reason. rdar://problem/17553104 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212333 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 5 years ago
2 changed file(s) with 41 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
3131 const MCFragment *Fragment,
3232 const MCFixup &Fixup,
3333 MCValue Target,
34 unsigned Type,
3435 unsigned Log2Size,
3536 uint64_t &FixedValue);
3637 void RecordARMScatteredHalfRelocation(MachObjectWriter *Writer,
250251 const MCFragment *Fragment,
251252 const MCFixup &Fixup,
252253 MCValue Target,
254 unsigned Type,
253255 unsigned Log2Size,
254256 uint64_t &FixedValue) {
255257 uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
256258 unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
257 unsigned Type = MachO::ARM_RELOC_VANILLA;
258259
259260 // See .
260261 const MCSymbol *A = &Target.getSymA()->getSymbol();
271272 uint32_t Value2 = 0;
272273
273274 if (const MCSymbolRefExpr *B = Target.getSymB()) {
275 assert(Type == MachO::ARM_RELOC_VANILLA && "invalid reloc for 2 symbols");
274276 const MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
275277
276278 if (!B_SD->getFragment())
373375 return RecordARMScatteredHalfRelocation(Writer, Asm, Layout, Fragment,
374376 Fixup, Target, FixedValue);
375377 return RecordARMScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup,
376 Target, Log2Size, FixedValue);
378 Target, RelocType, Log2Size,
379 FixedValue);
377380 }
378381
379382 // Get the symbol data, if any.
391394 Offset += 1 << Log2Size;
392395 if (Offset && SD && !Writer->doesSymbolRequireExternRelocation(SD))
393396 return RecordARMScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup,
394 Target, Log2Size, FixedValue);
397 Target, RelocType, Log2Size,
398 FixedValue);
395399
396400 // See .
397401 uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
0 @ RUN: llvm-mc -triple thumbv7-apple-ios7.0 -filetype=obj -o - %s | \
1 @ RUN: llvm-readobj -r - | FileCheck %s
2
3 @ MachO relocations that end up expressed as internal
4 @ (scattered) still need to have the type set correctly.
5
6 .text
7 .thumb_func
8 .thumb
9 .globl _with_thumb
10 _with_thumb:
11 bl _dest+10
12 blx _dest+20
13
14 .globl _with_arm
15 .arm
16 _with_arm:
17 bl _dest+10
18 blx _dest+20
19 bne _dest+30
20 b _dest+40
21
22 .data
23 _dest:
24 .word 42
25
26 @ CHECK: Relocations [
27 @ CHECK-NEXT: Section __text {
28 @ CHECK-NEXT: 0x14 1 2 n/a ARM_RELOC_BR24 1 0x18
29 @ CHECK-NEXT: 0x10 1 2 n/a ARM_RELOC_BR24 1 0x18
30 @ CHECK-NEXT: 0xC 1 2 n/a ARM_RELOC_BR24 1 0x18
31 @ CHECK-NEXT: 0x8 1 2 n/a ARM_RELOC_BR24 1 0x18
32 @ CHECK-NEXT: 0x4 1 2 n/a ARM_THUMB_RELOC_BR22 1 0x18
33 @ CHECK-NEXT: 0x0 1 2 n/a ARM_THUMB_RELOC_BR22 1 0x18