1# REQUIRES: mips 2# Check R_MIPS_GOT16 relocation calculation. 3 4# RUN: echo "SECTIONS { \ 5# RUN: . = 0x20000; .text : { *(.text) } \ 6# RUN: . = 0x30000; .got : { *(.got) } \ 7# RUN: }" > %t.script 8 9# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-be.o 10# RUN: ld.lld %t-be.o --script %t.script -o %t-be.exe 11# RUN: llvm-readobj --sections -r --symbols -A %t-be.exe \ 12# RUN: | FileCheck -check-prefix=ELF %s 13# RUN: llvm-objdump -d %t-be.exe | FileCheck --check-prefix=DIS %s 14 15# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o 16# RUN: ld.lld %t-el.o --script %t.script -o %t-el.exe 17# RUN: llvm-readobj --sections -r --symbols -A %t-el.exe \ 18# RUN: | FileCheck -check-prefix=ELF %s 19# RUN: llvm-objdump -d %t-el.exe | FileCheck --check-prefix=DIS %s 20 21# RUN: ld.lld -shared %t-be.o --script %t.script -o %t-be.so 22# RUN: llvm-readobj --sections -r --symbols -A %t-be.so \ 23# RUN: | FileCheck -check-prefix=ELF %s 24# RUN: llvm-objdump -d %t-be.so | FileCheck --check-prefix=DIS %s 25 26# RUN: ld.lld -shared %t-el.o --script %t.script -o %t-el.so 27# RUN: llvm-readobj --sections -r --symbols -A %t-el.so \ 28# RUN: | FileCheck -check-prefix=ELF %s 29# RUN: llvm-objdump -d %t-el.so | FileCheck --check-prefix=DIS %s 30 31 .text 32 .globl __start 33__start: 34 lui $2, %got(v1) 35 36 .data 37 .globl v1 38v1: 39 .word 0 40 41# ELF: Section { 42# ELF: Name: .got 43# ELF: Flags [ 44# ELF-NEXT: SHF_ALLOC 45# ELF-NEXT: SHF_MIPS_GPREL 46# ELF-NEXT: SHF_WRITE 47# ELF-NEXT: ] 48# 49# ELF: Relocations [ 50# ELF-NEXT: ] 51# 52# ELF: Symbol { 53# ELF: Name: v1 54# ELF-NEXT: Value: 0x[[V1:[0-9A-F]+]] 55# 56# ELF: {{.*}} GOT { 57# ELF-NEXT: Canonical gp value: 0x37FF0 58# 59# ELF: Entry { 60# ELF: Address: 0x30008 61# ELF-NEXT: Access: -32744 62# ELF-NEXT: Initial: 0x[[V1]] 63 64# "v1 GOT entry address" - _gp 65# 0x30008 - 0x37FF0 = -0x7fe8 == 0x8018 == 32792 66# DIS: lui $2, 32792 67