mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
7486d92a6c
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
63 lines
1.9 KiB
LLVM
63 lines
1.9 KiB
LLVM
;; RUN: llc -mtriple=aarch64-none-linux-gnu -filetype=obj %s -o - | \
|
|
;; RUN: llvm-readobj -h -r | FileCheck -check-prefix=OBJ %s
|
|
|
|
; Also take it on a round-trip through llvm-mc to stretch assembly-parsing's legs:
|
|
;; RUN: llc -mtriple=aarch64-none-linux-gnu %s -o - | \
|
|
;; RUN: llvm-mc -triple=aarch64-none-linux-gnu -filetype=obj -o - | \
|
|
;; RUN: llvm-readobj -h -r | FileCheck -check-prefix=OBJ %s
|
|
|
|
@var8 = global i8 0
|
|
@var16 = global i16 0
|
|
@var32 = global i32 0
|
|
@var64 = global i64 0
|
|
|
|
define void @loadstore() {
|
|
%val8 = load i8* @var8
|
|
store volatile i8 %val8, i8* @var8
|
|
|
|
%val16 = load i16* @var16
|
|
store volatile i16 %val16, i16* @var16
|
|
|
|
%val32 = load i32* @var32
|
|
store volatile i32 %val32, i32* @var32
|
|
|
|
%val64 = load i64* @var64
|
|
store volatile i64 %val64, i64* @var64
|
|
|
|
ret void
|
|
}
|
|
|
|
@globaddr = global i64* null
|
|
|
|
define void @address() {
|
|
store i64* @var64, i64** @globaddr
|
|
ret void
|
|
}
|
|
|
|
; Check we're using EM_AARCH64
|
|
; OBJ: ElfHeader {
|
|
; OBJ: Machine: EM_AARCH64
|
|
; OBJ: }
|
|
|
|
; OBJ: Relocations [
|
|
; OBJ: Section (2) .rela.text {
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_ADR_PREL_PG_HI21 var8
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_LDST8_ABS_LO12_NC var8
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_ADR_PREL_PG_HI21 var16
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_LDST16_ABS_LO12_NC var16
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_ADR_PREL_PG_HI21 var32
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_LDST32_ABS_LO12_NC var32
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_ADR_PREL_PG_HI21 var64
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_LDST64_ABS_LO12_NC var64
|
|
|
|
; This is on the store, so not really important, but it stops the next
|
|
; match working.
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_LDST64_ABS_LO12_NC var64
|
|
|
|
; Pure address-calculation against var64
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_ADR_PREL_PG_HI21 var64
|
|
; OBJ: 0x{{[0-9,A-F]+}} R_AARCH64_ADD_ABS_LO12_NC var64
|
|
|
|
; OBJ: }
|
|
; OBJ: ]
|