llvm-6502/test/MC/AArch64/elf-reloc-movw.s
Rafael Espindola 7486d92a6c Change how we iterate over relocations on ELF.
For COFF and MachO, sections semantically have relocations that apply to them.
That is not the case on ELF.

In relocatable objects (.o), a section with relocations in ELF has offsets to
another section where the relocations should be applied.

In dynamic objects and executables, relocations don't have an offset, they have
a virtual address. The section sh_info may or may not point to another section,
but that is not actually used for resolving the relocations.

This patch exposes that in the ObjectFile API. It has the following advantages:

* Most (all?) clients can handle this more efficiently. They will normally walk
all relocations, so doing an effort to iterate in a particular order doesn't
save time.

* llvm-readobj now prints relocations in the same way the native readelf does.

* probably most important, relocations that don't point to any section are now
visible. This is the case of relocations in the rela.dyn section. See the
updated relocation-executable.test for example.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182908 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-30 03:05:14 +00:00

43 lines
1.6 KiB
ArmAsm

// RUN: llvm-mc -triple=aarch64-none-linux-gnu -filetype=obj %s -o - | \
// RUN: llvm-readobj -r | FileCheck -check-prefix=OBJ %s
movz x0, #:abs_g0:some_label
movk x0, #:abs_g0_nc:some_label
movz x3, #:abs_g1:some_label
movk x5, #:abs_g1_nc:some_label
movz x3, #:abs_g2:some_label
movk x5, #:abs_g2_nc:some_label
movz x7, #:abs_g3:some_label
movk x11, #:abs_g3:some_label
movz x13, #:abs_g0_s:some_label
movn x17, #:abs_g0_s:some_label
movz x19, #:abs_g1_s:some_label
movn x19, #:abs_g1_s:some_label
movz x19, #:abs_g2_s:some_label
movn x19, #:abs_g2_s:some_label
// OBJ: Relocations [
// OBJ-NEXT: Section (2) .rela.text {
// OBJ-NEXT: 0x0 R_AARCH64_MOVW_UABS_G0 some_label 0x0
// OBJ-NEXT: 0x4 R_AARCH64_MOVW_UABS_G0_NC some_label 0x0
// OBJ-NEXT: 0x8 R_AARCH64_MOVW_UABS_G1 some_label 0x0
// OBJ-NEXT: 0xC R_AARCH64_MOVW_UABS_G1_NC some_label 0x0
// OBJ-NEXT: 0x10 R_AARCH64_MOVW_UABS_G2 some_label 0x0
// OBJ-NEXT: 0x14 R_AARCH64_MOVW_UABS_G2_NC some_label 0x0
// OBJ-NEXT: 0x18 R_AARCH64_MOVW_UABS_G3 some_label 0x0
// OBJ-NEXT: 0x1C R_AARCH64_MOVW_UABS_G3 some_label 0x0
// OBJ-NEXT: 0x20 R_AARCH64_MOVW_SABS_G0 some_label 0x0
// OBJ-NEXT: 0x24 R_AARCH64_MOVW_SABS_G0 some_label 0x0
// OBJ-NEXT: 0x28 R_AARCH64_MOVW_SABS_G1 some_label 0x0
// OBJ-NEXT: 0x2C R_AARCH64_MOVW_SABS_G1 some_label 0x0
// OBJ-NEXT: 0x30 R_AARCH64_MOVW_SABS_G2 some_label 0x0
// OBJ-NEXT: 0x34 R_AARCH64_MOVW_SABS_G2 some_label 0x0
// OBJ-NEXT: }
// OBJ-NEXT: ]