[mips] Make another set of test cases more tolerant to exact symbol addresses. NFC

llvm-svn: 371313
This commit is contained in:
Simon Atanasyan 2019-09-07 15:44:40 +00:00
parent 72e99e63a2
commit fcef13344d
16 changed files with 247 additions and 352 deletions

View File

@ -1,26 +1,31 @@
# REQUIRES: mips # REQUIRES: mips
# Check R_MIPS_GOT16 relocation calculation. # Check R_MIPS_GOT16 relocation calculation.
# RUN: echo "SECTIONS { \
# RUN: . = 0x20000; .text : { *(.text) } \
# RUN: . = 0x30000; .got : { *(.got) } \
# RUN: }" > %t.script
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-be.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-be.o
# RUN: ld.lld %t-be.o -o %t-be.exe # RUN: ld.lld %t-be.o --script %t.script -o %t-be.exe
# RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-be.exe \ # RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-be.exe \
# RUN: | FileCheck -check-prefixes=ELF,EXE %s # RUN: | FileCheck -check-prefix=ELF %s
# RUN: llvm-objdump -d %t-be.exe | FileCheck -check-prefix=DIS %s # RUN: llvm-objdump -d %t-be.exe | FileCheck -check-prefix=DIS %s
# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o
# RUN: ld.lld %t-el.o -o %t-el.exe # RUN: ld.lld %t-el.o --script %t.script -o %t-el.exe
# RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-el.exe \ # RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-el.exe \
# RUN: | FileCheck -check-prefixes=ELF,EXE %s # RUN: | FileCheck -check-prefix=ELF %s
# RUN: llvm-objdump -d %t-el.exe | FileCheck -check-prefix=DIS %s # RUN: llvm-objdump -d %t-el.exe | FileCheck -check-prefix=DIS %s
# RUN: ld.lld -shared %t-be.o -o %t-be.so # RUN: ld.lld -shared %t-be.o --script %t.script -o %t-be.so
# RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-be.so \ # RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-be.so \
# RUN: | FileCheck -check-prefixes=ELF,DSO %s # RUN: | FileCheck -check-prefix=ELF %s
# RUN: llvm-objdump -d %t-be.so | FileCheck -check-prefix=DIS %s # RUN: llvm-objdump -d %t-be.so | FileCheck -check-prefix=DIS %s
# RUN: ld.lld -shared %t-el.o -o %t-el.so # RUN: ld.lld -shared %t-el.o --script %t.script -o %t-el.so
# RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-el.so \ # RUN: llvm-readobj --sections -r --symbols --mips-plt-got %t-el.so \
# RUN: | FileCheck -check-prefixes=ELF,DSO %s # RUN: | FileCheck -check-prefix=ELF %s
# RUN: llvm-objdump -d %t-el.so | FileCheck -check-prefix=DIS %s # RUN: llvm-objdump -d %t-el.so | FileCheck -check-prefix=DIS %s
.text .text
@ -30,8 +35,6 @@ __start:
.data .data
.globl v1 .globl v1
.type v1,@object
.size v1,4
v1: v1:
.word 0 .word 0
@ -51,16 +54,13 @@ v1:
# ELF-NEXT: Value: 0x[[V1:[0-9A-F]+]] # ELF-NEXT: Value: 0x[[V1:[0-9A-F]+]]
# #
# ELF: {{.*}} GOT { # ELF: {{.*}} GOT {
# EXE-NEXT: Canonical gp value: 0x38000 # ELF-NEXT: Canonical gp value: 0x37FF0
# DSO-NEXT: Canonical gp value: 0x28000
# #
# ELF: Entry { # ELF: Entry {
# EXE: Address: 0x30018 # ELF: Address: 0x30008
# DSO: Address: 0x20018
# ELF-NEXT: Access: -32744 # ELF-NEXT: Access: -32744
# ELF-NEXT: Initial: 0x[[V1]] # ELF-NEXT: Initial: 0x[[V1]]
# "v1 GOT entry address" - _gp # "v1 GOT entry address" - _gp
# exe: 0x30018 - 0x38000 = -0x7fe8 == 0x8018 == 32792 # 0x30008 - 0x37FF0 = -0x7fe8 == 0x8018 == 32792
# dso: 0x20018 - 0x28000 = -0x7fe8 == 0x8018 == 32792 # DIS: lui $2, 32792
# DIS: {{.*}} lui $2, 32792

View File

@ -3,118 +3,42 @@
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -shared -o %t1.so # RUN: ld.lld %t.o -shared -o %t1.so
# RUN: llvm-readobj -r --dyn-syms --dynamic-table --mips-plt-got %t1.so \ # RUN: llvm-readelf -r --dyn-syms --dynamic-table --mips-plt-got %t1.so \
# RUN: | FileCheck -check-prefixes=CHECK,NOSYM %s # RUN: | FileCheck -check-prefixes=CHECK,NOSYM %s
# RUN: ld.lld %t.o -shared -Bsymbolic -o %t2.so # RUN: ld.lld %t.o -shared -Bsymbolic -o %t2.so
# RUN: llvm-readobj -r --dyn-syms --dynamic-table --mips-plt-got %t2.so \ # RUN: llvm-readelf -r --dyn-syms --dynamic-table --mips-plt-got %t2.so \
# RUN: | FileCheck -check-prefixes=CHECK,SYM %s # RUN: | FileCheck -check-prefixes=CHECK,SYM %s
# CHECK: Relocations [ # CHECK: There are no relocations in this file.
# CHECK-NEXT: ]
# NOSYM: Symbol { # CHECK: Symbol table '.dynsym'
# NOSYM: Name: foo # CHECK-DAG: [[FOO:[0-9a-f]+]] 0 NOTYPE WEAK DEFAULT 8 foo
# NOSYM-NEXT: Value: 0x20000 # CHECK-DAG: 00000000 0 NOTYPE WEAK DEFAULT UND bar
# NOSYM-NEXT: Size: 0 # CHECK-DAG: [[SYM:[0-9a-f]+]] 0 NOTYPE GLOBAL DEFAULT 8 sym
# NOSYM-NEXT: Binding: Weak
# NOSYM-NEXT: Type: None
# NOSYM-NEXT: Other: 0
# NOSYM-NEXT: Section: .data
# NOSYM-NEXT: }
# CHECK: Symbol { # CHECK: Dynamic section
# CHECK: Name: bar # CHECK: (MIPS_SYMTABNO) 4
# CHECK-NEXT: Value: 0x0 # NOSYM: (MIPS_LOCAL_GOTNO) 2
# CHECK-NEXT: Size: 0 # NOSYM: (MIPS_GOTSYM) 0x1
# CHECK-NEXT: Binding: Weak # SYM: (MIPS_LOCAL_GOTNO) 4
# CHECK-NEXT: Type: None # SYM: (MIPS_GOTSYM) 0x3
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# NOSYM: Symbol { # NOSYM: Primary GOT:
# NOSYM: Name: sym # NOSYM-NOT: Local entries:
# NOSYM-NEXT: Value: 0x20004 # NOSYM: Global entries:
# NOSYM-NEXT: Size: 0 # NOSYM-NEXT: Access Initial Sym.Val. Type Ndx Name
# NOSYM-NEXT: Binding: Global # NOSYM-NEXT: -32744(gp) [[FOO]] [[FOO]] NOTYPE 8 foo
# NOSYM-NEXT: Type: None # NOSYM-NEXT: -32740(gp) 00000000 00000000 NOTYPE UND bar
# NOSYM-NEXT: Other: 0 # NOSYM-NEXT: -32736(gp) [[SYM]] [[SYM]] NOTYPE 8 sym
# NOSYM-NEXT: Section: .data
# NOSYM-NEXT: }
# CHECK: 0x70000011 MIPS_SYMTABNO 4 # SYM: Primary GOT:
# SYM: Local entries:
# SYM: 0x7000000A MIPS_LOCAL_GOTNO 4 # SYM-NEXT: Access Initial
# SYM: 0x70000013 MIPS_GOTSYM 0x3 # SYM-NEXT: -32744(gp) [[FOO]]
# SYM-NEXT: -32740(gp) [[SYM]]
# NOSYM: 0x7000000A MIPS_LOCAL_GOTNO 2 # SYM: Global entries:
# NOSYM: 0x70000013 MIPS_GOTSYM 0x1 # SYM-NEXT: Access Initial Sym.Val. Type Ndx Name
# SYM-NEXT: -32736(gp) 00000000 00000000 NOTYPE UND bar
# CHECK: Primary GOT {
# CHECK-NEXT: Canonical gp value:
# CHECK-NEXT: Reserved entries [
# CHECK: ]
# SYM: Local entries [
# SYM-NEXT: Entry {
# SYM-NEXT: Address:
# SYM-NEXT: Access: -32744
# SYM-NEXT: Initial: 0x20000
# SYM-NEXT: }
# SYM-NEXT: Entry {
# SYM-NEXT: Address:
# SYM-NEXT: Access: -32740
# SYM-NEXT: Initial: 0x20004
# SYM-NEXT: }
# SYM-NEXT: ]
# NOSYM: Local entries [
# NOSYM-NEXT: ]
# SYM-NEXT: Global entries [
# SYM-NEXT: Entry {
# SYM-NEXT: Address:
# SYM-NEXT: Access: -32736
# SYM-NEXT: Initial: 0x0
# SYM-NEXT: Value: 0x0
# SYM-NEXT: Type: None
# SYM-NEXT: Section: Undefined
# SYM-NEXT: Name: bar
# SYM-NEXT: }
# SYM-NEXT: ]
# NOSYM-NEXT: Global entries [
# NOSYM-NEXT: Entry {
# NOSYM-NEXT: Address:
# NOSYM-NEXT: Access: -32744
# NOSYM-NEXT: Initial: 0x20000
# NOSYM-NEXT: Value: 0x20000
# NOSYM-NEXT: Type: None
# NOSYM-NEXT: Section: .data
# NOSYM-NEXT: Name: foo
# NOSYM-NEXT: }
# NOSYM-NEXT: Entry {
# NOSYM-NEXT: Address:
# NOSYM-NEXT: Access: -32740
# NOSYM-NEXT: Initial: 0x0
# NOSYM-NEXT: Value: 0x0
# NOSYM-NEXT: Type: None
# NOSYM-NEXT: Section: Undefined
# NOSYM-NEXT: Name: bar
# NOSYM-NEXT: }
# NOSYM-NEXT: Entry {
# NOSYM-NEXT: Address:
# NOSYM-NEXT: Access: -32736
# NOSYM-NEXT: Initial: 0x20004
# NOSYM-NEXT: Value: 0x20004
# NOSYM-NEXT: Type: None
# NOSYM-NEXT: Section: .data
# NOSYM-NEXT: Name: sym
# NOSYM-NEXT: }
# NOSYM-NEXT: ]
# CHECK: Number of TLS and multi-GOT entries: 0
# CHECK-NEXT: }
.text .text
.global sym .global sym

View File

@ -6,27 +6,32 @@
# RUN: ld.lld -r -o %t %t.o %t.o # RUN: ld.lld -r -o %t %t.o %t.o
# RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck -check-prefix=OBJ %s # RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck -check-prefix=OBJ %s
# RUN: ld.lld -shared -o %t.so %t # RUN: ld.lld -shared -o %t.so %t
# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck -check-prefix=SO %s # RUN: llvm-objdump -d -t --print-imm-hex --no-show-raw-insn %t.so \
# RUN: | FileCheck -check-prefix=SO %s
# OBJ: Disassembly of section .text: # OBJ: Disassembly of section .text:
# OBJ-EMPTY: # OBJ-EMPTY:
# OBJ-NEXT: .text: # OBJ-NEXT: .text:
# OBJ-NEXT: 0: lw $25, 0($gp) # OBJ-NEXT: lw $25, 0($gp)
# OBJ-NEXT: 00000000: R_MIPS_GOT16 .data # OBJ-NEXT: 00000000: R_MIPS_GOT16 .data
# OBJ-NEXT: 4: addiu $4, $25, 0 # OBJ-NEXT: addiu $4, $25, 0
# OBJ-NEXT: 00000004: R_MIPS_LO16 .data # OBJ-NEXT: 00000004: R_MIPS_LO16 .data
# OBJ: 10: lw $25, 0($gp) # OBJ: lw $25, 0($gp)
# OBJ-NEXT: 00000010: R_MIPS_GOT16 .data # OBJ-NEXT: 00000010: R_MIPS_GOT16 .data
# OBJ-NEXT: 14: addiu $4, $25, 16 # OBJ-NEXT: addiu $4, $25, 16
# OBJ-NEXT: 00000014: R_MIPS_LO16 .data # OBJ-NEXT: 00000014: R_MIPS_LO16 .data
# SO: Disassembly of section .text: # SO: Disassembly of section .text:
# SO-EMPTY: # SO-EMPTY:
# SO-NEXT: .text: # SO-NEXT: .text:
# SO-NEXT: 10000: lw $25, -32744($gp) # SO-NEXT: lw $25, -0x7fe8($gp)
# SO-NEXT: 10004: addiu $4, $25, 0 # SO-NEXT: addiu $4, $25, 0x[[D1:[0-9a-f]+]]
# SO: 10010: lw $25, -32744($gp) # SO: lw $25, -0x7fe8($gp)
# SO-NEXT: 10014: addiu $4, $25, 16 # SO-NEXT: addiu $4, $25, 0x[[D2:[0-9a-f]+]]
# SO: SYMBOL TABLE
# SO: [[D1]]
# SO: [[D2]]
.text .text
lw $t9, %got(.data)($gp) lw $t9, %got(.data)($gp)

View File

@ -2,52 +2,54 @@
# Check R_MIPS_GOT16 relocation calculation. # Check R_MIPS_GOT16 relocation calculation.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -shared -o %t.so # RUN: echo "SECTIONS { \
# RUN: . = 0x1000; .text ALIGN(0x1000) : { *(.text) } \
# RUN: . = 0x3000; .data : { *(.data) } \
# RUN: }" > %t.script
# RUN: ld.lld %t.o -shared --script %t.script -o %t.so
# RUN: llvm-objdump -d -t --no-show-raw-insn %t.so | FileCheck %s # RUN: llvm-objdump -d -t --no-show-raw-insn %t.so | FileCheck %s
# RUN: llvm-readelf -r --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s # RUN: llvm-readelf -r --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s
# CHECK: Disassembly of section .text: # CHECK: __start:
# CHECK-EMPTY: # CHECK-NEXT: lw $8, -32744($gp)
# CHECK-NEXT: __start: # CHECK-NEXT: addi $8, $8, 8236
# CHECK-NEXT: 10000: lw $8, -32744($gp) # CHECK-NEXT: lw $8, -32732($gp)
# CHECK-NEXT: 10004: addi $8, $8, 44 # CHECK-NEXT: addi $8, $8, -16384
# CHECK-NEXT: 10008: lw $8, -32732($gp) # CHECK-NEXT: lw $8, -32728($gp)
# CHECK-NEXT: 1000c: addi $8, $8, -28672 # CHECK-NEXT: addi $8, $8, -16380
# CHECK-NEXT: 10010: lw $8, -32728($gp) # CHECK-NEXT: lw $8, -32728($gp)
# CHECK-NEXT: 10014: addi $8, $8, -28668 # CHECK-NEXT: addi $8, $8, 16388
# CHECK-NEXT: 10018: lw $8, -32728($gp) # CHECK-NEXT: lw $8, -32720($gp)
# CHECK-NEXT: 1001c: addi $8, $8, 4100 # CHECK-NEXT: addi $8, $8, 16392
# CHECK-NEXT: 10020: lw $8, -32720($gp) # CHECK-NEXT: lw $8, -32716($gp)
# CHECK-NEXT: 10024: addi $8, $8, 4104
# CHECK-NEXT: 10028: lw $8, -32716($gp)
# #
# CHECK: SYMBOL TABLE: # CHECK: SYMBOL TABLE:
# CHECK: 00041008 .data 00000000 .hidden bar # CHECK: 00024008 .data 00000000 .hidden bar
# CHECK: 00000000 *UND* 00000000 foo # CHECK: 00000000 *UND* 00000000 foo
# GOT: There are no relocations in this file. # GOT: There are no relocations in this file.
# GOT: Local entries: # GOT: Local entries:
# GOT-NEXT: Address Access Initial # GOT-NEXT: Access Initial
# GOT-NEXT: 00041018 -32744(gp) 00010000 # GOT-NEXT: -32744(gp) 00000000
# ^-- (0x1002c + 0x8000) & ~0xffff # ^-- (0x2000 + 0x8000) & ~0xffff
# GOT-NEXT: 0004101c -32740(gp) 00020000 # GOT-NEXT: -32740(gp) 00010000
# ^-- redundant unused entry # ^-- redundant unused entry
# GOT-NEXT: 00041020 -32736(gp) 00020000 # GOT-NEXT: -32736(gp) 00000000
# ^-- redundant unused entry # ^-- redundant unused entry
# GOT-NEXT: 00041024 -32732(gp) 00030000 # GOT-NEXT: -32732(gp) 00010000
# ^-- (0x29000 + 0x8000) & ~0xffff # ^-- (0x3000 + 0x9000 + 0x8000) & ~0xffff
# GOT-NEXT: 00041028 -32728(gp) 00040000 # GOT-NEXT: -32728(gp) 00020000
# ^-- (0x29000 + 0x10004 + 0x8000) & ~0xffff # ^-- (0x3000 + 0x9000 + 0x10004 + 0x8000) & ~0xffff
# ^-- (0x29000 + 0x18004 + 0x8000) & ~0xffff # ^-- (0x3000 + 0x9000 + 0x18004 + 0x8000) & ~0xffff
# GOT-NEXT: 0004102c -32724(gp) 00050000 # GOT-NEXT: -32724(gp) 00030000
# ^-- redundant unused entry # ^-- redundant unused entry
# GOT-NEXT: 00041030 -32720(gp) 00041008 # GOT-NEXT: -32720(gp) 00024008
# ^-- 'bar' address # ^-- 'bar' address
# GOT-EMPTY: # GOT-EMPTY:
# GOT-NEXT: Global entries: # GOT-NEXT: Global entries:
# GOT-NEXT: Address Access Initial Sym.Val. Type Ndx Name # GOT-NEXT: Access Initial Sym.Val. Type Ndx Name
# GOT-NEXT: 00041034 -32716(gp) 00000000 00000000 NOTYPE UND foo # GOT-NEXT: -32716(gp) 00000000 00000000 NOTYPE UND foo
.text .text
.globl __start .globl __start

View File

@ -3,31 +3,30 @@
# we use our own value. # we use our own value.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: ld.lld -shared -o %t.so %t.o %S/Inputs/mips-gp-disp.so # RUN: echo "SECTIONS { \
# RUN: llvm-readobj --symbols %t.so | FileCheck -check-prefix=INT-SO %s # RUN: . = 0x1000; .text ALIGN(0x1000) : { *(.text) } \
# RUN: llvm-readobj --symbols %S/Inputs/mips-gp-disp.so \ # RUN: . = 0x30000; .got : { *(.got) } \
# RUN: }" > %t.script
# RUN: ld.lld -shared --script %t.script -o %t.so %t.o %S/Inputs/mips-gp-disp.so
# RUN: llvm-readelf --symbols %t.so | FileCheck -check-prefix=INT-SO %s
# RUN: llvm-readelf --symbols %S/Inputs/mips-gp-disp.so \
# RUN: | FileCheck -check-prefix=EXT-SO %s # RUN: | FileCheck -check-prefix=EXT-SO %s
# RUN: llvm-objdump -d -t --no-show-raw-insn %t.so | FileCheck -check-prefix=DIS %s # RUN: llvm-objdump -d -t --no-show-raw-insn %t.so | FileCheck -check-prefix=DIS %s
# RUN: llvm-readobj -r %t.so | FileCheck -check-prefix=REL %s # RUN: llvm-readelf -r %t.so | FileCheck -check-prefix=REL %s
# INT-SO: Name: _gp_disp # INT-SO: 00000000 0 NOTYPE LOCAL HIDDEN ABS _gp_disp
# INT-SO-NEXT: Value: # EXT-SO: 00020000 0 NOTYPE GLOBAL DEFAULT 9 _gp_disp
# INT-SO-NEXT: Size:
# INT-SO-NEXT: Binding: Local
# EXT-SO: Name: _gp_disp
# EXT-SO-NEXT: Value: 0x20000
# DIS: Disassembly of section .text: # DIS: Disassembly of section .text:
# DIS-EMPTY: # DIS-EMPTY:
# DIS-NEXT: __start: # DIS-NEXT: __start:
# DIS-NEXT: 10000: lui $8, 1 # DIS-NEXT: lui $8, 3
# DIS-NEXT: 10004: addi $8, $8, 32752 # DIS-NEXT: addi $8, $8, 24560
# ^-- 0x37ff0 & 0xffff # ^-- (_gp - __start) & 0xffff
# DIS: 00027ff0 .got 00000000 .hidden _gp # DIS: 00037ff0 .got 00000000 .hidden _gp
# DIS: 00002000 .text 00000000 __start
# REL: Relocations [ # REL: There are no relocations in this file
# REL-NEXT: ]
.text .text
.globl __start .globl __start

View File

@ -2,16 +2,19 @@
# Check handling of relocations against __gnu_local_gp symbol. # Check handling of relocations against __gnu_local_gp symbol.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: ld.lld -o %t.exe %t.o # RUN: echo "SECTIONS { \
# RUN: . = 0x10000; .text ALIGN(0x1000) : { *(.text) } \
# RUN: . = 0x30000; .got : { *(.got) } \
# RUN: }" > %t.script
# RUN: ld.lld --script %t.script -o %t.exe %t.o
# RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck %s # RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck %s
# CHECK: Disassembly of section .text: # CHECK: __start:
# CHECK-EMPTY: # CHECK-NEXT: lui $8, 3
# CHECK-NEXT: __start: # CHECK-NEXT: addi $8, $8, 32752
# CHECK-NEXT: 20000: lui $8, 3
# CHECK-NEXT: 20004: addi $8, $8, 32752
# CHECK: 00037ff0 .got 00000000 .hidden _gp # CHECK: 00037ff0 .got 00000000 .hidden _gp
# CHECK: 00011000 .text 00000000 __start
.text .text
.globl __start .globl __start

View File

@ -19,8 +19,8 @@
# CHECK-NEXT: SHF_MIPS_GPREL # CHECK-NEXT: SHF_MIPS_GPREL
# CHECK-NEXT: SHF_WRITE # CHECK-NEXT: SHF_WRITE
# CHECK-NEXT: ] # CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x20000 # CHECK-NEXT: Address:
# CHECK-NEXT: Offset: 0x20000 # CHECK-NEXT: Offset:
# CHECK: } # CHECK: }
# CHECK: Section { # CHECK: Section {
# CHECK-NEXT: Index: # CHECK-NEXT: Index:
@ -31,6 +31,6 @@
# CHECK-NEXT: SHF_MIPS_GPREL # CHECK-NEXT: SHF_MIPS_GPREL
# CHECK-NEXT: SHF_WRITE # CHECK-NEXT: SHF_WRITE
# CHECK-NEXT: ] # CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x20008 # CHECK-NEXT: Address:
# CHECK-NEXT: Offset: 0x20008 # CHECK-NEXT: Offset:
# CHECK: } # CHECK: }

View File

@ -5,23 +5,24 @@
# RUN: ld.lld -r -o %t-rel.o %t.o # RUN: ld.lld -r -o %t-rel.o %t.o
# RUN: llvm-readobj --mips-reginfo %t-rel.o | FileCheck --check-prefix=REL %s # RUN: llvm-readobj --mips-reginfo %t-rel.o | FileCheck --check-prefix=REL %s
# RUN: ld.lld -shared -o %t.so %S/Inputs/mips-gp0-non-zero.o # RUN: echo "SECTIONS { \
# RUN: llvm-readobj --mips-reginfo %t.so | FileCheck --check-prefix=DSO %s # RUN: .rodata ALIGN(0x1000) : { *(.rodata) } \
# RUN: . = 0x20000; .text : { *(.text) } \
# RUN: }" > %t.script
# RUN: ld.lld -shared --script %t.script -o %t.so %S/Inputs/mips-gp0-non-zero.o
# RUN: llvm-objdump -s -t %t.so | FileCheck --check-prefix=DUMP %s # RUN: llvm-objdump -s -t %t.so | FileCheck --check-prefix=DUMP %s
# REL: GP: 0x0 # REL: GP: 0x0
# DSO: GP: 0x27FF0
# DUMP: Contents of section .rodata: # DUMP: Contents of section .rodata:
# DUMP: {{[0-9a-f]+}} ffff0004 ffff0008 # DUMP: 1000 fffffff4 fffffff8
# ^ 0x10004 + 0x7ff0 - 0x27ff0 # ^ 0x20004 + 0x7ff0 - 0x28000
# ^ 0x10008 + 0x7ff0 - 0x27ff0 # ^ 0x20008 + 0x7ff0 - 0x28000
# DUMP: SYMBOL TABLE: # DUMP: SYMBOL TABLE:
# DUMP: 00010008 .text 00000000 bar # DUMP: 00020008 .text 00000000 bar
# DUMP: 00010004 .text 00000000 foo # DUMP: 00020004 .text 00000000 foo
# DUMP: 00027ff0 .got 00000000 .hidden _gp # DUMP: 00028000 .got 00000000 .hidden _gp
.text .text
.global __start .global __start

View File

@ -2,7 +2,11 @@
# Check R_MIPS_GPREL32 relocation calculation. # Check R_MIPS_GPREL32 relocation calculation.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: ld.lld -shared -o %t.so %t.o # RUN: echo "SECTIONS { \
# RUN: .rodata ALIGN(0x1000) : { *(.rodata) } \
# RUN: . = 0x20000; .text : { *(.text) } \
# RUN: }" > %t.script
# RUN: ld.lld -shared --script %t.script -o %t.so %t.o
# RUN: llvm-objdump -s -section=.rodata -t %t.so | FileCheck %s # RUN: llvm-objdump -s -section=.rodata -t %t.so | FileCheck %s
.text .text
@ -20,11 +24,11 @@ v1:
.gpword bar .gpword bar
# CHECK: Contents of section .rodata: # CHECK: Contents of section .rodata:
# CHECK: {{[0-9a-f]+}} fffe8014 fffe8018 # CHECK: 1000 ffff8004 ffff8008
# ^ 0x10004 - 0x27ff0 # ^ 0x20004 - 0x28000
# ^ 0x10008 - 0x27ff0 # ^ 0x20008 - 0x28000
# CHECK: SYMBOL TABLE: # CHECK: SYMBOL TABLE:
# CHECK: 00010008 .text 00000000 bar # CHECK: 00020008 .text 00000000 bar
# CHECK: 00010004 .text 00000000 foo # CHECK: 00020004 .text 00000000 foo
# CHECK: 00027ff0 .got 00000000 .hidden _gp # CHECK: 00028000 .got 00000000 .hidden _gp

View File

@ -4,7 +4,7 @@
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \ # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
# RUN: %S/Inputs/mips-dynamic.s -o %t2.o # RUN: %S/Inputs/mips-dynamic.s -o %t2.o
# RUN: ld.lld %t1.o %t2.o -o %t.exe # RUN: ld.lld %t1.o %t2.o %t.script -o %t.exe
# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s # RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s
.global __start .global __start
@ -14,7 +14,10 @@ __start:
lui $7, %highest(_foo+0x300047FFF7FF8) lui $7, %highest(_foo+0x300047FFF7FF8)
ld $7, %higher (_foo+0x300047FFF7FF8)($7) ld $7, %higher (_foo+0x300047FFF7FF8)($7)
# CHECK: 20000: lui $6, 3 # CHECK: __start:
# CHECK-NEXT: 20004: daddiu $6, $6, 5 # CHECK-NEXT: lui $6, 3
# CHECK-NEXT: 20008: lui $7, 3 # CHECK-NEXT: daddiu $6, $6, 5
# CHECK-NEXT: 2000c: ld $7, 5($7) # CHECK-NEXT: lui $7, 3
# CHECK-NEXT: ld $7, 5($7)
# CHECK-EMPTY:
# CHECK-NEXT: _foo:

View File

@ -1,13 +1,17 @@
# REQUIRES: mips # REQUIRES: mips
# Check R_MIPS_HI16 / LO16 relocations calculation against _gp_disp. # Check R_MIPS_HI16 / LO16 relocations calculation against _gp_disp.
# RUN: echo "SECTIONS { \
# RUN: . = 0x10000; .text ALIGN(0x1000) : { *(.text) } \
# RUN: . = 0x30000; .got : { *(.got) } \
# RUN: }" > %t.script
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
# RUN: %S/Inputs/mips-dynamic.s -o %t2.o # RUN: %S/Inputs/mips-dynamic.s -o %t2.o
# RUN: ld.lld %t1.o %t2.o -o %t.exe # RUN: ld.lld %t1.o %t2.o --script %t.script -o %t.exe
# RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck -check-prefix=EXE %s # RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck %s
# RUN: ld.lld %t1.o %t2.o -shared -o %t.so # RUN: ld.lld %t1.o %t2.o -shared --script %t.script -o %t.so
# RUN: llvm-objdump -d -t --no-show-raw-insn %t.so | FileCheck -check-prefix=SO %s # RUN: llvm-objdump -d -t --no-show-raw-insn %t.so | FileCheck %s
.text .text
.globl __start .globl __start
@ -19,38 +23,20 @@ bar:
lui $t0,%hi(_gp_disp) lui $t0,%hi(_gp_disp)
addi $t0,$t0,%lo(_gp_disp) addi $t0,$t0,%lo(_gp_disp)
# EXE: Disassembly of section .text: # CHECK: Disassembly of section .text:
# EXE-EMPTY: # CHECK-EMPTY:
# EXE-NEXT: __start: # CHECK-NEXT: __start:
# EXE-NEXT: 20000: lui $8, 2 # CHECK-NEXT: 11000: lui $8, 2
# ^-- %hi(0x47ff0-0x20000) # ^-- %hi(0x37ff0-0x11000)
# EXE-NEXT: 20004: addi $8, $8, -32768 # CHECK-NEXT: 11004: addi $8, $8, 28656
# ^-- %lo(0x38000-0x20004+4) # ^-- %lo(0x37ff0-0x11004+4)
# EXE: bar: # CHECK: bar:
# EXE-NEXT: 2000c: lui $8, 1 # CHECK-NEXT: 1100c: lui $8, 2
# ^-- %hi(0x38000-0x2000c) # ^-- %hi(0x37ff0-0x1100c)
# EXE-NEXT: 20010: addi $8, $8, 32756 # CHECK-NEXT: 11010: addi $8, $8, 28644
# ^-- %lo(0x38000-0x20010+4) # ^-- %lo(0x37ff0-0x11010+4)
# EXE: SYMBOL TABLE: # CHECK: SYMBOL TABLE:
# EXE: 0002000c .text 00000000 bar # CHECK: 0001100c .text 00000000 bar
# EXE: 00038000 .got 00000000 .hidden _gp # CHECK: 00037ff0 .got 00000000 .hidden _gp
# EXE: 00020000 .text 00000000 __start # CHECK: 00011000 .text 00000000 __start
# SO: Disassembly of section .text:
# SO-EMPTY:
# SO-NEXT: __start:
# SO-NEXT: 10000: lui $8, 2
# ^-- %hi(0x28000-0x10000)
# SO-NEXT: 10004: addi $8, $8, -32768
# ^-- %lo(0x28000-0x10004+4)
# SO: bar:
# SO-NEXT: 1000c: lui $8, 1
# ^-- %hi(0x28000-0x1000c)
# SO-NEXT: 10010: addi $8, $8, 32756
# ^-- %lo(0x28000-0x10010+4)
# SO: SYMBOL TABLE:
# SO: 0001000c .text 00000000 bar
# SO: 00028000 .got 00000000 .hidden _gp
# SO: 00010000 .text 00000000 __start

View File

@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe 2>&1 | FileCheck -check-prefix=WARN %s # RUN: ld.lld %t.o -o %t.exe 2>&1 | FileCheck -check-prefix=WARN %s
# RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck %s # RUN: llvm-objdump -d -t --print-imm-hex --no-show-raw-insn %t.exe | FileCheck %s
.text .text
.globl __start .globl __start
@ -15,14 +15,12 @@ _label:
# WARN: can't find matching R_MIPS_LO16 relocation for R_MIPS_HI16 # WARN: can't find matching R_MIPS_LO16 relocation for R_MIPS_HI16
# CHECK: Disassembly of section .text: # CHECK: __start:
# CHECK-EMPTY: # CHECK-NEXT: lui $8, 0x3
# CHECK-NEXT: __start: # ^-- %hi(__start) w/o addend
# CHECK-NEXT: 20000: lui $8, 3 # CHECK-NEXT: addi $8, $8, 0x[[VAL:[0-9a-f]+]]
# ^-- %hi(__start) w/o addend # ^-- %lo(_label)
# CHECK-NEXT 20004: addi $8, $8, 8
# ^-- %lo(_label)
# CHECK: SYMBOL TABLE: # CHECK: SYMBOL TABLE:
# CHECK: 00020008 .text 00000000 _label # CHECK: 00020{{0*}}[[VAL]] .text 00000000 _label
# CHECK: 00020000 .text 00000000 __start # CHECK: 00020{{.*}} .text 00000000 __start

View File

@ -2,8 +2,9 @@
# Check R_MIPS_HI16 / LO16 relocations calculation. # Check R_MIPS_HI16 / LO16 relocations calculation.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe # RUN: echo "SECTIONS { . = 0x20000; .text ALIGN(0x1000) : { *(.text) } }" > %t.script
# RUN: llvm-objdump -d -t %t.exe | FileCheck %s # RUN: ld.lld %t.o --script %t.script -o %t.exe
# RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck %s
.text .text
.globl __start .globl __start
@ -29,25 +30,23 @@ l1:
g1: g1:
.word 0 .word 0
# CHECK: Disassembly of section .text: # CHECK: __start:
# CHECK-EMPTY: # CHECK-NEXT: 21000: lui $8, 2
# CHECK-NEXT: __start: # ^-- %hi(__start+4)
# CHECK-NEXT: 20000: 3c 08 00 02 lui $8, 2 # CHECK-NEXT: 21004: lui $9, 2
# ^-- %hi(__start+4) # ^-- %hi(g1+8)
# CHECK-NEXT: 20004: 3c 09 00 03 lui $9, 3 # CHECK-NEXT: 21008: addi $8, $8, 4100
# ^-- %hi(g1+8) # ^-- %lo(__start+4)
# CHECK-NEXT: 20008: 21 08 00 04 addi $8, $8, 4 # CHECK-NEXT: 2100c: addi $8, $8, 4140
# ^-- %lo(__start+4) # ^-- %lo(g1+8)
# CHECK-NEXT: 2000c: 21 08 00 0c addi $8, $8, 12 # CHECK-NEXT: 21010: lui $8, 3
# ^-- %lo(g1+8) # ^-- %hi(l1+0x10000-4)
# CHECK-NEXT: 20010: 3c 08 00 04 lui $8, 4 # CHECK-NEXT: 21014: lui $9, 4
# ^-- %hi(l1+0x10000-4) # ^-- %hi(l1+0x20000-4)
# CHECK-NEXT: 20014: 3c 09 00 05 lui $9, 5 # CHECK-NEXT: 21018: addi $8, $8, 4124
# ^-- %hi(l1+0x20000-4) # ^-- %lo(l1-4)
# CHECK-NEXT: 20018: 21 08 ff fc addi $8, $8, -4
# ^-- %lo(l1-4)
# CHECK: SYMBOL TABLE: # CHECK: SYMBOL TABLE:
# CHECK: 0030000 l O .data 00000004 l1 # CHECK: 0021020 l O .data 00000004 l1
# CHECK: 0020000 .text 00000000 __start # CHECK: 0021000 .text 00000000 __start
# CHECK: 0030004 g O .data 00000004 g1 # CHECK: 0021024 g O .data 00000004 g1

20
lld/test/ELF/mips-jalr.s Normal file
View File

@ -0,0 +1,20 @@
# REQUIRES: mips
# Check that lld ignores R_MIPS_JALR relocation for now.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe
# RUN: llvm-readelf -r %t.o | FileCheck -check-prefix=REL %s
# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s
# REL: R_MIPS_CALL16 {{.*}} foo
# REL: R_MIPS_JALR {{.*}} foo
# CHECK: jalr $25
.text
.global __start
.option pic2
__start:
jal foo
foo:
nop

View File

@ -1,51 +0,0 @@
# Check that lld ignores R_MIPS_JALR relocation for now.
# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld %t.o -o %t.so -shared
# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s
# RUN: llvm-readobj -r %t.so | FileCheck -check-prefix=REL %s
# REQUIRES: mips
# CHECK: 10000: jalr $25
# REL: Relocations [
# REL-NEXT: ]
!ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 16
Content: "09f82003"
# ^-- jalr T1
- Name: .rel.text
Type: SHT_REL
Link: .symtab
Info: .text
Relocations:
- Offset: 0
Symbol: T1
Type: R_MIPS_JALR
Symbols:
- Name: T1
Type: STT_FUNC
Section: .text
Value: 0
Size: 4
- Name: __start
Type: STT_FUNC
Section: .text
Value: 0
Size: 4
Binding: STB_GLOBAL

View File

@ -6,25 +6,27 @@
# RUN: %p/Inputs/mips-mgot-1.s -o %t1.o # RUN: %p/Inputs/mips-mgot-1.s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
# RUN: %p/Inputs/mips-mgot-2.s -o %t2.o # RUN: %p/Inputs/mips-mgot-2.s -o %t2.o
# RUN: ld.lld -shared -mips-got-size 52 %t0.o %t1.o %t2.o -o %t.so # RUN: echo "SECTIONS { \
# RUN: . = 0x10000; .text : { *(.text) } \
# RUN: . = 0x70000; .got : { *(.got) } \
# RUN: }" > %t.script
# RUN: ld.lld -shared -mips-got-size 52 --script %t.script %t0.o %t1.o %t2.o -o %t.so
# RUN: llvm-objdump -s -section=.got -t %t.so | FileCheck %s # RUN: llvm-objdump -s -section=.got -t %t.so | FileCheck %s
# RUN: llvm-readobj -r --dyn-syms --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s # RUN: llvm-readobj -r --dyn-syms --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s
# CHECK: Contents of section .got: # CHECK: Contents of section .got:
# CHECK-NEXT: 70000 00000000 80000000 00010000 00010030 # CHECK-NEXT: 70000 00000000 80000000 [[FOO0:[0-9a-f]+]] [[FOO2:[0-9a-f]+]]
# CHECK-NEXT: 70010 00000000 00000004 00030000 00040000 # CHECK-NEXT: 70010 00000000 00000004 00010000 00020000
# CHECK-NEXT: 70020 00050000 00060000 00070000 00080000 # CHECK-NEXT: 70020 00030000 00040000 00050000 00060000
# CHECK-NEXT: 70030 00000000 00000000 00000000 00000000 # CHECK-NEXT: 70030 00000000 00000000 00000000 00000000
# CHECK-NEXT: 70040 00000000 00000000 00000000 # CHECK-NEXT: 70040 00000000 00000000 00000000
# CHECK: SYMBOL TABLE: # CHECK: SYMBOL TABLE:
# CHECK: 00000000 l O .tdata 00000000 loc0 # CHECK: 00000000 l O .tdata 00000000 loc0
# CHECK: 00010000 .text 00000000 foo0 # CHECK: [[FOO0]] .text 00000000 foo0
# CHECK: 00000000 g O .tdata 00000000 tls0 # CHECK: 00000000 g O .tdata 00000000 tls0
# CHECK: 00010020 .text 00000000 foo1
# CHECK: 00000004 g O .tdata 00000000 tls1 # CHECK: 00000004 g O .tdata 00000000 tls1
# CHECK: 00010030 .text 00000000 foo2 # CHECK: [[FOO2]] .text 00000000 foo2
# CHECK: 00000008 g O .tdata 00000000 tls2
# GOT: Relocations [ # GOT: Relocations [
# GOT-NEXT: Section (7) .rel.dyn { # GOT-NEXT: Section (7) .rel.dyn {
@ -48,11 +50,11 @@
# GOT: DynamicSymbols [ # GOT: DynamicSymbols [
# GOT: Symbol { # GOT: Symbol {
# GOT: Name: foo0 # GOT: Name: foo0
# GOT-NEXT: Value: 0x10000 # GOT-NEXT: Value: 0x[[FOO0:[0-9A-F]+]]
# GOT: } # GOT: }
# GOT-NEXT: Symbol { # GOT-NEXT: Symbol {
# GOT-NEXT: Name: foo2 # GOT-NEXT: Name: foo2
# GOT-NEXT: Value: 0x10030 # GOT-NEXT: Value: 0x[[FOO2:[0-9A-F]+]]
# GOT: } # GOT: }
# GOT-NEXT: ] # GOT-NEXT: ]
@ -78,8 +80,8 @@
# GOT-NEXT: Entry { # GOT-NEXT: Entry {
# GOT-NEXT: Address: # GOT-NEXT: Address:
# GOT-NEXT: Access: -32744 # GOT-NEXT: Access: -32744
# GOT-NEXT: Initial: 0x10000 # GOT-NEXT: Initial: 0x[[FOO0]]
# GOT-NEXT: Value: 0x10000 # GOT-NEXT: Value: 0x[[FOO0]]
# GOT-NEXT: Type: None # GOT-NEXT: Type: None
# GOT-NEXT: Section: .text # GOT-NEXT: Section: .text
# GOT-NEXT: Name: foo0 # GOT-NEXT: Name: foo0
@ -87,8 +89,8 @@
# GOT-NEXT: Entry { # GOT-NEXT: Entry {
# GOT-NEXT: Address: # GOT-NEXT: Address:
# GOT-NEXT: Access: -32740 # GOT-NEXT: Access: -32740
# GOT-NEXT: Initial: 0x10030 # GOT-NEXT: Initial: 0x[[FOO2]]
# GOT-NEXT: Value: 0x10030 # GOT-NEXT: Value: 0x[[FOO2]]
# GOT-NEXT: Type: None # GOT-NEXT: Type: None
# GOT-NEXT: Section: .text # GOT-NEXT: Section: .text
# GOT-NEXT: Name: foo2 # GOT-NEXT: Name: foo2