2018-06-27 00:58:19 +08:00
|
|
|
# REQUIRES: mips
|
2016-11-24 06:22:16 +08:00
|
|
|
# Check that the linker use a value of _gp symbol defined
|
|
|
|
# in a linker script to calculate GOT relocations.
|
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
|
2016-12-08 14:19:47 +08:00
|
|
|
|
2016-11-24 06:22:16 +08:00
|
|
|
# RUN: echo "SECTIONS { \
|
|
|
|
# RUN: .text : { *(.text) } \
|
2017-01-10 07:16:01 +08:00
|
|
|
# RUN: _gp = ABSOLUTE(.) + 0x100; \
|
2016-12-08 14:19:47 +08:00
|
|
|
# RUN: .got : { *(.got) } }" > %t.rel.script
|
2017-09-21 02:30:57 +08:00
|
|
|
# RUN: ld.lld -shared -o %t.rel.so --script %t.rel.script %t.o
|
|
|
|
# RUN: llvm-objdump -s -t %t.rel.so | FileCheck --check-prefix=REL %s
|
|
|
|
|
|
|
|
# RUN: echo "SECTIONS { \
|
|
|
|
# RUN: .text : { *(.text) } \
|
|
|
|
# RUN: _gp = 0x100 + ABSOLUTE(.); \
|
|
|
|
# RUN: .got : { *(.got) } }" > %t.rel.script
|
2016-12-08 14:19:47 +08:00
|
|
|
# RUN: ld.lld -shared -o %t.rel.so --script %t.rel.script %t.o
|
|
|
|
# RUN: llvm-objdump -s -t %t.rel.so | FileCheck --check-prefix=REL %s
|
|
|
|
|
|
|
|
# RUN: echo "SECTIONS { \
|
|
|
|
# RUN: .text : { *(.text) } \
|
|
|
|
# RUN: _gp = 0x200; \
|
|
|
|
# RUN: .got : { *(.got) } }" > %t.abs.script
|
|
|
|
# RUN: ld.lld -shared -o %t.abs.so --script %t.abs.script %t.o
|
|
|
|
# RUN: llvm-objdump -s -t %t.abs.so | FileCheck --check-prefix=ABS %s
|
2016-11-24 06:22:16 +08:00
|
|
|
|
2018-06-27 01:04:47 +08:00
|
|
|
# REL: Contents of section .reginfo:
|
2018-06-27 06:13:32 +08:00
|
|
|
# REL-NEXT: 0018 10000104 00000000 00000000 00000000
|
|
|
|
# REL-NEXT: 0028 00000000 000001ec
|
2018-06-27 01:04:47 +08:00
|
|
|
# ^-- _gp
|
|
|
|
|
2016-12-08 14:19:47 +08:00
|
|
|
# REL: Contents of section .text:
|
2018-06-27 01:04:47 +08:00
|
|
|
# REL-NEXT: 00e0 3c080000 2108010c 8f82ff1c
|
2016-12-08 14:19:47 +08:00
|
|
|
# ^-- %hi(_gp_disp)
|
|
|
|
# ^-- %lo(_gp_disp)
|
2018-06-27 01:04:47 +08:00
|
|
|
# ^-- 8 - (0x1ec - 0x100)
|
2016-12-08 14:19:47 +08:00
|
|
|
# G - (GP - .got)
|
|
|
|
|
|
|
|
# REL: Contents of section .data:
|
2017-01-10 09:21:30 +08:00
|
|
|
# REL-NEXT: 00f0 fffffef4
|
2018-06-27 01:04:47 +08:00
|
|
|
# ^-- 0x30-0x1ec
|
2018-05-30 16:48:53 +08:00
|
|
|
# foo - GP
|
2016-12-08 14:19:47 +08:00
|
|
|
|
2018-06-27 01:04:47 +08:00
|
|
|
# REL: 000000e0 .text 00000000 foo
|
2017-03-21 05:03:43 +08:00
|
|
|
# REL: 00000000 *ABS* 00000000 .hidden _gp_disp
|
2018-06-27 01:04:47 +08:00
|
|
|
# REL: 000001ec *ABS* 00000000 .hidden _gp
|
|
|
|
|
|
|
|
# ABS: Contents of section .reginfo:
|
2018-06-27 06:13:32 +08:00
|
|
|
# ABS-NEXT: 0018 10000104 00000000 00000000 00000000
|
|
|
|
# ABS-NEXT: 0028 00000000 00000200
|
2018-06-27 01:04:47 +08:00
|
|
|
# ^-- _gp
|
2016-12-08 14:19:47 +08:00
|
|
|
|
|
|
|
# ABS: Contents of section .text:
|
2018-06-27 01:04:47 +08:00
|
|
|
# ABS-NEXT: 00e0 3c080000 21080120 8f82ff08
|
2016-12-08 14:19:47 +08:00
|
|
|
# ^-- %hi(_gp_disp)
|
|
|
|
# ^-- %lo(_gp_disp)
|
2017-01-17 05:17:23 +08:00
|
|
|
# ^-- 8 - (0x200 - 0x100)
|
2016-12-08 14:19:47 +08:00
|
|
|
# G - (GP - .got)
|
|
|
|
|
|
|
|
# ABS: Contents of section .data:
|
2018-06-27 01:04:47 +08:00
|
|
|
# ABS-NEXT: 00f0 fffffee0
|
|
|
|
# ^-- 0xe0-0x200
|
2018-05-30 16:48:53 +08:00
|
|
|
# foo - GP
|
2016-12-08 14:19:47 +08:00
|
|
|
|
2018-06-27 01:04:47 +08:00
|
|
|
# ABS: 000000e0 .text 00000000 foo
|
2017-03-21 05:03:43 +08:00
|
|
|
# ABS: 00000000 *ABS* 00000000 .hidden _gp_disp
|
2016-12-08 14:19:47 +08:00
|
|
|
# ABS: 00000200 *ABS* 00000000 .hidden _gp
|
2016-11-24 06:22:16 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
foo:
|
|
|
|
lui $t0, %hi(_gp_disp)
|
|
|
|
addi $t0, $t0, %lo(_gp_disp)
|
|
|
|
lw $v0, %call16(bar)($gp)
|
|
|
|
|
|
|
|
.data
|
|
|
|
.gpword foo
|