2018-06-27 00:58:19 +08:00
|
|
|
# REQUIRES: mips
|
2016-11-06 06:58:01 +08:00
|
|
|
# Check handling of N32 ABI relocation records.
|
|
|
|
|
2018-07-03 22:39:27 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
|
|
|
|
# RUN: -target-abi n32 -o %t.o %s
|
|
|
|
# RUN: ld.lld %t.o -o %t.exe
|
2016-11-06 06:58:01 +08:00
|
|
|
# RUN: llvm-objdump -t -d -s %t.exe | FileCheck %s
|
|
|
|
# RUN: llvm-readobj -h %t.exe | FileCheck -check-prefix=ELF %s
|
|
|
|
|
2018-07-03 22:39:27 +08:00
|
|
|
.option pic2
|
|
|
|
.text
|
|
|
|
.type __start, @function
|
|
|
|
.global __start
|
|
|
|
__start:
|
|
|
|
lui $gp,%hi(%neg(%gp_rel(__start))) # R_MIPS_GPREL16
|
|
|
|
# R_MIPS_SUB
|
|
|
|
# R_MIPS_HI16
|
|
|
|
loc:
|
|
|
|
daddiu $gp,$gp,%lo(%neg(%gp_rel(__start))) # R_MIPS_GPREL16
|
|
|
|
# R_MIPS_SUB
|
|
|
|
# R_MIPS_LO16
|
|
|
|
|
|
|
|
.section .rodata,"a",@progbits
|
|
|
|
.gpword(loc) # R_MIPS_GPREL32
|
2016-11-06 06:58:01 +08:00
|
|
|
|
|
|
|
# CHECK: Disassembly of section .text:
|
|
|
|
# CHECK-NEXT: __start:
|
|
|
|
# CHECK-NEXT: 20000: 3c 1c 00 01 lui $gp, 1
|
|
|
|
# ^-- 0x20000 - 0x37ff0
|
|
|
|
# ^-- 0 - 0xfffe8010
|
|
|
|
# ^-- %hi(0x17ff0)
|
|
|
|
# CHECK: loc:
|
|
|
|
# CHECK-NEXT: 20004: 67 9c 7f f0 daddiu $gp, $gp, 32752
|
|
|
|
# ^-- 0x20000 - 0x37ff0
|
|
|
|
# ^-- 0 - 0xfffe8010
|
|
|
|
# ^-- %lo(0x17ff0)
|
|
|
|
|
|
|
|
# CHECK: Contents of section .rodata:
|
2018-07-03 22:39:27 +08:00
|
|
|
# CHECK-NEXT: {{[0-9a-f]+}} fffe8014
|
|
|
|
# ^-- loc - _gp
|
2016-11-06 06:58:01 +08:00
|
|
|
|
|
|
|
# CHECK: 00020004 .text 00000000 loc
|
2017-09-15 09:49:01 +08:00
|
|
|
# CHECK: 00037ff0 .got 00000000 .hidden _gp
|
2016-11-06 06:58:01 +08:00
|
|
|
# CHECK: 00020000 g F .text 00000000 __start
|
|
|
|
|
|
|
|
# ELF: Format: ELF32-mips
|
|
|
|
# ELF-NEXT: Arch: mips
|
|
|
|
# ELF-NEXT: AddressSize: 32bit
|
|
|
|
# ELF-NEXT: LoadName:
|
|
|
|
# ELF-NEXT: ElfHeader {
|
|
|
|
# ELF-NEXT: Ident {
|
|
|
|
# ELF-NEXT: Magic: (7F 45 4C 46)
|
|
|
|
# ELF-NEXT: Class: 32-bit (0x1)
|
|
|
|
# ELF-NEXT: DataEncoding: BigEndian (0x2)
|
|
|
|
# ELF-NEXT: FileVersion: 1
|
|
|
|
# ELF-NEXT: OS/ABI: SystemV (0x0)
|
|
|
|
# ELF-NEXT: ABIVersion: 0
|
|
|
|
# ELF-NEXT: Unused: (00 00 00 00 00 00 00)
|
|
|
|
# ELF-NEXT: }
|
|
|
|
# ELF-NEXT: Type: Executable (0x2)
|
|
|
|
# ELF-NEXT: Machine: EM_MIPS (0x8)
|
|
|
|
# ELF-NEXT: Version: 1
|
|
|
|
# ELF-NEXT: Entry: 0x20000
|
|
|
|
# ELF-NEXT: ProgramHeaderOffset:
|
|
|
|
# ELF-NEXT: SectionHeaderOffset:
|
|
|
|
# ELF-NEXT: Flags [
|
|
|
|
# ELF-NEXT: EF_MIPS_ABI2
|
2018-07-03 22:39:27 +08:00
|
|
|
# ELF-NEXT: EF_MIPS_ARCH_64
|
|
|
|
# ELF-NEXT: EF_MIPS_CPIC
|
|
|
|
# ELF-NEXT: EF_MIPS_PIC
|
2016-11-06 06:58:01 +08:00
|
|
|
# ELF-NEXT: ]
|