llvm-project/lld/test/ELF/ppc32-reloc-got.s

37 lines
1.1 KiB
ArmAsm

# REQUIRES: ppc
# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
# RUN: echo '.globl b; b:' | llvm-mc -filetype=obj -triple=powerpc - -o %t1.o
# RUN: ld.lld -shared %t1.o -soname=t1.so -o %t1.so
# RUN: ld.lld %t.o %t1.so -o %t
# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
# RUN: llvm-readobj -x .got %t | FileCheck --check-prefix=HEX %s
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
## Check we can handle R_PPC_GOT16, which may be generated by -fpic code.
# RELOC: .rela.dyn {
# RELOC-NEXT: 0x10020218 R_PPC_GLOB_DAT b 0x0
# RELOC-NEXT: }
# NM: 1002020c d _GLOBAL_OFFSET_TABLE_
# NM: 10030220 d a
## The GOT slot of a can be filled at link time.
# HEX: section '.got':
# HEX: 0x1002020c [[#%x,]] 00000000 00000000 00000000
# HEX-NEXT: 0x1002021c 10030220
## a: &.got[4] - _GLOBAL_OFFSET_TABLE_ = 0x1002021c - 0x1002020c = 16
## b: &.got[3] - _GLOBAL_OFFSET_TABLE_ = 0x10020218 - 0x1002020c = 12
# CHECK: lwz 3, 16(30)
# CHECK: lwz 4, 12(30)
lwz 3,a@got(30)
lwz 4,b@got(30)
.data
a:
.long _GLOBAL_OFFSET_TABLE_