1# REQUIRES: mips 2 3# Check addend adjustment in case of generating a relocatable object 4# if some input files have non-zero GP0 value. 5 6# We have to use GNU as and ld.bfd 2.28 to generate relocatable object 7# files with non-zero GP0 value using the following command lines: 8# 9# as -mips32 -o test.o \ 10# && ld.bfd -m elf32btsmip -r test.o -o mips-gp0-non-zero.o 11# as -mips64 -o test.o \ 12# && ld.bfd -m elf64btsmip -r test.o -o mips-n64-gp0-non-zero.o 13 14# Source code for mips-gp0-non-zero.o: 15# .text 16# .global __start 17# __start: 18# lw $t0,%call16(__start)($gp) 19# foo: 20# nop 21# bar: 22# nop 23# 24# .section .rodata, "a" 25# v: 26# .gpword foo 27# .gpword bar 28 29# Source code for mips-n64-gp0-non-zero.o and mips-micro-gp0-non-zero.o: 30# .text 31# .global __start 32# __start: 33# foo: 34# lui $gp,%hi(%neg(%gp_rel(foo))) 35 36# RUN: ld.lld -r -o %t-32.r %S/Inputs/mips-gp0-non-zero.o 37# RUN: llvm-readobj -A %t-32.r | FileCheck --check-prefix=GPVAL %s 38# RUN: llvm-objdump -s %t-32.r | FileCheck --check-prefix=ADDEND32 %s 39 40# RUN: ld.lld -r -o %t-64.r %S/Inputs/mips-n64-gp0-non-zero.o 41# RUN: llvm-readobj -A %t-64.r | FileCheck --check-prefix=GPVAL %s 42# RUN: llvm-readobj -r %S/Inputs/mips-n64-gp0-non-zero.o %t-64.r \ 43# RUN: | FileCheck --check-prefix=ADDEND64 %s 44 45# GPVAL: GP: 0x0 46 47# ADDEND32: Contents of section .rodata: 48# ADDEND32-NEXT: 0000 00007ff4 00007ff8 49# ^ 4+GP0 ^ 8+GP0 50 51# ADDEND64: File: {{.*}}{{/|\\}}mips-n64-gp0-non-zero.o 52# ADDEND64: .text 0xFFFFFFFFFFFF8011 53# ADDEND64: File: {{.*}}{{/|\\}}mips-non-zero-gp0.s.tmp-64.r 54# ADDEND64: .text 0x0 55