1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/MC/ARM/symbol-variants.s
Peter Smith 5460a16070 [MC][ARM] Emit R_ARM_BASE_PREL for _GLOBAL_OFFSET_TABLE_ expressions
The _GLOBAL_OFFSET_TABLE_ in SysVr4 ELF is conventionally the base of the
.got or .got.prel sections. Expressions such as _GLOBAL_OFFSET_TABLE_
- (.L1 +8) are used in assembler code to calculate offsets into the .got.
At present MC outputs a R_ARM_REL32 with respect to the
_GLOBAL_OFFSET_TABLE_ symbol, whereas gas outputs a R_ARM_BASE_PREL
relocation with respect to the _GLOBAL_OFFSET_TABLE_ symbol. While both are
correct the R_ARM_REL32 depends on the value of the _GLOBAL_OFFSET_TABLE_
symbol, wheras te R_ARM_BASE_PREL relocation is idependent of the symbol.
The R_ARM_BASE_PREL is therefore slightly more robust to linker's that may
not follow the conventional placement of _GLOBAL_OFFSET_TABLE_; for example
LLD for some time defined _GLOBAL_OFFSET_TABLE_ to 0.

Differential Revision: https://reviews.llvm.org/D46319
2020-04-14 10:13:21 +01:00

112 lines
2.3 KiB
ArmAsm

@ RUN: llvm-mc < %s -triple armv7-none-linux-gnueabi -filetype=obj | llvm-objdump --triple=armv7-none-linux-gnueabi -r - | FileCheck %s --check-prefix=CHECK --check-prefix=ARM
@ RUN: llvm-mc < %s -triple thumbv7-none-linux-gnueabi -filetype=obj | llvm-objdump --triple=thumbv7-none-linux-gnueabi -r - | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB
@ CHECK-LABEL: RELOCATION RECORDS FOR [.text]
.Lsym:
@ empty
.word f00
.word f01
@CHECK: 0 R_ARM_ABS32 f00
@CHECK: 4 R_ARM_ABS32 f01
@ none
.word f02(NONE)
.word f03(none)
@CHECK: 8 R_ARM_NONE f02
@CHECK: c R_ARM_NONE f03
@ plt
bl f04(PLT)
bl f05(plt)
@ARM: 10 R_ARM_CALL f04
@ARM: 14 R_ARM_CALL f05
@THUMB: 10 R_ARM_THM_CALL f04
@THUMB: 14 R_ARM_THM_CALL f05
@ got
.word f06(GOT)
.word f07(got)
@CHECK: 18 R_ARM_GOT_BREL f06
@CHECK: 1c R_ARM_GOT_BREL f07
@ gotoff
.word f08(GOTOFF)
.word f09(gotoff)
@CHECK: 20 R_ARM_GOTOFF32 f08
@CHECK: 24 R_ARM_GOTOFF32 f09
@ tpoff
.word f10(TPOFF)
.word f11(tpoff)
@CHECK: 28 R_ARM_TLS_LE32 f10
@CHECK: 2c R_ARM_TLS_LE32 f11
@ tlsgd
.word f12(TLSGD)
.word f13(tlsgd)
@CHECK: 30 R_ARM_TLS_GD32 f12
@CHECK: 34 R_ARM_TLS_GD32 f13
@ target1
.word f14(TARGET1)
.word f15(target1)
@CHECK: 38 R_ARM_TARGET1 f14
@CHECK: 3c R_ARM_TARGET1 f15
@ target2
.word f16(TARGET2)
.word f17(target2)
@CHECK: 40 R_ARM_TARGET2 f16
@CHECK: 44 R_ARM_TARGET2 f17
@ prel31
.word f18(PREL31)
.word f19(prel31)
@CHECK: 48 R_ARM_PREL31 f18
@CHECK: 4c R_ARM_PREL31 f19
@ tlsldo
.word f20(TLSLDO)
.word f21(tlsldo)
@CHECK: 50 R_ARM_TLS_LDO32 f20
@CHECK: 54 R_ARM_TLS_LDO32 f21
@ tlscall
.word f22(TLSCALL)
.word f23(tlscall)
@ CHECK: 58 R_ARM_TLS_CALL f22
@ CHECK: 5c R_ARM_TLS_CALL f23
@ tlsdesc
.word f24(TLSDESC)
.word f25(tlsdesc)
@ CHECK: 60 R_ARM_TLS_GOTDESC f24
@ CHECK: 64 R_ARM_TLS_GOTDESC f25
@ prel31 (relative)
.word f26(PREL31)-.
.word f27(prel31)-.
@CHECK: 68 R_ARM_PREL31 f26
@CHECK: 6c R_ARM_PREL31 f27
@ tlsldm
.word f28(TLSLDM)
.word f29(tlsldm)
@CHECK: 70 R_ARM_TLS_LDM32 f28
@CHECK: 74 R_ARM_TLS_LDM32 f29
@ relative
.word f30 - (.Lsym+8)
@CHECK: 78 R_ARM_REL32 f30
@ _GLOBAL_OFFSET_TABLE_ relative
.word _GLOBAL_OFFSET_TABLE_ - (.Lsym+8)
@CHECK: 7c R_ARM_BASE_PREL _GLOBAL_OFFSET_TABLE_
@ got_prel
.word f31(GOT_PREL) + (. - .Lsym)
ldr r3, =f32(GOT_PREL)
@CHECK: 80 R_ARM_GOT_PREL f31
@CHECK: 88 R_ARM_GOT_PREL f32