From: Simon Atanasyan Date: Sat, 7 Sep 2019 15:44:40 +0000 (+0000) Subject: [mips] Make another set of test cases more tolerant to exact symbol addresses. NFC X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fcef13344db8883d2ba5adfca1499b605a136c5b;p=platform%2Fupstream%2Fllvm.git [mips] Make another set of test cases more tolerant to exact symbol addresses. NFC llvm-svn: 371313 --- diff --git a/lld/test/ELF/mips-got-relocs.s b/lld/test/ELF/mips-got-relocs.s index f056055..cad6783 100644 --- a/lld/test/ELF/mips-got-relocs.s +++ b/lld/test/ELF/mips-got-relocs.s @@ -1,26 +1,31 @@ # REQUIRES: mips # 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: 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: | 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-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: | 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: 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: | 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: 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: | FileCheck -check-prefixes=ELF,DSO %s +# RUN: | FileCheck -check-prefix=ELF %s # RUN: llvm-objdump -d %t-el.so | FileCheck -check-prefix=DIS %s .text @@ -30,8 +35,6 @@ __start: .data .globl v1 - .type v1,@object - .size v1,4 v1: .word 0 @@ -51,16 +54,13 @@ v1: # ELF-NEXT: Value: 0x[[V1:[0-9A-F]+]] # # ELF: {{.*}} GOT { -# EXE-NEXT: Canonical gp value: 0x38000 -# DSO-NEXT: Canonical gp value: 0x28000 +# ELF-NEXT: Canonical gp value: 0x37FF0 # # ELF: Entry { -# EXE: Address: 0x30018 -# DSO: Address: 0x20018 +# ELF: Address: 0x30008 # ELF-NEXT: Access: -32744 # ELF-NEXT: Initial: 0x[[V1]] # "v1 GOT entry address" - _gp -# exe: 0x30018 - 0x38000 = -0x7fe8 == 0x8018 == 32792 -# dso: 0x20018 - 0x28000 = -0x7fe8 == 0x8018 == 32792 -# DIS: {{.*}} lui $2, 32792 +# 0x30008 - 0x37FF0 = -0x7fe8 == 0x8018 == 32792 +# DIS: lui $2, 32792 diff --git a/lld/test/ELF/mips-got-weak.s b/lld/test/ELF/mips-got-weak.s index 5e43bf3..7d13f7d 100644 --- a/lld/test/ELF/mips-got-weak.s +++ b/lld/test/ELF/mips-got-weak.s @@ -3,118 +3,42 @@ # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o # 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: 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 -# CHECK: Relocations [ -# CHECK-NEXT: ] - -# NOSYM: Symbol { -# NOSYM: Name: foo -# NOSYM-NEXT: Value: 0x20000 -# NOSYM-NEXT: Size: 0 -# NOSYM-NEXT: Binding: Weak -# NOSYM-NEXT: Type: None -# NOSYM-NEXT: Other: 0 -# NOSYM-NEXT: Section: .data -# NOSYM-NEXT: } - -# CHECK: Symbol { -# CHECK: Name: bar -# CHECK-NEXT: Value: 0x0 -# CHECK-NEXT: Size: 0 -# CHECK-NEXT: Binding: Weak -# CHECK-NEXT: Type: None -# CHECK-NEXT: Other: 0 -# CHECK-NEXT: Section: Undefined -# CHECK-NEXT: } - -# NOSYM: Symbol { -# NOSYM: Name: sym -# NOSYM-NEXT: Value: 0x20004 -# NOSYM-NEXT: Size: 0 -# NOSYM-NEXT: Binding: Global -# NOSYM-NEXT: Type: None -# NOSYM-NEXT: Other: 0 -# NOSYM-NEXT: Section: .data -# NOSYM-NEXT: } - -# CHECK: 0x70000011 MIPS_SYMTABNO 4 - -# SYM: 0x7000000A MIPS_LOCAL_GOTNO 4 -# SYM: 0x70000013 MIPS_GOTSYM 0x3 - -# NOSYM: 0x7000000A MIPS_LOCAL_GOTNO 2 -# NOSYM: 0x70000013 MIPS_GOTSYM 0x1 - -# 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: } +# CHECK: There are no relocations in this file. + +# CHECK: Symbol table '.dynsym' +# CHECK-DAG: [[FOO:[0-9a-f]+]] 0 NOTYPE WEAK DEFAULT 8 foo +# CHECK-DAG: 00000000 0 NOTYPE WEAK DEFAULT UND bar +# CHECK-DAG: [[SYM:[0-9a-f]+]] 0 NOTYPE GLOBAL DEFAULT 8 sym + +# CHECK: Dynamic section +# CHECK: (MIPS_SYMTABNO) 4 +# NOSYM: (MIPS_LOCAL_GOTNO) 2 +# NOSYM: (MIPS_GOTSYM) 0x1 +# SYM: (MIPS_LOCAL_GOTNO) 4 +# SYM: (MIPS_GOTSYM) 0x3 + +# NOSYM: Primary GOT: +# NOSYM-NOT: Local entries: +# NOSYM: Global entries: +# NOSYM-NEXT: Access Initial Sym.Val. Type Ndx Name +# NOSYM-NEXT: -32744(gp) [[FOO]] [[FOO]] NOTYPE 8 foo +# NOSYM-NEXT: -32740(gp) 00000000 00000000 NOTYPE UND bar +# NOSYM-NEXT: -32736(gp) [[SYM]] [[SYM]] NOTYPE 8 sym + +# SYM: Primary GOT: +# SYM: Local entries: +# SYM-NEXT: Access Initial +# SYM-NEXT: -32744(gp) [[FOO]] +# SYM-NEXT: -32740(gp) [[SYM]] +# SYM: Global entries: +# SYM-NEXT: Access Initial Sym.Val. Type Ndx Name +# SYM-NEXT: -32736(gp) 00000000 00000000 NOTYPE UND bar .text .global sym diff --git a/lld/test/ELF/mips-got16-relocatable.s b/lld/test/ELF/mips-got16-relocatable.s index ee7781f..5b8e0e8 100644 --- a/lld/test/ELF/mips-got16-relocatable.s +++ b/lld/test/ELF/mips-got16-relocatable.s @@ -6,27 +6,32 @@ # 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: 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-EMPTY: # OBJ-NEXT: .text: -# OBJ-NEXT: 0: lw $25, 0($gp) -# OBJ-NEXT: 00000000: R_MIPS_GOT16 .data -# OBJ-NEXT: 4: addiu $4, $25, 0 -# OBJ-NEXT: 00000004: R_MIPS_LO16 .data -# OBJ: 10: lw $25, 0($gp) -# OBJ-NEXT: 00000010: R_MIPS_GOT16 .data -# OBJ-NEXT: 14: addiu $4, $25, 16 -# OBJ-NEXT: 00000014: R_MIPS_LO16 .data +# OBJ-NEXT: lw $25, 0($gp) +# OBJ-NEXT: 00000000: R_MIPS_GOT16 .data +# OBJ-NEXT: addiu $4, $25, 0 +# OBJ-NEXT: 00000004: R_MIPS_LO16 .data +# OBJ: lw $25, 0($gp) +# OBJ-NEXT: 00000010: R_MIPS_GOT16 .data +# OBJ-NEXT: addiu $4, $25, 16 +# OBJ-NEXT: 00000014: R_MIPS_LO16 .data # SO: Disassembly of section .text: # SO-EMPTY: # SO-NEXT: .text: -# SO-NEXT: 10000: lw $25, -32744($gp) -# SO-NEXT: 10004: addiu $4, $25, 0 -# SO: 10010: lw $25, -32744($gp) -# SO-NEXT: 10014: addiu $4, $25, 16 +# SO-NEXT: lw $25, -0x7fe8($gp) +# SO-NEXT: addiu $4, $25, 0x[[D1:[0-9a-f]+]] +# SO: lw $25, -0x7fe8($gp) +# SO-NEXT: addiu $4, $25, 0x[[D2:[0-9a-f]+]] + +# SO: SYMBOL TABLE +# SO: [[D1]] +# SO: [[D2]] .text lw $t9, %got(.data)($gp) diff --git a/lld/test/ELF/mips-got16.s b/lld/test/ELF/mips-got16.s index 56b9ea0..18cfe43 100644 --- a/lld/test/ELF/mips-got16.s +++ b/lld/test/ELF/mips-got16.s @@ -2,52 +2,54 @@ # Check R_MIPS_GOT16 relocation calculation. # 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-readelf -r --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s -# CHECK: Disassembly of section .text: -# CHECK-EMPTY: -# CHECK-NEXT: __start: -# CHECK-NEXT: 10000: lw $8, -32744($gp) -# CHECK-NEXT: 10004: addi $8, $8, 44 -# CHECK-NEXT: 10008: lw $8, -32732($gp) -# CHECK-NEXT: 1000c: addi $8, $8, -28672 -# CHECK-NEXT: 10010: lw $8, -32728($gp) -# CHECK-NEXT: 10014: addi $8, $8, -28668 -# CHECK-NEXT: 10018: lw $8, -32728($gp) -# CHECK-NEXT: 1001c: addi $8, $8, 4100 -# CHECK-NEXT: 10020: lw $8, -32720($gp) -# CHECK-NEXT: 10024: addi $8, $8, 4104 -# CHECK-NEXT: 10028: lw $8, -32716($gp) +# CHECK: __start: +# CHECK-NEXT: lw $8, -32744($gp) +# CHECK-NEXT: addi $8, $8, 8236 +# CHECK-NEXT: lw $8, -32732($gp) +# CHECK-NEXT: addi $8, $8, -16384 +# CHECK-NEXT: lw $8, -32728($gp) +# CHECK-NEXT: addi $8, $8, -16380 +# CHECK-NEXT: lw $8, -32728($gp) +# CHECK-NEXT: addi $8, $8, 16388 +# CHECK-NEXT: lw $8, -32720($gp) +# CHECK-NEXT: addi $8, $8, 16392 +# CHECK-NEXT: lw $8, -32716($gp) # # CHECK: SYMBOL TABLE: -# CHECK: 00041008 .data 00000000 .hidden bar +# CHECK: 00024008 .data 00000000 .hidden bar # CHECK: 00000000 *UND* 00000000 foo # GOT: There are no relocations in this file. # GOT: Local entries: -# GOT-NEXT: Address Access Initial -# GOT-NEXT: 00041018 -32744(gp) 00010000 -# ^-- (0x1002c + 0x8000) & ~0xffff -# GOT-NEXT: 0004101c -32740(gp) 00020000 -# ^-- redundant unused entry -# GOT-NEXT: 00041020 -32736(gp) 00020000 -# ^-- redundant unused entry -# GOT-NEXT: 00041024 -32732(gp) 00030000 -# ^-- (0x29000 + 0x8000) & ~0xffff -# GOT-NEXT: 00041028 -32728(gp) 00040000 -# ^-- (0x29000 + 0x10004 + 0x8000) & ~0xffff -# ^-- (0x29000 + 0x18004 + 0x8000) & ~0xffff -# GOT-NEXT: 0004102c -32724(gp) 00050000 -# ^-- redundant unused entry -# GOT-NEXT: 00041030 -32720(gp) 00041008 -# ^-- 'bar' address +# GOT-NEXT: Access Initial +# GOT-NEXT: -32744(gp) 00000000 +# ^-- (0x2000 + 0x8000) & ~0xffff +# GOT-NEXT: -32740(gp) 00010000 +# ^-- redundant unused entry +# GOT-NEXT: -32736(gp) 00000000 +# ^-- redundant unused entry +# GOT-NEXT: -32732(gp) 00010000 +# ^-- (0x3000 + 0x9000 + 0x8000) & ~0xffff +# GOT-NEXT: -32728(gp) 00020000 +# ^-- (0x3000 + 0x9000 + 0x10004 + 0x8000) & ~0xffff +# ^-- (0x3000 + 0x9000 + 0x18004 + 0x8000) & ~0xffff +# GOT-NEXT: -32724(gp) 00030000 +# ^-- redundant unused entry +# GOT-NEXT: -32720(gp) 00024008 +# ^-- 'bar' address # GOT-EMPTY: # GOT-NEXT: Global entries: -# GOT-NEXT: Address Access Initial Sym.Val. Type Ndx Name -# GOT-NEXT: 00041034 -32716(gp) 00000000 00000000 NOTYPE UND foo +# GOT-NEXT: Access Initial Sym.Val. Type Ndx Name +# GOT-NEXT: -32716(gp) 00000000 00000000 NOTYPE UND foo .text .globl __start diff --git a/lld/test/ELF/mips-gp-disp.s b/lld/test/ELF/mips-gp-disp.s index ff0c563..2f8c625 100644 --- a/lld/test/ELF/mips-gp-disp.s +++ b/lld/test/ELF/mips-gp-disp.s @@ -3,31 +3,30 @@ # we use our own value. # 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: llvm-readobj --symbols %t.so | FileCheck -check-prefix=INT-SO %s -# RUN: llvm-readobj --symbols %S/Inputs/mips-gp-disp.so \ +# RUN: echo "SECTIONS { \ +# RUN: . = 0x1000; .text ALIGN(0x1000) : { *(.text) } \ +# 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: 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-NEXT: Value: -# INT-SO-NEXT: Size: -# INT-SO-NEXT: Binding: Local - -# EXT-SO: Name: _gp_disp -# EXT-SO-NEXT: Value: 0x20000 +# INT-SO: 00000000 0 NOTYPE LOCAL HIDDEN ABS _gp_disp +# EXT-SO: 00020000 0 NOTYPE GLOBAL DEFAULT 9 _gp_disp # DIS: Disassembly of section .text: # DIS-EMPTY: # DIS-NEXT: __start: -# DIS-NEXT: 10000: lui $8, 1 -# DIS-NEXT: 10004: addi $8, $8, 32752 -# ^-- 0x37ff0 & 0xffff -# DIS: 00027ff0 .got 00000000 .hidden _gp +# DIS-NEXT: lui $8, 3 +# DIS-NEXT: addi $8, $8, 24560 +# ^-- (_gp - __start) & 0xffff +# DIS: 00037ff0 .got 00000000 .hidden _gp +# DIS: 00002000 .text 00000000 __start -# REL: Relocations [ -# REL-NEXT: ] +# REL: There are no relocations in this file .text .globl __start diff --git a/lld/test/ELF/mips-gp-local.s b/lld/test/ELF/mips-gp-local.s index 5d9520d..650eabb 100644 --- a/lld/test/ELF/mips-gp-local.s +++ b/lld/test/ELF/mips-gp-local.s @@ -2,16 +2,19 @@ # Check handling of relocations against __gnu_local_gp symbol. # 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 -# CHECK: Disassembly of section .text: -# CHECK-EMPTY: -# CHECK-NEXT: __start: -# CHECK-NEXT: 20000: lui $8, 3 -# CHECK-NEXT: 20004: addi $8, $8, 32752 +# CHECK: __start: +# CHECK-NEXT: lui $8, 3 +# CHECK-NEXT: addi $8, $8, 32752 # CHECK: 00037ff0 .got 00000000 .hidden _gp +# CHECK: 00011000 .text 00000000 __start .text .globl __start diff --git a/lld/test/ELF/mips-gprel-sec.s b/lld/test/ELF/mips-gprel-sec.s index e9efa02..b44703d 100644 --- a/lld/test/ELF/mips-gprel-sec.s +++ b/lld/test/ELF/mips-gprel-sec.s @@ -19,8 +19,8 @@ # CHECK-NEXT: SHF_MIPS_GPREL # CHECK-NEXT: SHF_WRITE # CHECK-NEXT: ] -# CHECK-NEXT: Address: 0x20000 -# CHECK-NEXT: Offset: 0x20000 +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: # CHECK: } # CHECK: Section { # CHECK-NEXT: Index: @@ -31,6 +31,6 @@ # CHECK-NEXT: SHF_MIPS_GPREL # CHECK-NEXT: SHF_WRITE # CHECK-NEXT: ] -# CHECK-NEXT: Address: 0x20008 -# CHECK-NEXT: Offset: 0x20008 +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: # CHECK: } diff --git a/lld/test/ELF/mips-gprel32-relocs-gp0.s b/lld/test/ELF/mips-gprel32-relocs-gp0.s index 045279a..773a05b 100644 --- a/lld/test/ELF/mips-gprel32-relocs-gp0.s +++ b/lld/test/ELF/mips-gprel32-relocs-gp0.s @@ -5,23 +5,24 @@ # RUN: ld.lld -r -o %t-rel.o %t.o # 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: llvm-readobj --mips-reginfo %t.so | FileCheck --check-prefix=DSO %s +# 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 %S/Inputs/mips-gp0-non-zero.o # RUN: llvm-objdump -s -t %t.so | FileCheck --check-prefix=DUMP %s # REL: GP: 0x0 -# DSO: GP: 0x27FF0 - # DUMP: Contents of section .rodata: -# DUMP: {{[0-9a-f]+}} ffff0004 ffff0008 -# ^ 0x10004 + 0x7ff0 - 0x27ff0 -# ^ 0x10008 + 0x7ff0 - 0x27ff0 +# DUMP: 1000 fffffff4 fffffff8 +# ^ 0x20004 + 0x7ff0 - 0x28000 +# ^ 0x20008 + 0x7ff0 - 0x28000 # DUMP: SYMBOL TABLE: -# DUMP: 00010008 .text 00000000 bar -# DUMP: 00010004 .text 00000000 foo -# DUMP: 00027ff0 .got 00000000 .hidden _gp +# DUMP: 00020008 .text 00000000 bar +# DUMP: 00020004 .text 00000000 foo +# DUMP: 00028000 .got 00000000 .hidden _gp .text .global __start diff --git a/lld/test/ELF/mips-gprel32-relocs.s b/lld/test/ELF/mips-gprel32-relocs.s index 8f31aa8..e6b4cb5 100644 --- a/lld/test/ELF/mips-gprel32-relocs.s +++ b/lld/test/ELF/mips-gprel32-relocs.s @@ -2,7 +2,11 @@ # Check R_MIPS_GPREL32 relocation calculation. # 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 .text @@ -20,11 +24,11 @@ v1: .gpword bar # CHECK: Contents of section .rodata: -# CHECK: {{[0-9a-f]+}} fffe8014 fffe8018 -# ^ 0x10004 - 0x27ff0 -# ^ 0x10008 - 0x27ff0 +# CHECK: 1000 ffff8004 ffff8008 +# ^ 0x20004 - 0x28000 +# ^ 0x20008 - 0x28000 # CHECK: SYMBOL TABLE: -# CHECK: 00010008 .text 00000000 bar -# CHECK: 00010004 .text 00000000 foo -# CHECK: 00027ff0 .got 00000000 .hidden _gp +# CHECK: 00020008 .text 00000000 bar +# CHECK: 00020004 .text 00000000 foo +# CHECK: 00028000 .got 00000000 .hidden _gp diff --git a/lld/test/ELF/mips-higher-highest.s b/lld/test/ELF/mips-higher-highest.s index a95d6a7..f31c1be 100644 --- a/lld/test/ELF/mips-higher-highest.s +++ b/lld/test/ELF/mips-higher-highest.s @@ -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 \ # 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 .global __start @@ -14,7 +14,10 @@ __start: lui $7, %highest(_foo+0x300047FFF7FF8) ld $7, %higher (_foo+0x300047FFF7FF8)($7) -# CHECK: 20000: lui $6, 3 -# CHECK-NEXT: 20004: daddiu $6, $6, 5 -# CHECK-NEXT: 20008: lui $7, 3 -# CHECK-NEXT: 2000c: ld $7, 5($7) +# CHECK: __start: +# CHECK-NEXT: lui $6, 3 +# CHECK-NEXT: daddiu $6, $6, 5 +# CHECK-NEXT: lui $7, 3 +# CHECK-NEXT: ld $7, 5($7) +# CHECK-EMPTY: +# CHECK-NEXT: _foo: diff --git a/lld/test/ELF/mips-hilo-gp-disp.s b/lld/test/ELF/mips-hilo-gp-disp.s index 91f50ca..ba5315b 100644 --- a/lld/test/ELF/mips-hilo-gp-disp.s +++ b/lld/test/ELF/mips-hilo-gp-disp.s @@ -1,13 +1,17 @@ # REQUIRES: mips # 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 \ # RUN: %S/Inputs/mips-dynamic.s -o %t2.o -# RUN: ld.lld %t1.o %t2.o -o %t.exe -# RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck -check-prefix=EXE %s -# RUN: ld.lld %t1.o %t2.o -shared -o %t.so -# RUN: llvm-objdump -d -t --no-show-raw-insn %t.so | FileCheck -check-prefix=SO %s +# 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 %s +# 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 %s .text .globl __start @@ -19,38 +23,20 @@ bar: lui $t0,%hi(_gp_disp) addi $t0,$t0,%lo(_gp_disp) -# EXE: Disassembly of section .text: -# EXE-EMPTY: -# EXE-NEXT: __start: -# EXE-NEXT: 20000: lui $8, 2 -# ^-- %hi(0x47ff0-0x20000) -# EXE-NEXT: 20004: addi $8, $8, -32768 -# ^-- %lo(0x38000-0x20004+4) -# EXE: bar: -# EXE-NEXT: 2000c: lui $8, 1 -# ^-- %hi(0x38000-0x2000c) -# EXE-NEXT: 20010: addi $8, $8, 32756 -# ^-- %lo(0x38000-0x20010+4) +# CHECK: Disassembly of section .text: +# CHECK-EMPTY: +# CHECK-NEXT: __start: +# CHECK-NEXT: 11000: lui $8, 2 +# ^-- %hi(0x37ff0-0x11000) +# CHECK-NEXT: 11004: addi $8, $8, 28656 +# ^-- %lo(0x37ff0-0x11004+4) +# CHECK: bar: +# CHECK-NEXT: 1100c: lui $8, 2 +# ^-- %hi(0x37ff0-0x1100c) +# CHECK-NEXT: 11010: addi $8, $8, 28644 +# ^-- %lo(0x37ff0-0x11010+4) -# EXE: SYMBOL TABLE: -# EXE: 0002000c .text 00000000 bar -# EXE: 00038000 .got 00000000 .hidden _gp -# EXE: 00020000 .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 +# CHECK: SYMBOL TABLE: +# CHECK: 0001100c .text 00000000 bar +# CHECK: 00037ff0 .got 00000000 .hidden _gp +# CHECK: 00011000 .text 00000000 __start diff --git a/lld/test/ELF/mips-hilo-hi-only.s b/lld/test/ELF/mips-hilo-hi-only.s index ec6c751..e85c0a5 100644 --- a/lld/test/ELF/mips-hilo-hi-only.s +++ b/lld/test/ELF/mips-hilo-hi-only.s @@ -3,7 +3,7 @@ # 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: 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 .globl __start @@ -15,14 +15,12 @@ _label: # WARN: can't find matching R_MIPS_LO16 relocation for R_MIPS_HI16 -# CHECK: Disassembly of section .text: -# CHECK-EMPTY: -# CHECK-NEXT: __start: -# CHECK-NEXT: 20000: lui $8, 3 -# ^-- %hi(__start) w/o addend -# CHECK-NEXT 20004: addi $8, $8, 8 -# ^-- %lo(_label) +# CHECK: __start: +# CHECK-NEXT: lui $8, 0x3 +# ^-- %hi(__start) w/o addend +# CHECK-NEXT: addi $8, $8, 0x[[VAL:[0-9a-f]+]] +# ^-- %lo(_label) # CHECK: SYMBOL TABLE: -# CHECK: 00020008 .text 00000000 _label -# CHECK: 00020000 .text 00000000 __start +# CHECK: 00020{{0*}}[[VAL]] .text 00000000 _label +# CHECK: 00020{{.*}} .text 00000000 __start diff --git a/lld/test/ELF/mips-hilo.s b/lld/test/ELF/mips-hilo.s index 517ae2f..3cc0912 100644 --- a/lld/test/ELF/mips-hilo.s +++ b/lld/test/ELF/mips-hilo.s @@ -2,8 +2,9 @@ # Check R_MIPS_HI16 / LO16 relocations calculation. # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o -# RUN: ld.lld %t.o -o %t.exe -# RUN: llvm-objdump -d -t %t.exe | FileCheck %s +# RUN: echo "SECTIONS { . = 0x20000; .text ALIGN(0x1000) : { *(.text) } }" > %t.script +# 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 .globl __start @@ -29,25 +30,23 @@ l1: g1: .word 0 -# CHECK: Disassembly of section .text: -# CHECK-EMPTY: -# CHECK-NEXT: __start: -# CHECK-NEXT: 20000: 3c 08 00 02 lui $8, 2 -# ^-- %hi(__start+4) -# CHECK-NEXT: 20004: 3c 09 00 03 lui $9, 3 -# ^-- %hi(g1+8) -# CHECK-NEXT: 20008: 21 08 00 04 addi $8, $8, 4 -# ^-- %lo(__start+4) -# CHECK-NEXT: 2000c: 21 08 00 0c addi $8, $8, 12 -# ^-- %lo(g1+8) -# CHECK-NEXT: 20010: 3c 08 00 04 lui $8, 4 -# ^-- %hi(l1+0x10000-4) -# CHECK-NEXT: 20014: 3c 09 00 05 lui $9, 5 -# ^-- %hi(l1+0x20000-4) -# CHECK-NEXT: 20018: 21 08 ff fc addi $8, $8, -4 -# ^-- %lo(l1-4) +# CHECK: __start: +# CHECK-NEXT: 21000: lui $8, 2 +# ^-- %hi(__start+4) +# CHECK-NEXT: 21004: lui $9, 2 +# ^-- %hi(g1+8) +# CHECK-NEXT: 21008: addi $8, $8, 4100 +# ^-- %lo(__start+4) +# CHECK-NEXT: 2100c: addi $8, $8, 4140 +# ^-- %lo(g1+8) +# CHECK-NEXT: 21010: lui $8, 3 +# ^-- %hi(l1+0x10000-4) +# CHECK-NEXT: 21014: lui $9, 4 +# ^-- %hi(l1+0x20000-4) +# CHECK-NEXT: 21018: addi $8, $8, 4124 +# ^-- %lo(l1-4) # CHECK: SYMBOL TABLE: -# CHECK: 0030000 l O .data 00000004 l1 -# CHECK: 0020000 .text 00000000 __start -# CHECK: 0030004 g O .data 00000004 g1 +# CHECK: 0021020 l O .data 00000004 l1 +# CHECK: 0021000 .text 00000000 __start +# CHECK: 0021024 g O .data 00000004 g1 diff --git a/lld/test/ELF/mips-jalr.s b/lld/test/ELF/mips-jalr.s new file mode 100644 index 0000000..a4a51ad --- /dev/null +++ b/lld/test/ELF/mips-jalr.s @@ -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 diff --git a/lld/test/ELF/mips-jalr.test b/lld/test/ELF/mips-jalr.test deleted file mode 100644 index 8caaba2..0000000 --- a/lld/test/ELF/mips-jalr.test +++ /dev/null @@ -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 diff --git a/lld/test/ELF/mips-mgot.s b/lld/test/ELF/mips-mgot.s index 9488cc9..f958478 100644 --- a/lld/test/ELF/mips-mgot.s +++ b/lld/test/ELF/mips-mgot.s @@ -6,25 +6,27 @@ # RUN: %p/Inputs/mips-mgot-1.s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # 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-readobj -r --dyn-syms --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s # CHECK: Contents of section .got: -# CHECK-NEXT: 70000 00000000 80000000 00010000 00010030 -# CHECK-NEXT: 70010 00000000 00000004 00030000 00040000 -# CHECK-NEXT: 70020 00050000 00060000 00070000 00080000 +# CHECK-NEXT: 70000 00000000 80000000 [[FOO0:[0-9a-f]+]] [[FOO2:[0-9a-f]+]] +# CHECK-NEXT: 70010 00000000 00000004 00010000 00020000 +# CHECK-NEXT: 70020 00030000 00040000 00050000 00060000 # CHECK-NEXT: 70030 00000000 00000000 00000000 00000000 # CHECK-NEXT: 70040 00000000 00000000 00000000 # CHECK: SYMBOL TABLE: # 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: 00010020 .text 00000000 foo1 # CHECK: 00000004 g O .tdata 00000000 tls1 -# CHECK: 00010030 .text 00000000 foo2 -# CHECK: 00000008 g O .tdata 00000000 tls2 +# CHECK: [[FOO2]] .text 00000000 foo2 # GOT: Relocations [ # GOT-NEXT: Section (7) .rel.dyn { @@ -48,11 +50,11 @@ # GOT: DynamicSymbols [ # GOT: Symbol { # GOT: Name: foo0 -# GOT-NEXT: Value: 0x10000 +# GOT-NEXT: Value: 0x[[FOO0:[0-9A-F]+]] # GOT: } # GOT-NEXT: Symbol { # GOT-NEXT: Name: foo2 -# GOT-NEXT: Value: 0x10030 +# GOT-NEXT: Value: 0x[[FOO2:[0-9A-F]+]] # GOT: } # GOT-NEXT: ] @@ -78,8 +80,8 @@ # GOT-NEXT: Entry { # GOT-NEXT: Address: # GOT-NEXT: Access: -32744 -# GOT-NEXT: Initial: 0x10000 -# GOT-NEXT: Value: 0x10000 +# GOT-NEXT: Initial: 0x[[FOO0]] +# GOT-NEXT: Value: 0x[[FOO0]] # GOT-NEXT: Type: None # GOT-NEXT: Section: .text # GOT-NEXT: Name: foo0 @@ -87,8 +89,8 @@ # GOT-NEXT: Entry { # GOT-NEXT: Address: # GOT-NEXT: Access: -32740 -# GOT-NEXT: Initial: 0x10030 -# GOT-NEXT: Value: 0x10030 +# GOT-NEXT: Initial: 0x[[FOO2]] +# GOT-NEXT: Value: 0x[[FOO2]] # GOT-NEXT: Type: None # GOT-NEXT: Section: .text # GOT-NEXT: Name: foo2