2018-06-27 00:58:19 +08:00
|
|
|
# REQUIRES: mips
|
2015-11-06 15:43:03 +08:00
|
|
|
# Check R_MIPS_GOT16 relocation calculation.
|
|
|
|
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: echo "SECTIONS { \
|
|
|
|
# RUN: . = 0x20000; .text : { *(.text) } \
|
|
|
|
# RUN: . = 0x30000; .got : { *(.got) } \
|
|
|
|
# RUN: }" > %t.script
|
|
|
|
|
2015-11-06 15:43:03 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-be.o
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: ld.lld %t-be.o --script %t.script -o %t-be.exe
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-be.exe \
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: | FileCheck -check-prefix=ELF %s
|
2019-02-25 19:30:33 +08:00
|
|
|
# RUN: llvm-objdump -d %t-be.exe | FileCheck -check-prefix=DIS %s
|
2015-11-06 15:43:03 +08:00
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: ld.lld %t-el.o --script %t.script -o %t-el.exe
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-el.exe \
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: | FileCheck -check-prefix=ELF %s
|
2019-02-25 19:30:33 +08:00
|
|
|
# RUN: llvm-objdump -d %t-el.exe | FileCheck -check-prefix=DIS %s
|
2015-11-06 15:43:03 +08:00
|
|
|
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: ld.lld -shared %t-be.o --script %t.script -o %t-be.so
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-be.so \
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: | FileCheck -check-prefix=ELF %s
|
2019-02-25 19:30:33 +08:00
|
|
|
# RUN: llvm-objdump -d %t-be.so | FileCheck -check-prefix=DIS %s
|
2015-11-06 15:43:03 +08:00
|
|
|
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: ld.lld -shared %t-el.o --script %t.script -o %t-el.so
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-el.so \
|
2019-09-07 23:44:40 +08:00
|
|
|
# RUN: | FileCheck -check-prefix=ELF %s
|
2019-02-25 19:30:33 +08:00
|
|
|
# RUN: llvm-objdump -d %t-el.so | FileCheck -check-prefix=DIS %s
|
2015-11-06 15:43:03 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.globl __start
|
|
|
|
__start:
|
|
|
|
lui $2, %got(v1)
|
|
|
|
|
|
|
|
.data
|
|
|
|
.globl v1
|
|
|
|
v1:
|
|
|
|
.word 0
|
|
|
|
|
2019-02-25 19:30:33 +08:00
|
|
|
# ELF: Section {
|
|
|
|
# ELF: Name: .got
|
|
|
|
# ELF: Flags [
|
|
|
|
# ELF-NEXT: SHF_ALLOC
|
|
|
|
# ELF-NEXT: SHF_MIPS_GPREL
|
|
|
|
# ELF-NEXT: SHF_WRITE
|
|
|
|
# ELF-NEXT: ]
|
|
|
|
#
|
|
|
|
# ELF: Relocations [
|
|
|
|
# ELF-NEXT: ]
|
|
|
|
#
|
|
|
|
# ELF: Symbol {
|
|
|
|
# ELF: Name: v1
|
|
|
|
# ELF-NEXT: Value: 0x[[V1:[0-9A-F]+]]
|
|
|
|
#
|
|
|
|
# ELF: {{.*}} GOT {
|
2019-09-07 23:44:40 +08:00
|
|
|
# ELF-NEXT: Canonical gp value: 0x37FF0
|
2019-02-25 19:30:33 +08:00
|
|
|
#
|
|
|
|
# ELF: Entry {
|
2019-09-07 23:44:40 +08:00
|
|
|
# ELF: Address: 0x30008
|
2019-02-25 19:30:33 +08:00
|
|
|
# ELF-NEXT: Access: -32744
|
|
|
|
# ELF-NEXT: Initial: 0x[[V1]]
|
|
|
|
|
|
|
|
# "v1 GOT entry address" - _gp
|
2019-09-07 23:44:40 +08:00
|
|
|
# 0x30008 - 0x37FF0 = -0x7fe8 == 0x8018 == 32792
|
|
|
|
# DIS: lui $2, 32792
|