From 2439b8b0c5f384561e005a64efe5c36b1007c6ff Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Mon, 9 Sep 2019 22:04:20 +0000 Subject: [PATCH] [mips] Make another set of test cases more tolerant to exact symbol addresses. NFC llvm-svn: 371458 --- lld/test/ELF/mips-32.s | 14 ++- lld/test/ELF/mips-micro-cross-calls.s | 38 +++--- lld/test/ELF/mips-micro-jal.s | 164 +++++++++---------------- lld/test/ELF/mips-micro-plt.s | 110 +++++------------ lld/test/ELF/mips-micro-relocs.s | 70 +++++------ lld/test/ELF/mips-micro-thunks.s | 74 +++++------ lld/test/ELF/mips-micror6-relocs.s | 33 +++-- lld/test/ELF/mips-n32-rels.s | 69 +++++------ lld/test/ELF/mips-nonalloc.s | 8 +- lld/test/ELF/mips-npic-call-pic-os.s | 132 +++++--------------- lld/test/ELF/mips-npic-call-pic.s | 170 +++++++++----------------- lld/test/ELF/mips-pc-relocs.s | 21 ++-- lld/test/ELF/mips-plt-n32.s | 15 ++- lld/test/ELF/mips-plt-n64.s | 15 ++- lld/test/ELF/mips-plt-r6.s | 9 +- lld/test/ELF/mips-tls-64-pic-local-variable.s | 20 +-- lld/test/ELF/mips-tls-64.s | 37 +++--- lld/test/ELF/mips-tls-hilo.s | 16 +-- lld/test/ELF/mips-tls-static-64.s | 6 +- lld/test/ELF/mips-tls-static.s | 8 +- lld/test/ELF/mips-tls.s | 33 ++--- lld/test/ELF/mips-xgot-order.s | 41 ++++--- lld/test/ELF/rel-addend-with-rela-input.s | 24 ++-- 23 files changed, 463 insertions(+), 664 deletions(-) diff --git a/lld/test/ELF/mips-32.s b/lld/test/ELF/mips-32.s index 9009ce4..97b49ae 100644 --- a/lld/test/ELF/mips-32.s +++ b/lld/test/ELF/mips-32.s @@ -1,14 +1,18 @@ # REQUIRES: mips # Check R_MIPS_32 relocation calculation. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x10000; .data ALIGN(0x1000) : { *(.data) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-be.o -# 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-objdump -t -s %t-be.so | FileCheck -check-prefixes=SYM,BE %s # RUN: llvm-readelf -r -s --dynamic-table --mips-plt-got %t-be.so \ # RUN: | FileCheck -check-prefix=REL %s # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o -# 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-objdump -t -s %t-el.so | FileCheck -check-prefixes=SYM,EL %s # RUN: llvm-readelf -r -s --dynamic-table --mips-plt-got %t-el.so \ # RUN: | FileCheck -check-prefix=REL %s @@ -21,15 +25,15 @@ v2: .word v1 # R_MIPS_32 target v1 addend 0 # BE: Contents of section .data: -# BE-NEXT: {{.*}} 00000004 00010000 +# BE-NEXT: {{.*}} 00000004 00011000 # ^-- v2+4 ^-- v1 # EL: Contents of section .data: -# EL-NEXT: {{.*}} 04000000 00000100 +# EL-NEXT: {{.*}} 04000000 00100100 # ^-- v2+4 ^-- v1 # SYM: SYMBOL TABLE: -# SYM: 00010000 .data 00000000 v1 +# SYM: 00011000 .data 00000000 v1 # REL: Relocation section # REL: {{.*}} R_MIPS_REL32 diff --git a/lld/test/ELF/mips-micro-cross-calls.s b/lld/test/ELF/mips-micro-cross-calls.s index 1368bda..1663413b 100644 --- a/lld/test/ELF/mips-micro-cross-calls.s +++ b/lld/test/ELF/mips-micro-cross-calls.s @@ -7,28 +7,38 @@ # RUN: -position-independent -mattr=micromips \ # RUN: %S/Inputs/mips-micro.s -o %t-eb-pic.o # RUN: ld.lld -o %t-eb.exe %t-eb.o %t-eb-pic.o -# RUN: llvm-objdump -d -mattr=-micromips %t-eb.exe \ -# RUN: | FileCheck --check-prefix=REG %s -# RUN: llvm-objdump -d -mattr=+micromips %t-eb.exe \ -# RUN: | FileCheck --check-prefix=MICRO %s +# RUN: llvm-objdump -d -t -mattr=-micromips \ +# RUN: --no-show-raw-insn --print-imm-hex %t-eb.exe \ +# RUN: | FileCheck --check-prefixes=SYM,REG %s +# RUN: llvm-objdump -d -t -mattr=+micromips \ +# RUN: --no-show-raw-insn --print-imm-hex %t-eb.exe \ +# RUN: | FileCheck --check-prefixes=SYM,MICRO %s # REG: __start: -# REG-NEXT: 20000: 74 00 80 04 jalx 131088 -# REG-NEXT: 20004: 00 00 00 00 nop -# REG-NEXT: 20008: 74 00 80 08 jalx 131104 <__microLA25Thunk_foo> +# REG-NEXT: jalx 0x[[MIC:[0-9a-f]+]] +# REG-NEXT: nop +# REG-NEXT: jalx 0x[[FOOT:[0-9a-f]+]] <__microLA25Thunk_foo> # REG: __LA25Thunk_bar: -# REG-NEXT: 20030: 3c 19 00 02 lui $25, 2 -# REG-NEXT: 20034: 08 00 80 11 j 131140 +# REG-NEXT: lui $25, 0x2 +# REG-NEXT: j 0x[[BAR:[0-9a-f]+]] # MICRO: micro: -# MICRO-NEXT: 20010: f0 00 80 00 jalx 131072 <__start> -# MICRO-NEXT: 20014: 00 00 00 00 nop -# MICRO-NEXT: 20018: f0 00 80 0c jalx 131120 <__LA25Thunk_bar> +# MICRO-NEXT: jalx 0x[[START:[0-9a-f]+]] +# MICRO-NEXT: nop +# MICRO-NEXT: jalx 0x[[BART:[0-9a-f]+]] # MICRO: __microLA25Thunk_foo: -# MICRO-NEXT: 20020: 41 b9 00 02 lui $25, 2 -# MICRO-NEXT: 20024: d4 01 00 20 j 131136 +# MICRO-NEXT: lui $25, 0x2 +# MICRO-NEXT: j 0x[[FOO:[0-9a-f]+]] + +# REG: [[FOOT]] l F .text 0000000e 0x80 __microLA25Thunk_foo +# REG: [[BAR]] g F .text 00000000 bar +# REG: [[MIC]] .text 00000000 0x80 micro + +# MICRO: [[BART]] l F .text 00000010 __LA25Thunk_bar +# MICRO: [[START]] .text 00000000 __start +# MICRO: [[FOO]] g F .text 00000000 0x80 foo .text .set nomicromips diff --git a/lld/test/ELF/mips-micro-jal.s b/lld/test/ELF/mips-micro-jal.s index a056551..f2bc0e4 100644 --- a/lld/test/ELF/mips-micro-jal.s +++ b/lld/test/ELF/mips-micro-jal.s @@ -1,39 +1,48 @@ # REQUIRES: mips # Check PLT creation for microMIPS to microMIPS calls. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x20000; .text ALIGN(0x100) : { *(.text) } \ +# RUN: . = 0x20300; .plt : { *(.plt) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1eb.o # RUN: ld.lld -shared -soname=teb.so -o %teb.so %t1eb.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips %s -o %t2eb.o -# RUN: ld.lld -o %teb.exe %t2eb.o %teb.so -# RUN: llvm-objdump -d -mattr=micromips %teb.exe | FileCheck --check-prefix=EB %s -# RUN: llvm-readobj --mips-plt-got %teb.exe | FileCheck --check-prefix=PLT %s +# RUN: ld.lld --script %t.script -o %teb.exe %t2eb.o %teb.so +# RUN: llvm-objdump -d -mattr=micromips --no-show-raw-insn %teb.exe \ +# RUN: | FileCheck --check-prefix=R2 %s +# RUN: llvm-readelf --mips-plt-got %teb.exe | FileCheck --check-prefix=PLT %s # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1el.o # RUN: ld.lld -shared -soname=tel.so -o %tel.so %t1el.o # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -mattr=micromips %s -o %t2el.o -# RUN: ld.lld -o %tel.exe %t2el.o %tel.so -# RUN: llvm-objdump -d -mattr=micromips %tel.exe | FileCheck --check-prefix=EL %s -# RUN: llvm-readobj --mips-plt-got %tel.exe | FileCheck --check-prefix=PLT %s +# RUN: ld.lld --script %t.script -o %tel.exe %t2el.o %tel.so +# RUN: llvm-objdump -d -mattr=micromips --no-show-raw-insn %tel.exe \ +# RUN: | FileCheck --check-prefix=R2 %s +# RUN: llvm-readelf --mips-plt-got %tel.exe | FileCheck --check-prefix=PLT %s # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips -mcpu=mips32r6 %S/Inputs/mips-micro.s -o %t1eb.o # RUN: ld.lld -shared -soname=teb.so -o %teb.so %t1eb.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips -mcpu=mips32r6 %s -o %t2eb.o -# RUN: ld.lld -o %teb.exe %t2eb.o %teb.so -# RUN: llvm-objdump -d -mattr=micromips %teb.exe | FileCheck --check-prefix=EBR6 %s +# RUN: ld.lld --script %t.script -o %teb.exe %t2eb.o %teb.so +# RUN: llvm-objdump -d -mattr=micromips %teb.exe --no-show-raw-insn \ +# RUN: | FileCheck --check-prefix=R6 %s # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -mattr=micromips -mcpu=mips32r6 %S/Inputs/mips-micro.s -o %t1el.o # RUN: ld.lld -shared -soname=tel.so -o %tel.so %t1el.o # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -mattr=micromips -mcpu=mips32r6 %s -o %t2el.o -# RUN: ld.lld -o %tel.exe %t2el.o %tel.so -# RUN: llvm-objdump -d -mattr=micromips %tel.exe | FileCheck --check-prefix=ELR6 %s +# RUN: ld.lld --script %t.script -o %tel.exe %t2el.o %tel.so +# RUN: llvm-objdump -d -mattr=micromips --no-show-raw-insn %tel.exe \ +# RUN: | FileCheck --check-prefix=R6 %s # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1eb.o @@ -42,109 +51,46 @@ # RUN: %S/Inputs/mips-fpic.s -o %t-reg.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips %s -o %t2eb.o -# RUN: ld.lld --no-threads -o %teb.exe %t-reg.o %t2eb.o %teb.so -# RUN: llvm-objdump -d -mattr=micromips %teb.exe \ -# RUN: | FileCheck --check-prefix=MIXED %s - -# EB: Disassembly of section .plt: -# EB-EMPTY: -# EB-NEXT: .plt: -# EB-NEXT: 20010: 79 80 3f fd addiupc $3, 65524 -# EB-NEXT: 20014: ff 23 00 00 lw $25, 0($3) -# EB-NEXT: 20018: 05 35 subu16 $2, $2, $3 -# EB-NEXT: 2001a: 25 25 srl16 $2, $2, 2 -# EB-NEXT: 2001c: 33 02 ff fe addiu $24, $2, -2 -# EB-NEXT: 20020: 0d ff move $15, $ra -# EB-NEXT: 20022: 45 f9 jalrs16 $25 -# EB-NEXT: 20024: 0f 83 move $gp, $3 -# EB-NEXT: 20026: 0c 00 nop -# EB-NEXT: ... -# EB-NEXT: 20030: 79 00 3f f7 addiupc $2, 65500 -# EB-NEXT: 20034: ff 22 00 00 lw $25, 0($2) -# EB-NEXT: 20038: 45 99 jr16 $25 -# EB-NEXT: 2003a: 0f 02 move $24, $2 - -# EL: Disassembly of section .plt: -# EL-EMPTY: -# EL-NEXT: .plt: -# EL-NEXT: 20010: 80 79 fd 3f addiupc $3, 65524 -# EL-NEXT: 20014: 23 ff 00 00 lw $25, 0($3) -# EL-NEXT: 20018: 35 05 subu16 $2, $2, $3 -# EL-NEXT: 2001a: 25 25 srl16 $2, $2, 2 -# EL-NEXT: 2001c: 02 33 fe ff addiu $24, $2, -2 -# EL-NEXT: 20020: ff 0d move $15, $ra -# EL-NEXT: 20022: f9 45 jalrs16 $25 -# EL-NEXT: 20024: 83 0f move $gp, $3 -# EL-NEXT: 20026: 00 0c nop -# EL-NEXT: ... -# EL-NEXT: 20030: 00 79 f7 3f addiupc $2, 65500 -# EL-NEXT: 20034: 22 ff 00 00 lw $25, 0($2) -# EL-NEXT: 20038: 99 45 jr16 $25 -# EL-NEXT: 2003a: 02 0f move $24, $2 - -# EBR6: Disassembly of section .plt: -# EBR6-EMPTY: -# EBR6-NEXT: .plt: -# EBR6-NEXT: 20010: 78 60 3f fd lapc $3, 65524 -# EBR6-NEXT: 20014: ff 23 00 00 lw $25, 0($3) -# EBR6-NEXT: 20018: 05 35 subu16 $2, $2, $3 -# EBR6-NEXT: 2001a: 25 25 srl16 $2, $2, 2 -# EBR6-NEXT: 2001c: 33 02 ff fe addiu $24, $2, -2 -# EBR6-NEXT: 20020: 0d ff move16 $15, $ra -# EBR6-NEXT: 20022: 0f 83 move16 $gp, $3 -# EBR6-NEXT: 20024: 47 2b jalr $25 - -# EBR6: 20030: 78 40 3f f7 lapc $2, 65500 -# EBR6-NEXT: 20034: ff 22 00 00 lw $25, 0($2) -# EBR6-NEXT: 20038: 0f 02 move16 $24, $2 -# EBR6-NEXT: 2003a: 47 23 jrc16 $25 +# RUN: ld.lld --script %t.script --no-threads -o %teb.exe %t-reg.o %t2eb.o %teb.so +# RUN: llvm-objdump -d -mattr=micromips --no-show-raw-insn %teb.exe \ +# RUN: | FileCheck --check-prefix=R2 %s -# ELR6: Disassembly of section .plt: -# ELR6-EMPTY: -# ELR6-NEXT: .plt: -# ELR6-NEXT: 20010: 60 78 fd 3f lapc $3, 65524 -# ELR6-NEXT: 20014: 23 ff 00 00 lw $25, 0($3) -# ELR6-NEXT: 20018: 35 05 subu16 $2, $2, $3 -# ELR6-NEXT: 2001a: 25 25 srl16 $2, $2, 2 -# ELR6-NEXT: 2001c: 02 33 fe ff addiu $24, $2, -2 -# ELR6-NEXT: 20020: ff 0d move16 $15, $ra -# ELR6-NEXT: 20022: 83 0f move16 $gp, $3 -# ELR6-NEXT: 20024: 2b 47 jalr $25 +# R2: .plt: +# R2: 20300: addiupc $3, 52 +# R2-NEXT: lw $25, 0($3) +# R2-NEXT: subu16 $2, $2, $3 +# R2-NEXT: srl16 $2, $2, 2 +# R2-NEXT: addiu $24, $2, -2 +# R2-NEXT: move $15, $ra +# R2-NEXT: jalrs16 $25 +# R2-NEXT: move $gp, $3 +# R2-NEXT: nop +# R2-NEXT: ... +# R2-NEXT: 20320: addiupc $2, 28 +# R2-NEXT: lw $25, 0($2) +# R2-NEXT: jr16 $25 +# R2-NEXT: move $24, $2 -# ELR6: 20030: 40 78 f7 3f lapc $2, 65500 -# ELR6-NEXT: 20034: 22 ff 00 00 lw $25, 0($2) -# ELR6-NEXT: 20038: 02 0f move16 $24, $2 -# ELR6-NEXT: 2003a: 23 47 jrc16 $25 +# R6: .plt: +# R6: 20300: lapc $3, 52 +# R6-NEXT: lw $25, 0($3) +# R6-NEXT: subu16 $2, $2, $3 +# R6-NEXT: srl16 $2, $2, 2 +# R6-NEXT: addiu $24, $2, -2 +# R6-NEXT: move16 $15, $ra +# R6-NEXT: move16 $gp, $3 +# R6-NEXT: jalr $25 -# MIXED: Disassembly of section .plt: -# MIXED-EMPTY: -# MIXED-NEXT: .plt: -# MIXED-NEXT: 20020: 79 80 3f f9 addiupc $3, 65508 -# MIXED-NEXT: 20024: ff 23 00 00 lw $25, 0($3) -# MIXED-NEXT: 20028: 05 35 subu16 $2, $2, $3 -# MIXED-NEXT: 2002a: 25 25 srl16 $2, $2, 2 -# MIXED-NEXT: 2002c: 33 02 ff fe addiu $24, $2, -2 -# MIXED-NEXT: 20030: 0d ff move $15, $ra -# MIXED-NEXT: 20032: 45 f9 jalrs16 $25 -# MIXED-NEXT: 20034: 0f 83 move $gp, $3 -# MIXED-NEXT: 20036: 0c 00 nop -# MIXED-NEXT: ... -# MIXED-NEXT: 20040: 79 00 3f f3 addiupc $2, 65484 -# MIXED-NEXT: 20044: ff 22 00 00 lw $25, 0($2) -# MIXED-NEXT: 20048: 45 99 jr16 $25 -# MIXED-NEXT: 2004a: 0f 02 move $24, $2 +# R6: 20320: lapc $2, 28 +# R6-NEXT: lw $25, 0($2) +# R6-NEXT: move16 $24, $2 +# R6-NEXT: jrc16 $25 -# PLT: Entries [ -# PLT-NEXT: Entry { -# PLT-NEXT: Address: 0x3000C -# ^ 0x20030 + 65500 -# PLT-NEXT: Initial: -# PLT-NEXT: Value: 0x0 -# PLT-NEXT: Type: Function -# PLT-NEXT: Section: Undefined -# PLT-NEXT: Name: foo -# PLT-NEXT: } -# PLT-NEXT: ] +# PLT: PLT GOT: +# PLT: Entries: +# PLT-NEXT: Address Initial Sym.Val. Type Ndx Name +# PLT-NEXT: 0002033c 00020301 00000000 FUNC UND foo +# ^ 0x20320 + 28 .text .set micromips diff --git a/lld/test/ELF/mips-micro-plt.s b/lld/test/ELF/mips-micro-plt.s index b64e5f6..47ef46b 100644 --- a/lld/test/ELF/mips-micro-plt.s +++ b/lld/test/ELF/mips-micro-plt.s @@ -6,93 +6,43 @@ # RUN: ld.lld %t-dso.o -shared -soname=t.so -o %t.so # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips %s -o %t-exe.o -# RUN: ld.lld %t-exe.o %t.so -o %t.exe -# RUN: llvm-readobj --symbols --dyn-syms --mips-plt-got %t.exe | FileCheck %s -# RUN: llvm-objdump -d -mattr=micromips %t.exe | FileCheck --check-prefix=ASM %s +# RUN: echo "SECTIONS { \ +# RUN: . = 0x20000; .text ALIGN(0x100) : { *(.text) } \ +# RUN: . = 0x20300; .plt : { *(.plt) } \ +# RUN: }" > %t.script +# RUN: ld.lld %t-exe.o %t.so --script %t.script -o %t.exe +# RUN: llvm-readelf --symbols --dyn-syms --mips-plt-got %t.exe | FileCheck %s +# RUN: llvm-objdump -d -mattr=micromips --no-show-raw-insn %t.exe \ +# RUN: | FileCheck --check-prefix=ASM %s -# CHECK: Symbols [ -# CHECK: Symbol { -# CHECK: Name: foo -# CHECK-NEXT: Value: 0x20010 -# CHECK-NEXT: Size: -# CHECK-NEXT: Binding: Local -# CHECK-NEXT: Type: None -# CHECK-NEXT: Other [ -# CHECK-NEXT: STO_MIPS_MICROMIPS -# CHECK-NEXT: STV_HIDDEN -# CHECK-NEXT: ] -# CHECK-NEXT: Section: .text -# CHECK-NEXT: } -# CHECK: Symbol { -# CHECK: Name: __start -# CHECK-NEXT: Value: 0x20000 -# CHECK-NEXT: Size: -# CHECK-NEXT: Binding: Global -# CHECK-NEXT: Type: None -# CHECK-NEXT: Other [ -# CHECK-NEXT: STO_MIPS_MICROMIPS -# CHECK-NEXT: ] -# CHECK-NEXT: Section: .text -# CHECK-NEXT: } -# CHECK: Symbol { -# CHECK: Name: foo0 -# CHECK-NEXT: Value: 0x20040 -# CHECK-NEXT: Size: -# CHECK-NEXT: Binding: Global -# CHECK-NEXT: Type: Function -# CHECK-NEXT: Other [ -# CHECK-NEXT: STO_MIPS_MICROMIPS -# CHECK-NEXT: STO_MIPS_PLT -# CHECK-NEXT: ] -# CHECK-NEXT: Section: Undefined -# CHECK-NEXT: } -# CHECK-NEXT: ] -# CHECK: DynamicSymbols [ -# CHECK: Symbol { -# CHECK: Name: foo0 -# CHECK-NEXT: Value: 0x20041 -# CHECK-NEXT: Size: -# CHECK-NEXT: Binding: Global -# CHECK-NEXT: Type: Function -# CHECK-NEXT: Other [ -# CHECK-NEXT: STO_MIPS_MICROMIPS -# CHECK-NEXT: STO_MIPS_PLT -# CHECK-NEXT: ] -# CHECK-NEXT: Section: Undefined -# CHECK-NEXT: } -# CHECK-NEXT: ] +# CHECK: Symbol table '.dynsym' +# CHECK: Num: Value Size Type Bind Vis Ndx Name +# CHECK: 1: 00020321 0 FUNC GLOBAL DEFAULT [] UND foo0 -# CHECK: Primary GOT { -# CHECK: Local entries [ -# CHECK-NEXT: Entry { -# CHECK-NEXT: Address: -# CHECK-NEXT: Access: -# CHECK-NEXT: Initial: 0x20011 -# CHECK-NEXT: } -# CHECK: ] -# CHECK: } +# CHECK: Symbol table '.symtab' +# CHECK: Num: Value Size Type Bind Vis Ndx Name +# CHECK: 1: 00020210 0 NOTYPE LOCAL HIDDEN [] 8 foo +# CHECK: 4: 00020200 0 NOTYPE GLOBAL DEFAULT [] 8 __start +# CHECK: 5: 00020320 0 FUNC GLOBAL DEFAULT [] UND foo0 -# CHECK: PLT GOT { -# CHECK: Entries [ -# CHECK-NEXT: Entry { -# CHECK-NEXT: Address: -# CHECK-NEXT: Initial: 0x20021 -# CHECK-NEXT: Value: 0x20041 -# CHECK-NEXT: Type: Function -# CHECK-NEXT: Section: Undefined -# CHECK-NEXT: Name: foo0 -# CHECK-NEXT: } -# CHECK-NEXT: ] -# CHECK-NEXT: } +# CHECK: Primary GOT: +# CHECK: Local entries: +# CHECK: Address Access Initial +# CHECK: -32744(gp) 00020211 + +# CHECK: PLT GOT: +# CHECK: Entries: +# CHECK: Address Initial Sym.Val. Type Ndx Name +# CHECK: 00020301 00020321 FUNC UND foo0 # ASM: __start: -# ASM-NEXT: 20000: fd 1c 80 18 lw $8, -32744($gp) -# ASM-NEXT: 20004: 11 08 00 11 addi $8, $8, 17 -# ASM-NEXT: 20008: 41 a8 00 02 lui $8, 2 -# ASM-NEXT: 2000c: 11 08 00 41 addi $8, $8, 65 +# ASM-NEXT: 20200: lw $8, -32744($gp) +# ASM-NEXT: addi $8, $8, 529 +# ASM-NEXT: lui $8, 2 +# ASM-NEXT: addi $8, $8, 801 # # ASM: foo: -# ASM-NEXT: 20010: f4 01 00 20 jal 131136 +# ASM-NEXT: 20210: jal 131872 .text .set micromips diff --git a/lld/test/ELF/mips-micro-relocs.s b/lld/test/ELF/mips-micro-relocs.s index a0decf1..b9235eb 100644 --- a/lld/test/ELF/mips-micro-relocs.s +++ b/lld/test/ELF/mips-micro-relocs.s @@ -1,64 +1,58 @@ # REQUIRES: mips # Check handling of microMIPS relocations. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x20000; .text ALIGN(0x100) : { *(.text) } \ +# RUN: . = 0x20300; .plt : { *(.plt) } \ +# RUN: . = 0x30000; .data : { *(.data) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1eb.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mattr=micromips %s -o %t2eb.o -# RUN: ld.lld -o %teb.exe %t1eb.o %t2eb.o -# RUN: llvm-objdump -d -t -s -mattr=micromips %teb.exe \ -# RUN: | FileCheck --check-prefixes=EB,SYM %s -# RUN: llvm-readobj -h %teb.exe | FileCheck --check-prefix=ELF %s +# RUN: ld.lld -o %teb.exe -script %t.script %t1eb.o %t2eb.o +# RUN: llvm-objdump -d -t -s -mattr=micromips --no-show-raw-insn %teb.exe \ +# RUN: | FileCheck --check-prefixes=ASM,EB %s +# RUN: llvm-readelf -h %teb.exe | FileCheck --check-prefix=ELF %s # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1el.o # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -mattr=micromips %s -o %t2el.o -# RUN: ld.lld -o %tel.exe %t1el.o %t2el.o -# RUN: llvm-objdump -d -t -s -mattr=micromips %tel.exe \ -# RUN: | FileCheck --check-prefixes=EL,SYM %s -# RUN: llvm-readobj -h %tel.exe | FileCheck --check-prefix=ELF %s +# RUN: ld.lld -o %tel.exe -script %t.script %t1el.o %t2el.o +# RUN: llvm-objdump -d -t -s -mattr=micromips --no-show-raw-insn %tel.exe \ +# RUN: | FileCheck --check-prefixes=ASM,EL %s +# RUN: llvm-readelf -h %tel.exe | FileCheck --check-prefix=ELF %s -# EB: __start: -# EB-NEXT: 20010: 41 a3 00 01 lui $3, 1 -# EB-NEXT: 20014: 30 63 7f ef addiu $3, $3, 32751 -# EB-NEXT: 20018: fc 7c 80 18 lw $3, -32744($gp) -# EB-NEXT: 2001c: fc 63 80 18 lw $3, -32744($3) -# EB-NEXT: 20020: 8f 70 beqz16 $6, -32 -# EB-NEXT: 20022: 00 7e 00 00 sll $3, $fp, 0 -# EB-NEXT: 20026: cf ec b16 -40 -# EB-NEXT: 20028: 00 00 00 00 nop -# EB-NEXT: 2002c: 94 00 ff e8 b -44 +# ASM: __start: +# ASM-NEXT: 20110: lui $3, 1 +# ASM-NEXT: addiu $3, $3, 32495 +# ASM-NEXT: lw $3, -32744($gp) +# ASM-NEXT: lw $3, -32744($3) +# ASM-NEXT: beqz16 $6, -32 +# ASM-NEXT: sll $3, $fp, 0 +# ASM-NEXT: b16 -40 +# ASM-NEXT: nop +# ASM-NEXT: b -44 # EB: Contents of section .data: -# EB-NEXT: 30000 fffe8011 +# EB-NEXT: 30000 fffe8111 # EB: Contents of section .debug_info -# EB-NEXT: 0000 00020011 - -# EL: __start: -# EL-NEXT: 20010: a3 41 01 00 lui $3, 1 -# EL-NEXT: 20014: 63 30 ef 7f addiu $3, $3, 32751 -# EL-NEXT: 20018: 7c fc 18 80 lw $3, -32744($gp) -# EL-NEXT: 2001c: 63 fc 18 80 lw $3, -32744($3) -# EL-NEXT: 20020: 70 8f beqz16 $6, -32 -# EL-NEXT: 20022: 7e 00 00 00 sll $3, $fp, 0 -# EL-NEXT: 20026: ec cf b16 -40 -# EL-NEXT: 20028: 00 00 00 00 nop -# EL-NEXT: 2002c: 00 94 e8 ff b -44 +# EB-NEXT: 0000 00020111 # EL: Contents of section .data: -# EL-NEXT: 30000 1180feff +# EL-NEXT: 30000 1181feff # EL: Contents of section .debug_info -# EL-NEXT: 0000 11000200 +# EL-NEXT: 0000 11010200 -# SYM: 00038000 .got 00000000 .hidden _gp -# SYM: 00020000 g F .text 00000000 0x80 foo -# SYM: 00020010 .text 00000000 0x80 __start +# ASM: 00038000 .got 00000000 .hidden _gp +# ASM: 00020100 g F .text 00000000 0x80 foo +# ASM: 00020110 .text 00000000 0x80 __start -# ELF: ElfHeader { -# ELF: Entry: 0x20011 +# ELF: Entry point address: 0x20111 .text .set micromips diff --git a/lld/test/ELF/mips-micro-thunks.s b/lld/test/ELF/mips-micro-thunks.s index 0505361..90f984c 100644 --- a/lld/test/ELF/mips-micro-thunks.s +++ b/lld/test/ELF/mips-micro-thunks.s @@ -1,77 +1,63 @@ # REQUIRES: mips # Check microMIPS thunk generation. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x20000; .text ALIGN(0x100) : { *(.text) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mcpu=mips32r2 -mattr=micromips %s -o %t-eb.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -position-independent -mcpu=mips32r2 -mattr=micromips \ # RUN: %S/Inputs/mips-micro.s -o %t-eb-pic.o -# RUN: ld.lld -o %t-eb.exe %t-eb.o %t-eb-pic.o -# RUN: llvm-objdump -d -mattr=+micromips %t-eb.exe \ -# RUN: | FileCheck --check-prefix=EB-R2 %s +# RUN: ld.lld -o %t-eb.exe -script %t.script %t-eb.o %t-eb-pic.o +# RUN: llvm-objdump -d -mattr=+micromips --no-show-raw-insn %t-eb.exe \ +# RUN: | FileCheck --check-prefix=R2 %s # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -mcpu=mips32r2 -mattr=micromips %s -o %t-el.o # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -position-independent -mcpu=mips32r2 -mattr=micromips \ # RUN: %S/Inputs/mips-micro.s -o %t-el-pic.o -# RUN: ld.lld -o %t-el.exe %t-el.o %t-el-pic.o -# RUN: llvm-objdump -d -mattr=+micromips %t-el.exe \ -# RUN: | FileCheck --check-prefix=EL-R2 %s +# RUN: ld.lld -o %t-el.exe -script %t.script %t-el.o %t-el-pic.o +# RUN: llvm-objdump -d -mattr=+micromips --no-show-raw-insn %t-el.exe \ +# RUN: | FileCheck --check-prefix=R2 %s # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mcpu=mips32r6 -mattr=micromips %s -o %t-eb-r6.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -position-independent -mcpu=mips32r6 -mattr=micromips \ # RUN: %S/Inputs/mips-micro.s -o %t-eb-pic-r6.o -# RUN: ld.lld -o %t-eb-r6.exe %t-eb-r6.o %t-eb-pic-r6.o -# RUN: llvm-objdump -d -mattr=+micromips %t-eb-r6.exe \ -# RUN: | FileCheck --check-prefix=EB-R6 %s +# RUN: ld.lld -o %t-eb-r6.exe -script %t.script %t-eb-r6.o %t-eb-pic-r6.o +# RUN: llvm-objdump -d -mattr=+micromips --no-show-raw-insn %t-eb-r6.exe \ +# RUN: | FileCheck --check-prefix=R6 %s # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -mcpu=mips32r6 -mattr=micromips %s -o %t-el-r6.o # RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ # RUN: -position-independent -mcpu=mips32r6 -mattr=micromips \ # RUN: %S/Inputs/mips-micro.s -o %t-el-pic-r6.o -# RUN: ld.lld -o %t-el-r6.exe %t-el-r6.o %t-el-pic-r6.o -# RUN: llvm-objdump -d -mattr=+micromips %t-el-r6.exe \ -# RUN: | FileCheck --check-prefix=EL-R6 %s - -# EB-R2: __start: -# EB-R2-NEXT: 20000: f4 01 00 04 jal 131080 <__microLA25Thunk_foo> -# EB-R2-NEXT: 20004: 00 00 00 00 nop - -# EB-R2: __microLA25Thunk_foo: -# EB-R2-NEXT: 20008: 41 b9 00 02 lui $25, 2 -# EB-R2-NEXT: 2000c: d4 01 00 10 j 131104 -# EB-R2-NEXT: 20010: 33 39 00 21 addiu $25, $25, 33 -# EB-R2-NEXT: 20014: 0c 00 nop - -# EL-R2: __start: -# EL-R2-NEXT: 20000: 01 f4 04 00 jal 131080 <__microLA25Thunk_foo> -# EL-R2-NEXT: 20004: 00 00 00 00 nop - -# EL-R2: __microLA25Thunk_foo: -# EL-R2-NEXT: 20008: b9 41 02 00 lui $25, 2 -# EL-R2-NEXT: 2000c: 01 d4 10 00 j 131104 -# EL-R2-NEXT: 20010: 39 33 21 00 addiu $25, $25, 33 -# EL-R2-NEXT: 20014: 00 0c nop +# RUN: ld.lld -o %t-el-r6.exe -script %t.script %t-el-r6.o %t-el-pic-r6.o +# RUN: llvm-objdump -d -mattr=+micromips --no-show-raw-insn %t-el-r6.exe \ +# RUN: | FileCheck --check-prefix=R6 %s -# EB-R6: __start: -# EB-R6-NEXT: 20000: b4 00 00 00 balc 0 <__start> +# R2: __start: +# R2-NEXT: 20100: jal 131336 <__microLA25Thunk_foo> +# R2-NEXT: nop -# EB-R6: __microLA25Thunk_foo: -# EB-R6-NEXT: 20004: 13 20 00 02 lui $25, 2 -# EB-R6-NEXT: 20008: 33 39 00 11 addiu $25, $25, 17 -# EB-R6-NEXT: 2000c: 94 00 00 00 bc 0 <__microLA25Thunk_foo+0x8> +# R2: __microLA25Thunk_foo: +# R2-NEXT: 20108: lui $25, 2 +# R2-NEXT: j 131360 +# R2-NEXT: addiu $25, $25, 289 +# R2-NEXT: nop -# EL-R6: __start: -# EL-R6-NEXT: 20000: 00 b4 00 00 balc 0 <__start> +# R6: __start: +# R6-NEXT: 20100: balc 0 <__start> -# EL-R6: __microLA25Thunk_foo: -# EL-R6-NEXT: 20004: 20 13 02 00 lui $25, 2 -# EL-R6-NEXT: 20008: 39 33 11 00 addiu $25, $25, 17 -# EL-R6-NEXT: 2000c: 00 94 00 00 bc 0 <__microLA25Thunk_foo+0x8> +# R6: __microLA25Thunk_foo: +# R6-NEXT: 20104: lui $25, 2 +# R6-NEXT: addiu $25, $25, 273 +# R6-NEXT: bc 0 <__microLA25Thunk_foo+0x8> .text .set micromips diff --git a/lld/test/ELF/mips-micror6-relocs.s b/lld/test/ELF/mips-micror6-relocs.s index fb450ba..e5d2182 100644 --- a/lld/test/ELF/mips-micror6-relocs.s +++ b/lld/test/ELF/mips-micror6-relocs.s @@ -2,32 +2,31 @@ # Check handling of microMIPS R6 relocations. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x20000; .text ALIGN(0x100) : { *(.text) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips -mcpu=mips32r6 \ # RUN: %S/Inputs/mips-micro.s -o %t1eb.o # RUN: llvm-mc -filetype=obj -triple=mips -mcpu=mips32r6 %s -o %t2eb.o -# RUN: ld.lld -o %teb.exe %t1eb.o %t2eb.o -# RUN: llvm-objdump -d -t -mattr=micromips %teb.exe \ -# RUN: | FileCheck --check-prefixes=EB,SYM %s +# RUN: ld.lld -o %teb.exe -script %t.script %t1eb.o %t2eb.o +# RUN: llvm-objdump -d -t -mattr=micromips --no-show-raw-insn %teb.exe \ +# RUN: | FileCheck %s # RUN: llvm-mc -filetype=obj -triple=mipsel -mcpu=mips32r6 \ # RUN: %S/Inputs/mips-micro.s -o %t1el.o # RUN: llvm-mc -filetype=obj -triple=mipsel -mcpu=mips32r6 %s -o %t2el.o -# RUN: ld.lld -o %tel.exe %t1el.o %t2el.o -# RUN: llvm-objdump -d -t -mattr=micromips %tel.exe \ -# RUN: | FileCheck --check-prefixes=EL,SYM %s - -# EB: __start: -# EB-NEXT: 20010: 78 47 ff fd lapc $2, -12 -# EB-NEXT: 20014: 80 7f ff f6 beqzc $3, -36 -# EB-NEXT: 20018: b7 ff ff f4 balc -24 +# RUN: ld.lld -o %tel.exe -script %t.script %t1el.o %t2el.o +# RUN: llvm-objdump -d -t -mattr=micromips --no-show-raw-insn %tel.exe \ +# RUN: | FileCheck %s -# EL: __start: -# EL-NEXT: 20010: 47 78 fd ff lapc $2, -12 -# EL-NEXT: 20014: 7f 80 f6 ff beqzc $3, -36 -# EL-NEXT: 20018: ff b7 f4 ff balc -24 +# CHECK: __start: +# CHECK-NEXT: 20110: lapc $2, -12 +# CHECK-NEXT: beqzc $3, -36 +# CHECK-NEXT: balc -24 -# SYM: 00020000 g F .text 00000000 0x80 foo -# SYM: 00020010 .text 00000000 0x80 __start +# CHECK: 00020100 g F .text 00000000 0x80 foo +# CHECK: 00020110 .text 00000000 0x80 __start .text .set micromips diff --git a/lld/test/ELF/mips-n32-rels.s b/lld/test/ELF/mips-n32-rels.s index 0e5e785..7afa3a8 100644 --- a/lld/test/ELF/mips-n32-rels.s +++ b/lld/test/ELF/mips-n32-rels.s @@ -3,9 +3,12 @@ # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \ # RUN: -target-abi n32 -o %t.o %s -# RUN: ld.lld %t.o -o %t.exe -# RUN: llvm-objdump -t -d -s %t.exe | FileCheck %s -# RUN: llvm-readobj -h %t.exe | FileCheck -check-prefix=ELF %s +# RUN: echo "SECTIONS { \ +# RUN: . = 0x20000; .text ALIGN(0x100) : { *(.text) } \ +# RUN: }" > %t.script +# RUN: ld.lld %t.o -script %t.script -o %t.exe +# RUN: llvm-objdump -t -d -s --no-show-raw-insn %t.exe | FileCheck %s +# RUN: llvm-readelf -h %t.exe | FileCheck -check-prefix=ELF %s .option pic2 .text @@ -26,47 +29,31 @@ loc: # CHECK: Disassembly of section .text: # CHECK-EMPTY: # CHECK-NEXT: __start: -# CHECK-NEXT: 20000: 3c 1c 00 01 lui $gp, 1 -# ^-- 0x20000 - 0x37ff0 -# ^-- 0 - 0xfffe8010 -# ^-- %hi(0x17ff0) +# CHECK-NEXT: 20100: lui $gp, 1 +# ^-- 0x20100 - 0x28100 +# ^-- 0 - 0xffff8000 +# ^-- %hi(0x8000) # CHECK: loc: -# CHECK-NEXT: 20004: 67 9c 7f f0 daddiu $gp, $gp, 32752 -# ^-- 0x20000 - 0x37ff0 -# ^-- 0 - 0xfffe8010 -# ^-- %lo(0x17ff0) +# CHECK-NEXT: 20104: daddiu $gp, $gp, -32768 +# ^-- 0x20100 - 0x28100 +# ^-- 0 - 0xffff8000 +# ^-- %lo(0x8000) # CHECK: Contents of section .rodata: -# CHECK-NEXT: {{[0-9a-f]+}} fffe8014 +# CHECK-NEXT: {{[0-9a-f]+}} ffff8004 # ^-- loc - _gp -# CHECK: 00020004 .text 00000000 loc -# CHECK: 00037ff0 .got 00000000 .hidden _gp -# CHECK: 00020000 g F .text 00000000 __start +# CHECK: 00020104 .text 00000000 loc +# CHECK: 00028100 .got 00000000 .hidden _gp +# CHECK: 00020100 g F .text 00000000 __start -# ELF: Format: ELF32-mips -# ELF-NEXT: Arch: mips -# ELF-NEXT: AddressSize: 32bit -# ELF-NEXT: LoadName: -# ELF-NEXT: ElfHeader { -# ELF-NEXT: Ident { -# ELF-NEXT: Magic: (7F 45 4C 46) -# ELF-NEXT: Class: 32-bit (0x1) -# ELF-NEXT: DataEncoding: BigEndian (0x2) -# ELF-NEXT: FileVersion: 1 -# ELF-NEXT: OS/ABI: SystemV (0x0) -# ELF-NEXT: ABIVersion: 0 -# ELF-NEXT: Unused: (00 00 00 00 00 00 00) -# ELF-NEXT: } -# ELF-NEXT: Type: Executable (0x2) -# ELF-NEXT: Machine: EM_MIPS (0x8) -# ELF-NEXT: Version: 1 -# ELF-NEXT: Entry: 0x20000 -# ELF-NEXT: ProgramHeaderOffset: -# ELF-NEXT: SectionHeaderOffset: -# ELF-NEXT: Flags [ -# ELF-NEXT: EF_MIPS_ABI2 -# ELF-NEXT: EF_MIPS_ARCH_64 -# ELF-NEXT: EF_MIPS_CPIC -# ELF-NEXT: EF_MIPS_PIC -# ELF-NEXT: ] +# ELF: Class: ELF32 +# ELF: Data: 2's complement, big endian +# ELF: Version: 1 (current) +# ELF: OS/ABI: UNIX - System V +# ELF: ABI Version: 0x0 +# ELF: Type: EXEC (Executable file) +# ELF: Machine: MIPS R3000 +# ELF: Version: 0x1 +# ELF: Entry point address: 0x20100 +# ELF: Flags: 0x60000026, pic, cpic, abi2, mips64 diff --git a/lld/test/ELF/mips-nonalloc.s b/lld/test/ELF/mips-nonalloc.s index 38d4599..a255a65 100644 --- a/lld/test/ELF/mips-nonalloc.s +++ b/lld/test/ELF/mips-nonalloc.s @@ -5,11 +5,13 @@ # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: %S/Inputs/mips-nonalloc.s -o %t2.o # RUN: ld.lld %t1.o %t2.o -o %t.exe -# RUN: llvm-objdump -s %t.exe | FileCheck %s +# RUN: llvm-objdump -t -s %t.exe | FileCheck %s # CHECK: Contents of section .debug_info: -# CHECK-NEXT: 0000 ffffffff 00020000 00020000 -# ^--------^-- __start +# CHECK-NEXT: 0000 ffffffff [[SYM:[0-9a-f]+]] [[SYM]] +# ^------------------^-- __start + +# CHECK: [[SYM]] .text 00000000 __start .global __start __start: diff --git a/lld/test/ELF/mips-npic-call-pic-os.s b/lld/test/ELF/mips-npic-call-pic-os.s index 1b1e551..3f08129 100644 --- a/lld/test/ELF/mips-npic-call-pic-os.s +++ b/lld/test/ELF/mips-npic-call-pic-os.s @@ -11,129 +11,61 @@ # RUN: %p/Inputs/mips-pic.s -o %t-pic.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-npic.o # RUN: ld.lld %t-npic.o %t-pic.o %t-sto-pic.o -o %t.exe -# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.exe | FileCheck %s # CHECK: Disassembly of section .text: # CHECK-EMPTY: # CHECK-NEXT: __LA25Thunk_foo1a: -# CHECK-NEXT: 20000: lui $25, 2 -# CHECK-NEXT: 20004: j 131104 -# CHECK-NEXT: 20008: addiu $25, $25, 32 -# CHECK-NEXT: 2000c: nop +# CHECK-NEXT: lui $25, 0x2 +# CHECK-NEXT: j {{.*}} +# CHECK-NEXT: addiu $25, $25, {{.*}} # CHECK: __LA25Thunk_foo1b: -# CHECK-NEXT: 20010: lui $25, 2 -# CHECK-NEXT: 20014: j 131108 -# CHECK-NEXT: 20018: addiu $25, $25, 36 -# CHECK-NEXT: 2001c: nop +# CHECK-NEXT: lui $25, 0x2 +# CHECK-NEXT: j {{.*}} +# CHECK-NEXT: addiu $25, $25, {{.*}} # CHECK: foo1a: -# CHECK-NEXT: 20020: nop +# CHECK-NEXT: nop # CHECK: foo1b: -# CHECK-NEXT: 20024: nop +# CHECK-NEXT: nop # CHECK: __LA25Thunk_foo2: -# CHECK-NEXT: 20028: lui $25, 2 -# CHECK-NEXT: 2002c: j 131136 -# CHECK-NEXT: 20030: addiu $25, $25, 64 -# CHECK-NEXT: 20034: nop +# CHECK-NEXT: lui $25, 0x2 +# CHECK-NEXT: j {{.*}} +# CHECK-NEXT: addiu $25, $25, {{.*}} # CHECK: foo2: -# CHECK-NEXT: 20040: nop +# CHECK-NEXT: nop # CHECK: __LA25Thunk_fpic: -# CHECK-NEXT: 20044: lui $25, 2 -# CHECK-NEXT: 20048: j 131168 -# CHECK-NEXT: 2004c: addiu $25, $25, 96 -# CHECK-NEXT: 20050: nop +# CHECK-NEXT: lui $25, 0x2 +# CHECK-NEXT: j {{.*}} +# CHECK-NEXT: addiu $25, $25, {{.*}} # CHECK: fpic: -# CHECK-NEXT: 20060: nop +# CHECK-NEXT: nop # CHECK: fnpic: -# CHECK-NEXT: 20070: nop +# CHECK-NEXT: nop # CHECK-EMPTY: -# CHECK-NEXT: Disassembly of section differentos: +# CHECK-NEXT: Disassembly of section .differentos: # CHECK-EMPTY: # CHECK-NEXT: __start: -# CHECK-NEXT: 20074: jal 131072 <__LA25Thunk_foo1a> -# CHECK-NEXT: 20078: nop -# CHECK-NEXT: 2007c: jal 131112 <__LA25Thunk_foo2> -# CHECK-NEXT: 20080: nop -# CHECK-NEXT: 20084: jal 131088 <__LA25Thunk_foo1b> -# CHECK-NEXT: 20088: nop -# CHECK-NEXT: 2008c: jal 131112 <__LA25Thunk_foo2> -# CHECK-NEXT: 20090: nop -# CHECK-NEXT: 20094: jal 131140 <__LA25Thunk_fpic> -# CHECK-NEXT: 20098: nop -# CHECK-NEXT: 2009c: jal 131184 -# CHECK-NEXT: 200a0: nop - -# Make sure the thunks are created properly no matter how -# objects are laid out. -# -# RUN: ld.lld %t-pic.o %t-npic.o %t-sto-pic.o -o %t.exe -# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck -check-prefix=REVERSE %s - -# REVERSE: Disassembly of section .text: -# REVERSE-EMPTY: -# REVERSE-NEXT: __LA25Thunk_foo1a: -# REVERSE-NEXT: 20000: lui $25, 2 -# REVERSE-NEXT: 20004: j 131104 -# REVERSE-NEXT: 20008: addiu $25, $25, 32 -# REVERSE-NEXT: 2000c: nop - -# REVERSE: __LA25Thunk_foo1b: -# REVERSE-NEXT: 20010: lui $25, 2 -# REVERSE-NEXT: 20014: j 131108 -# REVERSE-NEXT: 20018: addiu $25, $25, 36 -# REVERSE-NEXT: 2001c: nop - -# REVERSE: foo1a: -# REVERSE-NEXT: 20020: nop - -# REVERSE: foo1b: -# REVERSE-NEXT: 20024: nop - -# REVERSE: __LA25Thunk_foo2: -# REVERSE-NEXT: 20028: lui $25, 2 -# REVERSE-NEXT: 2002c: j 131136 -# REVERSE-NEXT: 20030: addiu $25, $25, 64 -# REVERSE-NEXT: 20034: nop - -# REVERSE: foo2: -# REVERSE-NEXT: 20040: nop - -# REVERSE: __LA25Thunk_fpic: -# REVERSE-NEXT: 20050: lui $25, 2 -# REVERSE-NEXT: 20054: j 131168 -# REVERSE-NEXT: 20058: addiu $25, $25, 96 -# REVERSE-NEXT: 2005c: nop - -# REVERSE: fpic: -# REVERSE-NEXT: 20060: nop - -# REVERSE: fnpic: -# REVERSE-NEXT: 20070: nop - -# REVERSE: Disassembly of section differentos: -# REVERSE-EMPTY: -# REVERSE-NEXT: __start: -# REVERSE-NEXT: 20074: jal 131072 <__LA25Thunk_foo1a> -# REVERSE-NEXT: 20078: nop -# REVERSE-NEXT: 2007c: jal 131112 <__LA25Thunk_foo2> -# REVERSE-NEXT: 20080: nop -# REVERSE-NEXT: 20084: jal 131088 <__LA25Thunk_foo1b> -# REVERSE-NEXT: 20088: nop -# REVERSE-NEXT: 2008c: jal 131112 <__LA25Thunk_foo2> -# REVERSE-NEXT: 20090: nop -# REVERSE-NEXT: 20094: jal 131152 <__LA25Thunk_fpic> -# REVERSE-NEXT: 20098: nop -# REVERSE-NEXT: 2009c: jal 131184 -# REVERSE-NEXT: 200a0: nop - - .section differentos, "ax", %progbits +# CHECK-NEXT: jal {{.*}} <__LA25Thunk_foo1a> +# CHECK-NEXT: nop +# CHECK-NEXT: jal {{.*}} <__LA25Thunk_foo2> +# CHECK-NEXT: nop +# CHECK-NEXT: jal {{.*}} <__LA25Thunk_foo1b> +# CHECK-NEXT: nop +# CHECK-NEXT: jal {{.*}} <__LA25Thunk_foo2> +# CHECK-NEXT: nop +# CHECK-NEXT: jal {{.*}} <__LA25Thunk_fpic> +# CHECK-NEXT: nop +# CHECK-NEXT: jal {{.*}} + + .section .differentos, "ax", %progbits .globl __start __start: jal foo1a diff --git a/lld/test/ELF/mips-npic-call-pic.s b/lld/test/ELF/mips-npic-call-pic.s index 7a99c05..5959fed 100644 --- a/lld/test/ELF/mips-npic-call-pic.s +++ b/lld/test/ELF/mips-npic-call-pic.s @@ -2,6 +2,10 @@ # Check LA25 stubs creation. This stub code is necessary when # non-PIC code calls PIC function. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x20000; .text ALIGN(0x100) : { *(.text) *(.text.*) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mcpu=mips32r2 \ # RUN: %p/Inputs/mips-fpic.s -o %t-fpic.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mcpu=mips32r2 \ @@ -11,8 +15,10 @@ # RUN: %p/Inputs/mips-pic.s -o %t-pic-r2.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mcpu=mips32r2 \ # RUN: %s -o %t-npic-r2.o -# RUN: ld.lld %t-npic-r2.o %t-pic-r2.o %t-sto-pic-r2.o -o %t-r2.exe -# RUN: llvm-objdump -d --no-show-raw-insn %t-r2.exe | FileCheck --check-prefixes=CHECK,R2 %s +# RUN: ld.lld %t-npic-r2.o %t-pic-r2.o %t-sto-pic-r2.o \ +# RUN: -script %t.script -o %t-r2.exe +# RUN: llvm-objdump -d --no-show-raw-insn %t-r2.exe \ +# RUN: | FileCheck --check-prefixes=CHECK,R2 %s # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mcpu=mips32r6 \ # RUN: %p/Inputs/mips-fpic.s -o %t-fpic.o @@ -23,135 +29,69 @@ # RUN: %p/Inputs/mips-pic.s -o %t-pic-r6.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mcpu=mips32r6 \ # RUN: %s -o %t-npic-r6.o -# RUN: ld.lld %t-npic-r6.o %t-pic-r6.o %t-sto-pic-r6.o -o %t-r6.exe -# RUN: llvm-objdump -d --no-show-raw-insn %t-r6.exe | FileCheck --check-prefixes=CHECK,R6 %s +# RUN: ld.lld %t-npic-r6.o %t-pic-r6.o %t-sto-pic-r6.o \ +# RUN: -script %t.script -o %t-r6.exe +# RUN: llvm-objdump -d --no-show-raw-insn %t-r6.exe \ +# RUN: | FileCheck --check-prefixes=CHECK,R6 %s # CHECK: Disassembly of section .text: # CHECK-EMPTY: # CHECK-NEXT: __start: -# CHECK-NEXT: 20000: jal 131120 <__LA25Thunk_foo1a> -# CHECK-NEXT: 20004: nop -# CHECK-NEXT: 20008: jal 131160 <__LA25Thunk_foo2> -# CHECK-NEXT: 2000c: nop -# CHECK-NEXT: 20010: jal 131136 <__LA25Thunk_foo1b> -# CHECK-NEXT: 20014: nop -# CHECK-NEXT: 20018: jal 131160 <__LA25Thunk_foo2> -# CHECK-NEXT: 2001c: nop -# CHECK-NEXT: 20020: jal 131188 <__LA25Thunk_fpic> -# CHECK-NEXT: 20024: nop -# CHECK-NEXT: 20028: jal 131232 -# CHECK-NEXT: 2002c: nop -# -# CHECK: __LA25Thunk_foo1a: -# R2: 20030: lui $25, 2 -# R6: 20030: aui $25, $zero, 2 -# CHECK: 20034: j 131152 -# CHECK-NEXT: 20038: addiu $25, $25, 80 -# CHECK-NEXT: 2003c: nop - -# CHECK: __LA25Thunk_foo1b: -# R2: 20040: lui $25, 2 -# R6: 20040: aui $25, $zero, 2 -# CHECK-NEXT: 20044: j 131156 -# CHECK-NEXT: 20048: addiu $25, $25, 84 -# CHECK-NEXT: 2004c: nop - -# CHECK: foo1a: -# CHECK-NEXT: 20050: nop - -# CHECK: foo1b: -# CHECK-NEXT: 20054: nop - -# CHECK: __LA25Thunk_foo2: -# R2: 20058: lui $25, 2 -# R6: 20058: aui $25, $zero, 2 -# CHECK-NEXT: 2005c: j 131184 -# CHECK-NEXT: 20060: addiu $25, $25, 112 -# CHECK-NEXT: 20064: nop - -# CHECK: foo2: -# CHECK-NEXT: 20070: nop +# CHECK-NEXT: 20100: jal 131412 <__LA25Thunk_foo1a> +# CHECK-NEXT: nop +# CHECK-NEXT: jal 131464 <__LA25Thunk_foo2> +# CHECK-NEXT: nop +# CHECK-NEXT: jal 131428 <__LA25Thunk_foo1b> +# CHECK-NEXT: nop +# CHECK-NEXT: jal 131464 <__LA25Thunk_foo2> +# CHECK-NEXT: nop +# CHECK-NEXT: jal 131376 <__LA25Thunk_fpic> +# CHECK-NEXT: nop +# CHECK-NEXT: jal 131408 +# CHECK-NEXT: nop # CHECK: __LA25Thunk_fpic: -# R2: 20074: lui $25, 2 -# R6: 20074: aui $25, $zero, 2 -# CHECK-NEXT: 20078: j 131216 -# CHECK-NEXT: 2007c: addiu $25, $25, 144 -# CHECK-NEXT: 20080: nop +# R2: 20130: lui $25, 2 +# R6: 20130: aui $25, $zero, 2 +# CHECK-NEXT: j 131392 +# CHECK-NEXT: addiu $25, $25, 320 +# CHECK-NEXT: nop # CHECK: fpic: -# CHECK-NEXT: 20090: nop +# CHECK-NEXT: 20140: nop # CHECK: fnpic: -# CHECK-NEXT: 200a0: nop +# CHECK-NEXT: 20150: nop -# Make sure the thunks are created properly no matter how -# objects are laid out. -# -# RUN: ld.lld %t-pic-r2.o %t-npic-r2.o %t-sto-pic-r2.o -o %t.exe -# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck -check-prefixes=REVERSE,REV-R2 %s -# -# RUN: ld.lld %t-pic-r6.o %t-npic-r6.o %t-sto-pic-r6.o -o %t.exe -# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck -check-prefixes=REVERSE,REV-R6 %s - -# REVERSE: Disassembly of section .text: -# REVERSE-EMPTY: -# REVERSE-NEXT: __LA25Thunk_foo1a: -# REV-R2: 20000: lui $25, 2 -# REV-R6: 20000: aui $25, $zero, 2 -# REVERSE: 20004: j 131104 -# REVERSE-NEXT: 20008: addiu $25, $25, 32 -# REVERSE-NEXT: 2000c: nop - -# REVERSE: __LA25Thunk_foo1b: -# REV-R2: 20010: lui $25, 2 -# REV-R6: 20010: aui $25, $zero, 2 -# REVERSE: 20014: j 131108 -# REVERSE-NEXT: 20018: addiu $25, $25, 36 -# REVERSE-NEXT: 2001c: nop - -# REVERSE: foo1a: -# REVERSE-NEXT: 20020: nop - -# REVERSE: foo1b: -# REVERSE-NEXT: 20024: nop - -# REVERSE: __LA25Thunk_foo2: -# REV-R2: 20028: lui $25, 2 -# REV-R6: 20028: aui $25, $zero, 2 -# REVERSE: 2002c: j 131136 -# REVERSE-NEXT: 20030: addiu $25, $25, 64 -# REVERSE-NEXT: 20034: nop +# CHECK: __LA25Thunk_foo1a: +# R2: 20154: lui $25, 2 +# R6: 20154: aui $25, $zero, 2 +# CHECK: j 131456 +# CHECK-NEXT: addiu $25, $25, 384 +# CHECK-NEXT: nop -# REVERSE: foo2: -# REVERSE-NEXT: 20040: nop +# CHECK: __LA25Thunk_foo1b: +# R2: 20164: lui $25, 2 +# R6: aui $25, $zero, 2 +# CHECK-NEXT: j 131460 +# CHECK-NEXT: addiu $25, $25, 388 +# CHECK-NEXT: nop -# REVERSE: __start: -# REVERSE-NEXT: 20050: jal 131072 <__LA25Thunk_foo1a> -# REVERSE-NEXT: 20054: nop -# REVERSE-NEXT: 20058: jal 131112 <__LA25Thunk_foo2> -# REVERSE-NEXT: 2005c: nop -# REVERSE-NEXT: 20060: jal 131088 <__LA25Thunk_foo1b> -# REVERSE-NEXT: 20064: nop -# REVERSE-NEXT: 20068: jal 131112 <__LA25Thunk_foo2> -# REVERSE-NEXT: 2006c: nop -# REVERSE-NEXT: 20070: jal 131200 <__LA25Thunk_fpic> -# REVERSE-NEXT: 20074: nop -# REVERSE-NEXT: 20078: jal 131232 -# REVERSE-NEXT: 2007c: nop +# CHECK: foo1a: +# CHECK-NEXT: 20180: nop -# REVERSE: __LA25Thunk_fpic: -# REV-R2: 20080: lui $25, 2 -# REV-R6: 20080: aui $25, $zero, 2 -# REVERSE: 20084: j 131216 -# REVERSE-NEXT: 20088: addiu $25, $25, 144 -# REVERSE-NEXT: 2008c: nop +# CHECK: foo1b: +# CHECK-NEXT: 20184: nop -# REVERSE: fpic: -# REVERSE-NEXT: 20090: nop +# CHECK: __LA25Thunk_foo2: +# R2: 20188: lui $25, 2 +# R6: aui $25, $zero, 2 +# CHECK-NEXT: j 131488 +# CHECK-NEXT: addiu $25, $25, 416 +# CHECK-NEXT: nop -# REVERSE: fnpic: -# REVERSE-NEXT: 200a0: nop +# CHECK: foo2: +# CHECK-NEXT: 201a0: nop .text .globl __start diff --git a/lld/test/ELF/mips-pc-relocs.s b/lld/test/ELF/mips-pc-relocs.s index ecacc8a..06d4644 100644 --- a/lld/test/ELF/mips-pc-relocs.s +++ b/lld/test/ELF/mips-pc-relocs.s @@ -5,8 +5,13 @@ # RUN: -mcpu=mips32r6 %s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mcpu=mips32r6 %S/Inputs/mips-dynamic.s -o %t2.o -# RUN: ld.lld %t1.o %t2.o -o %t.exe -# RUN: llvm-objdump -mcpu=mips32r6 -d -t -s --no-show-raw-insn %t.exe | FileCheck %s +# RUN: echo "SECTIONS { \ +# RUN: . = 0x10000; .text ALIGN(0x10000) : { *(.text) } \ +# RUN: . = 0x30000; .data : { *(.data) } \ +# RUN: }" > %t.script +# RUN: ld.lld %t1.o %t2.o -script %t.script -o %t.exe +# RUN: llvm-objdump -mcpu=mips32r6 -d -t -s --no-show-raw-insn %t.exe \ +# RUN: | FileCheck %s .text .globl __start @@ -25,17 +30,17 @@ __start: # CHECK-EMPTY: # CHECK-NEXT: __start: # CHECK-NEXT: 20000: lwpc $6, 32 -# ^-- (0x20020-0x20000)>>2 +# ^-- (0x20020-0x20000)>>2 # CHECK-NEXT: 20004: beqc $5, $6, 28 -# ^-- (0x20020-4-0x20004)>>2 +# ^-- (0x20020-4-0x20004)>>2 # CHECK-NEXT: 20008: beqzc $9, 24 -# ^-- (0x20020-4-0x20008)>>2 +# ^-- (0x20020-4-0x20008)>>2 # CHECK-NEXT: 2000c: bc 20 -# ^-- (0x20020-4-0x2000c)>>2 +# ^-- (0x20020-4-0x2000c)>>2 # CHECK-NEXT: 20010: aluipc $2, 0 -# ^-- %hi(0x20020-0x20010) +# ^-- %hi(0x20020-0x20010) # CHECK-NEXT: 20014: addiu $2, $2, 12 -# ^-- %lo(0x20020-0x20014) +# ^-- %lo(0x20020-0x20014) # CHECK: Contents of section .data: # CHECK-NEXT: 30000 ffff0028 00000000 00000000 00000000 diff --git a/lld/test/ELF/mips-plt-n32.s b/lld/test/ELF/mips-plt-n32.s index 6091edc..3d509f8 100644 --- a/lld/test/ELF/mips-plt-n32.s +++ b/lld/test/ELF/mips-plt-n32.s @@ -2,16 +2,23 @@ # Check PLT entries generation in case of using N32 ABI. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x10000; .text ALIGN(0x10000) : { *(.text) } \ +# RUN: . = 0x30000; .data : { *(.data) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \ # RUN: -target-abi n32 %s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \ # RUN: -target-abi n32 %S/Inputs/mips-dynamic.s -o %t2.o # RUN: ld.lld %t2.o -shared -soname=t.so -o %t.so -# RUN: ld.lld %t1.o %t.so -o %t.exe -# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s --check-prefixes=DEFAULT,CHECK +# RUN: ld.lld %t1.o %t.so -script %t.script -o %t.exe +# RUN: llvm-objdump -d --no-show-raw-insn %t.exe \ +# RUN: | FileCheck %s --check-prefixes=DEFAULT,CHECK # RUN: ld.lld %t2.o -shared -soname=t.so -o %t.so -z hazardplt -# RUN: ld.lld %t1.o %t.so -o %t.exe -z hazardplt -# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s --check-prefixes=HAZARDPLT,CHECK +# RUN: ld.lld %t1.o %t.so -script %t.script -o %t.exe -z hazardplt +# RUN: llvm-objdump -d --no-show-raw-insn %t.exe \ +# RUN: | FileCheck %s --check-prefixes=HAZARDPLT,CHECK # CHECK: Disassembly of section .text: # CHECK-EMPTY: diff --git a/lld/test/ELF/mips-plt-n64.s b/lld/test/ELF/mips-plt-n64.s index 212458e..dd98513 100644 --- a/lld/test/ELF/mips-plt-n64.s +++ b/lld/test/ELF/mips-plt-n64.s @@ -1,15 +1,22 @@ # REQUIRES: mips # Check R_MIPS_26 relocation handling in case of N64 ABIs. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x10000; .text ALIGN(0x10000) : { *(.text) } \ +# RUN: . = 0x30000; .data : { *(.data) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \ # RUN: %S/Inputs/mips-dynamic.s -o %t-so.o # RUN: ld.lld %t-so.o -shared -soname=t.so -o %t.so # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o -# RUN: ld.lld %t.o %t.so -o %t.exe -# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s --check-prefixes=CHECK,DEFAULT +# RUN: ld.lld %t.o %t.so -script %t.script -o %t.exe +# RUN: llvm-objdump -d --no-show-raw-insn %t.exe \ +# RUN: | FileCheck %s --check-prefixes=CHECK,DEFAULT # RUN: ld.lld %t-so.o -shared -soname=t.so -o %t.so -z hazardplt -# RUN: ld.lld %t.o %t.so -o %t.exe -z hazardplt -# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s --check-prefixes=CHECK,HAZARDPLT +# RUN: ld.lld %t.o %t.so -script %t.script -o %t.exe -z hazardplt +# RUN: llvm-objdump -d --no-show-raw-insn %t.exe \ +# RUN: | FileCheck %s --check-prefixes=CHECK,HAZARDPLT # CHECK: Disassembly of section .text: # CHECK-EMPTY: diff --git a/lld/test/ELF/mips-plt-r6.s b/lld/test/ELF/mips-plt-r6.s index 3d49051d..206cdf1 100644 --- a/lld/test/ELF/mips-plt-r6.s +++ b/lld/test/ELF/mips-plt-r6.s @@ -1,15 +1,20 @@ # REQUIRES: mips # Check PLT entries generation in case of R6 ABI version. +# RUN: echo "SECTIONS { \ +# RUN: . = 0x10000; .text ALIGN(0x10000) : { *(.text) } \ +# RUN: . = 0x30000; .data : { *(.data) } \ +# RUN: }" > %t.script + # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mcpu=mips32r6 %s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mcpu=mips32r6 %S/Inputs/mips-dynamic.s -o %t2.o # RUN: ld.lld %t2.o -shared -soname=t.so -o %t.so -# RUN: ld.lld %t1.o %t.so -o %t.exe +# RUN: ld.lld %t1.o %t.so -script %t.script -o %t.exe # RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s --check-prefixes=DEFAULT,CHECK # RUN: ld.lld %t2.o -shared -soname=t.so -o %t.so -z hazardplt -# RUN: ld.lld %t1.o %t.so -o %t.exe -z hazardplt +# RUN: ld.lld %t1.o %t.so -script %t.script -o %t.exe -z hazardplt # RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s --check-prefixes=HAZARDPLT,CHECK # CHECK: Disassembly of section .text: diff --git a/lld/test/ELF/mips-tls-64-pic-local-variable.s b/lld/test/ELF/mips-tls-64-pic-local-variable.s index 04d916f..b482458 100644 --- a/lld/test/ELF/mips-tls-64-pic-local-variable.s +++ b/lld/test/ELF/mips-tls-64-pic-local-variable.s @@ -1,11 +1,17 @@ # REQUIRES: mips -# MIPS TLS variables that are marked as local by a version script were previously -# writing values to the GOT that caused runtime crashes. This was happending when -# linking jemalloc_tsd.c in FreeBSD libc. Check that we do the right thing now: + +# MIPS TLS variables that are marked as local by a version script were +# previously writing values to the GOT that caused runtime crashes. This +# was happending when linking jemalloc_tsd.c in FreeBSD libc. Check that +# we do the right thing now: # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-freebsd %s -o %t.o # RUN: echo "{ global: foo; local: *; };" > %t.script -# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so +# RUN: echo "SECTIONS { \ +# RUN: . = 0x10000; .text : { *(.text) } \ +# RUN: . = 0x20000; .got : { *(.got) } \ +# RUN: }" > %t.script1 +# RUN: ld.lld --version-script %t.script -script %t.script1 -shared %t.o -o %t.so # RUN: llvm-objdump --section=.got -s %t.so | FileCheck %s -check-prefix GOT # RUN: llvm-readobj -r %t.so | FileCheck %s -check-prefix RELOCS @@ -18,7 +24,9 @@ # RELOCS-NEXT: 0x20018 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE # RELOCS-NEXT: } -# Test case generated using clang -mcpu=mips4 -target mips64-unknown-freebsd12.0 -fpic -O -G0 -EB -mabi=n64 -msoft-float -std=gnu99 -S %s -o %t.s +# Test case generated using: +# clang -mcpu=mips4 -target mips64-unknown-freebsd12.0 \ +# -fpic -O -G0 -EB -mabi=n64 -msoft-float -std=gnu99 -S %s -o %t.s # from the following source: # # _Thread_local int x; @@ -45,5 +53,3 @@ foo: x: .4byte 0 .size x, 4 - - diff --git a/lld/test/ELF/mips-tls-64.s b/lld/test/ELF/mips-tls-64.s index 14b9aa8..f0b7618 100644 --- a/lld/test/ELF/mips-tls-64.s +++ b/lld/test/ELF/mips-tls-64.s @@ -6,27 +6,32 @@ # RUN: ld.lld -shared %t.so.o -soname=t.so -o %t.so # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o -# RUN: ld.lld %t.o %t.so -o %t.exe +# RUN: echo "SECTIONS { \ +# RUN: . = 0x10000; .text : { *(.text) } \ +# RUN: . = 0x30000; .got : { *(.got) } \ +# RUN: }" > %t.script + +# RUN: ld.lld %t.o %t.so -script %t.script -o %t.exe # RUN: llvm-objdump -d -s -t --no-show-raw-insn %t.exe | FileCheck -check-prefix=DIS %s # RUN: llvm-readobj -r --mips-plt-got %t.exe | FileCheck %s -# RUN: ld.lld -shared %t.o %t.so -o %t-out.so +# RUN: ld.lld -shared %t.o %t.so -script %t.script -o %t-out.so # RUN: llvm-objdump -d -s -t --no-show-raw-insn %t-out.so | FileCheck -check-prefix=DIS-SO %s # RUN: llvm-readobj -r --mips-plt-got %t-out.so | FileCheck -check-prefix=SO %s # DIS: __start: -# DIS-NEXT: 20000: addiu $2, $3, -32720 -# DIS-NEXT: 20004: addiu $2, $3, -32736 -# DIS-NEXT: 20008: addiu $2, $3, -32704 -# DIS-NEXT: 2000c: addiu $2, $3, -32688 -# DIS-NEXT: 20010: addiu $2, $3, -32728 +# DIS-NEXT: addiu $2, $3, -32720 +# DIS-NEXT: addiu $2, $3, -32736 +# DIS-NEXT: addiu $2, $3, -32704 +# DIS-NEXT: addiu $2, $3, -32688 +# DIS-NEXT: addiu $2, $3, -32728 # DIS: Contents of section .got: -# DIS-NEXT: 40010 00000000 00000000 80000000 00000000 -# DIS-NEXT: 40020 00000000 00000000 ffffffff ffff9004 -# DIS-NEXT: 40030 00000000 00000000 00000000 00000000 -# DIS-NEXT: 40040 00000000 00000001 00000000 00000000 -# DIS-NEXT: 40050 00000000 00000001 ffffffff ffff8004 +# DIS-NEXT: 30000 00000000 00000000 80000000 00000000 +# DIS-NEXT: 30010 00000000 00000000 ffffffff ffff9004 +# DIS-NEXT: 30020 00000000 00000000 00000000 00000000 +# DIS-NEXT: 30030 00000000 00000001 00000000 00000000 +# DIS-NEXT: 30040 00000000 00000001 ffffffff ffff8004 # DIS: 0000000000000000 l O .tdata 00000000 loc # DIS: 0000000000000004 g O .tdata 00000000 bar @@ -34,13 +39,13 @@ # CHECK: Relocations [ # CHECK-NEXT: Section (7) .rel.dyn { -# CHECK-NEXT: 0x40020 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0 -# CHECK-NEXT: 0x40030 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0 -# CHECK-NEXT: 0x40038 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0 +# CHECK-NEXT: 0x30010 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0 +# CHECK-NEXT: 0x30020 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0 +# CHECK-NEXT: 0x30028 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0 # CHECK-NEXT: } # CHECK-NEXT: ] # CHECK-NEXT: Primary GOT { -# CHECK-NEXT: Canonical gp value: 0x48000 +# CHECK-NEXT: Canonical gp value: 0x37FF0 # CHECK-NEXT: Reserved entries [ # CHECK: ] # CHECK-NEXT: Local entries [ diff --git a/lld/test/ELF/mips-tls-hilo.s b/lld/test/ELF/mips-tls-hilo.s index 5fa15ab..abac8fa 100644 --- a/lld/test/ELF/mips-tls-hilo.s +++ b/lld/test/ELF/mips-tls-hilo.s @@ -11,14 +11,14 @@ # RUN: llvm-readobj -r --mips-plt-got %t.so | FileCheck -check-prefix=SO %s # DIS: __start: -# DIS-NEXT: 20000: addiu $2, $3, 0 -# %hi(loc0 - .tdata - 0x8000) --^ -# DIS-NEXT: 20004: addiu $2, $3, -32768 -# %lo(loc0 - .tdata - 0x8000) --^ -# DIS-NEXT: 20008: addiu $2, $3, 0 -# %hi(loc0 - .tdata - 0x7000) --^ -# DIS-NEXT: 2000c: addiu $2, $3, -28672 -# %lo(loc0 - .tdata - 0x7000) --^ +# DIS-NEXT: addiu $2, $3, 0 +# ^-- %hi(loc0 - .tdata - 0x8000) +# DIS-NEXT: addiu $2, $3, -32768 +# ^-- %lo(loc0 - .tdata - 0x8000) +# DIS-NEXT: addiu $2, $3, 0 +# ^-- %hi(loc0 - .tdata - 0x7000) +# DIS-NEXT: addiu $2, $3, -28672 +# ^-- %lo(loc0 - .tdata - 0x7000) # DIS: 00000000 l O .tdata 00000000 loc0 diff --git a/lld/test/ELF/mips-tls-static-64.s b/lld/test/ELF/mips-tls-static-64.s index f2da42e..26b5195 100644 --- a/lld/test/ELF/mips-tls-static-64.s +++ b/lld/test/ELF/mips-tls-static-64.s @@ -7,11 +7,11 @@ # RUN: llvm-objdump -s -t %t.exe | FileCheck %s # CHECK: Contents of section .data: -# CHECK-NEXT: 40000 00020004 ffffffff ffff8004 ffffffff -# CHECK-NEXT: 40010 ffff9004 +# CHECK-NEXT: {{.*}} [[TGA:[0-9a-f]+]] ffffffff ffff8004 ffffffff +# CHECK-NEXT: {{.*}} ffff9004 # # CHECK: SYMBOL TABLE: -# CHECK: 0000000000020004 .text 00000000 __tls_get_addr +# CHECK: [[TGA]] .text 00000000 __tls_get_addr # CHECK: 0000000000000000 g O .tdata 00000000 tls1 .text diff --git a/lld/test/ELF/mips-tls-static.s b/lld/test/ELF/mips-tls-static.s index 4062f85..877a38a 100644 --- a/lld/test/ELF/mips-tls-static.s +++ b/lld/test/ELF/mips-tls-static.s @@ -7,13 +7,13 @@ # RUN: llvm-objdump -s -t %t.exe | FileCheck %s # CHECK: Contents of section .data: -# CHECK-NEXT: 40000 0002000c ffff8004 ffff9004 +# CHECK-NEXT: {{.*}} [[TGA:[0-9a-f]+]] ffff8004 ffff9004 # CHECK: Contents of section .got: -# CHECK-NEXT: 40010 00000000 80000000 ffff9000 00000001 -# CHECK-NEXT: 40020 ffff8000 00000001 00000000 +# CHECK-NEXT: {{.*}} 00000000 80000000 ffff9000 00000001 +# CHECK-NEXT: {{.*}} ffff8000 00000001 00000000 # # CHECK: SYMBOL TABLE: -# CHECK: 0002000c .text 00000000 __tls_get_addr +# CHECK: [[TGA]] .text 00000000 __tls_get_addr # CHECK: 00000000 g O .tdata 00000000 tls1 .text diff --git a/lld/test/ELF/mips-tls.s b/lld/test/ELF/mips-tls.s index 1f8d826..842c2df 100644 --- a/lld/test/ELF/mips-tls.s +++ b/lld/test/ELF/mips-tls.s @@ -6,25 +6,30 @@ # RUN: ld.lld -shared %t.so.o -soname=t.so -o %t.so # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o -# RUN: ld.lld %t.o %t.so -o %t.exe +# RUN: echo "SECTIONS { \ +# RUN: . = 0x10000; .text : { *(.text) } \ +# RUN: . = 0x30000; .got : { *(.got) } \ +# RUN: }" > %t.script + +# RUN: ld.lld %t.o %t.so -script %t.script -o %t.exe # RUN: llvm-objdump -d -s -t --no-show-raw-insn %t.exe | FileCheck -check-prefix=DIS %s # RUN: llvm-readobj -r --mips-plt-got %t.exe | FileCheck %s -# RUN: ld.lld -shared %t.o %t.so -o %t-out.so +# RUN: ld.lld -shared %t.o %t.so -script %t.script -o %t-out.so # RUN: llvm-objdump -d -s -t --no-show-raw-insn %t-out.so | FileCheck -check-prefix=DIS-SO %s # RUN: llvm-readobj -r --mips-plt-got %t-out.so | FileCheck -check-prefix=SO %s # DIS: __start: -# DIS-NEXT: 20000: addiu $2, $3, -32736 -# DIS-NEXT: 20004: addiu $2, $3, -32744 -# DIS-NEXT: 20008: addiu $2, $3, -32728 -# DIS-NEXT: 2000c: addiu $2, $3, -32720 -# DIS-NEXT: 20010: addiu $2, $3, -32740 +# DIS-NEXT: addiu $2, $3, -32736 +# DIS-NEXT: addiu $2, $3, -32744 +# DIS-NEXT: addiu $2, $3, -32728 +# DIS-NEXT: addiu $2, $3, -32720 +# DIS-NEXT: addiu $2, $3, -32740 # DIS: Contents of section .got: -# DIS-NEXT: 40010 00000000 80000000 00000000 ffff9004 -# DIS-NEXT: 40020 00000000 00000000 00000001 00000000 -# DIS-NEXT: 40030 00000001 ffff8004 +# DIS-NEXT: 30000 00000000 80000000 00000000 ffff9004 +# DIS-NEXT: 30010 00000000 00000000 00000001 00000000 +# DIS-NEXT: 30020 00000001 ffff8004 # DIS: 00000000 l O .tdata 00000000 loc # DIS: 00000004 g O .tdata 00000000 bar @@ -32,13 +37,13 @@ # CHECK: Relocations [ # CHECK-NEXT: Section (7) .rel.dyn { -# CHECK-NEXT: 0x40018 R_MIPS_TLS_TPREL32 foo 0x0 -# CHECK-NEXT: 0x40020 R_MIPS_TLS_DTPMOD32 foo 0x0 -# CHECK-NEXT: 0x40024 R_MIPS_TLS_DTPREL32 foo 0x0 +# CHECK-NEXT: 0x30008 R_MIPS_TLS_TPREL32 foo 0x0 +# CHECK-NEXT: 0x30010 R_MIPS_TLS_DTPMOD32 foo 0x0 +# CHECK-NEXT: 0x30014 R_MIPS_TLS_DTPREL32 foo 0x0 # CHECK-NEXT: } # CHECK-NEXT: ] # CHECK-NEXT: Primary GOT { -# CHECK-NEXT: Canonical gp value: 0x48000 +# CHECK-NEXT: Canonical gp value: 0x37FF0 # CHECK-NEXT: Reserved entries [ # CHECK: ] # CHECK-NEXT: Local entries [ diff --git a/lld/test/ELF/mips-xgot-order.s b/lld/test/ELF/mips-xgot-order.s index 483feef..a9925d2 100644 --- a/lld/test/ELF/mips-xgot-order.s +++ b/lld/test/ELF/mips-xgot-order.s @@ -4,33 +4,36 @@ # 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 -s -t --no-show-raw-insn %t.exe | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s +# RUN: llvm-readelf -s -mips-plt-got %t.exe | FileCheck -check-prefix=GOT %s # CHECK: Disassembly of section .text: # CHECK-EMPTY: # CHECK-NEXT: __start: -# CHECK-NEXT: 20000: lui $2, 0 -# CHECK-NEXT: 20004: lw $2, -32732($2) -# CHECK-NEXT: 20008: lui $2, 0 -# CHECK-NEXT: 2000c: lw $2, -32728($2) +# CHECK-NEXT: lui $2, 0 +# CHECK-NEXT: lw $2, -32732($2) +# CHECK-NEXT: lui $2, 0 +# CHECK-NEXT: lw $2, -32728($2) # # CHECK: bar: -# CHECK-NEXT: 20010: lw $2, -32736($2) -# CHECK-NEXT: 20014: lw $2, -32744($2) -# CHECK-NEXT: 20018: addi $2, $2, 0 +# CHECK-NEXT: lw $2, -32736($2) +# CHECK-NEXT: lw $2, -32744($2) +# CHECK-NEXT: addi $2, $2, {{.*}} -# CHECK: Contents of section .got: -# CHECK-NEXT: 30010 00000000 80000000 00030000 00040000 -# ^ %hi(loc) -# ^ redundant entry -# CHECK-NEXT: 30020 00020010 00020000 00030000 -# ^ %got(bar) -# ^ %got_hi/lo(start) -# ^ %got_hi/lo(loc) +# GOT: Symbol table '.symtab' +# GOT: Num: Value Size Type Bind Vis Ndx Name +# GOT: [[LOC:[0-9a-f]+]] 0 NOTYPE LOCAL DEFAULT 4 loc +# GOT: [[START:[0-9a-f]+]] 0 NOTYPE GLOBAL DEFAULT 3 __start +# GOT: [[BAR:[0-9a-f]+]] 0 NOTYPE GLOBAL DEFAULT 3 bar -# CHECK: 00030000 .data 00000000 loc -# CHECK: 00020000 .text 00000000 __start -# CHECK: 00020010 .text 00000000 bar +# GOT: Static GOT: +# GOT: Local entries: +# GOT: Address Access Initial +# GOT-NEXT: -32744(gp) 00030000 +# GOT-NEXT: -32740(gp) 00040000 +# GOT-NEXT: -32736(gp) [[BAR]] +# GOT-NEXT: -32732(gp) [[START]] +# GOT-NEXT: -32728(gp) [[LOC]] .text .global __start, bar diff --git a/lld/test/ELF/rel-addend-with-rela-input.s b/lld/test/ELF/rel-addend-with-rela-input.s index 88b5ece..2dc5ead 100644 --- a/lld/test/ELF/rel-addend-with-rela-input.s +++ b/lld/test/ELF/rel-addend-with-rela-input.s @@ -3,36 +3,42 @@ # uses Elf_Rela # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t-rela.o -# RUN: llvm-readobj -h -S --section-data -r %t-rela.o | FileCheck -check-prefix INPUT-RELA %s +# RUN: llvm-readobj -h -S --section-data -r %t-rela.o \ +# RUN: | FileCheck -check-prefix INPUT-RELA %s + # INPUT-RELA: ElfHeader { # INPUT-RELA: Class: 64-bit # INPUT-RELA: DataEncoding: BigEndian # INPUT-RELA: Section { # INPUT-RELA: Name: .data # INPUT-RELA: SectionData ( -# INPUT-RELA-NEXT: 0000: 00000000 00000000 ABCDEF00 12345678 |.............4Vx| -# ^--- No addend here since it uses RELA +# INPUT-RELA-NEXT: 0000: 00000000 00000000 ABCDEF00 12345678 +# ^--- No addend here since it uses RELA # INPUT-RELA: Relocations [ # INPUT-RELA-NEXT: Section ({{.+}}) .rela.data { # INPUT-RELA-NEXT: 0x0 R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE foo 0x5544 # INPUT-RELA-NEXT: } # INPUT-RELA-NEXT: ] -# Previously the addend to the dynamic relocation in the .data section was not copied if -# the input file used RELA and the output uses REL. Check that it works now: +# Previously the addend to the dynamic relocation in the .data section +# was not copied if the input file used RELA and the output uses REL. +# Check that it works now: # RUN: ld.lld -shared -o %t.so %t-rela.o -verbose -# RUN: llvm-readobj -h -S --section-data -r %t.so | FileCheck -check-prefix RELA-TO-REL %s +# RUN: llvm-readobj -h -S --section-data -r %t.so \ +# RUN: | FileCheck -check-prefix RELA-TO-REL %s + # RELA-TO-REL: ElfHeader { # RELA-TO-REL: Class: 64-bit # RELA-TO-REL: DataEncoding: BigEndian # RELA-TO-REL: Section { # RELA-TO-REL: Name: .data +# RELA-TO-REL: Address: 0x[[DATA:[0-9A-F]+]] # RELA-TO-REL: SectionData ( -# RELA-TO-REL-NEXT: 0000: 00000000 00005544 ABCDEF00 12345678 |......UD.....4Vx| -# ^--- Addend for relocation in .rel.dyn +# RELA-TO-REL-NEXT: 0000: 00000000 00005544 ABCDEF00 12345678 +# ^--- Addend for relocation in .rel.dyn # RELA-TO-REL: Relocations [ # RELA-TO-REL-NEXT: Section ({{.+}}) .rel.dyn { -# RELA-TO-REL-NEXT: 0x10000 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE foo 0x0 +# RELA-TO-REL-NEXT: 0x[[DATA]] R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE foo 0x0 # RELA-TO-REL-NEXT: } # RELA-TO-REL-NEXT: ] -- 2.7.4