Skip to content
Permalink
Browse files

[mips] Make another set of test cases more tolerant to exact symbol a…

…ddresses. NFC

llvm-svn: 371458
  • Loading branch information...
atanasyan committed Sep 9, 2019
1 parent 4f68c22 commit 2439b8b0c5f384561e005a64efe5c36b1007c6ff
@@ -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
@@ -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 <micro>
# 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]+]] <micro>
# 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 <bar>
# REG-NEXT: lui $25, 0x2
# REG-NEXT: j 0x[[BAR:[0-9a-f]+]] <bar>

# 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]+]] <foo>

# 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
@@ -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

0 comments on commit 2439b8b

Please sign in to comment.
You can’t perform that action at this time.