summaryrefslogtreecommitdiffstats
path: root/lld/test
diff options
context:
space:
mode:
Diffstat (limited to 'lld/test')
-rw-r--r--lld/test/CMakeLists.txt2
-rw-r--r--lld/test/elf/Mips/base-address.test16
-rw-r--r--lld/test/elf/Mips/dynlib-fileheader-micro.test5
-rw-r--r--lld/test/elf/Mips/dynlib-fileheader.test5
-rw-r--r--lld/test/elf/Mips/mips-options-gp0.test17
-rw-r--r--lld/test/elf/Mips/reginfo-01.test30
-rw-r--r--lld/test/elf/Mips/reginfo-02.test74
-rw-r--r--lld/test/elf/Mips/reginfo-03.test40
-rw-r--r--lld/test/elf/Mips/reginfo-04.test76
-rw-r--r--lld/test/elf/Mips/reginfo-05.test118
-rw-r--r--lld/test/elf/Mips/rel-gprel16.test12
-rw-r--r--lld/test/elf/Mips/rel-gprel32.test8
12 files changed, 357 insertions, 46 deletions
diff --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index e29f5f4c5a9..dff9903f925 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -20,7 +20,7 @@ configure_lit_site_cfg(
)
set(LLD_TEST_DEPS
- FileCheck not llvm-nm
+ FileCheck not llvm-ar llvm-nm
lld llvm-config llvm-objdump llvm-readobj yaml2obj obj2yaml
linker-script-test macho-dump llvm-mc llvm-nm
)
diff --git a/lld/test/elf/Mips/base-address.test b/lld/test/elf/Mips/base-address.test
index f55091f84c3..5f629a4b434 100644
--- a/lld/test/elf/Mips/base-address.test
+++ b/lld/test/elf/Mips/base-address.test
@@ -77,16 +77,6 @@ Sections:
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x04
Size: 0x00
- - Name: .reginfo
- Type: SHT_MIPS_REGINFO
- Flags: [ SHF_ALLOC ]
- AddressAlign: 0x01
- Size: 0x18
- - Name: .MIPS.abiflags
- Type: SHT_MIPS_ABIFLAGS
- Flags: [ SHF_ALLOC ]
- AddressAlign: 0x08
- Content: '000020010101000100000000000000000000000000000000'
Symbols:
Local:
- Name: .text
@@ -98,12 +88,6 @@ Symbols:
- Name: .bss
Type: STT_SECTION
Section: .bss
- - Name: .reginfo
- Type: STT_SECTION
- Section: .reginfo
- - Name: .MIPS.abiflags
- Type: STT_SECTION
- Section: .MIPS.abiflags
Global:
- Name: main
Section: .text
diff --git a/lld/test/elf/Mips/dynlib-fileheader-micro.test b/lld/test/elf/Mips/dynlib-fileheader-micro.test
index 139b3aa626c..5572160b5aa 100644
--- a/lld/test/elf/Mips/dynlib-fileheader-micro.test
+++ b/lld/test/elf/Mips/dynlib-fileheader-micro.test
@@ -64,11 +64,6 @@ Sections:
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x04
Size: 0x00
- - Name: .reginfo
- Type: SHT_MIPS_REGINFO
- Flags: [ SHF_ALLOC ]
- AddressAlign: 0x01
- Size: 0x18
- Name: .MIPS.abiflags
Type: SHT_MIPS_ABIFLAGS
Flags: [ SHF_ALLOC ]
diff --git a/lld/test/elf/Mips/dynlib-fileheader.test b/lld/test/elf/Mips/dynlib-fileheader.test
index 5dd9d6a64a7..426e07d05c7 100644
--- a/lld/test/elf/Mips/dynlib-fileheader.test
+++ b/lld/test/elf/Mips/dynlib-fileheader.test
@@ -63,11 +63,6 @@ Sections:
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x04
Size: 0x00
- - Name: .reginfo
- Type: SHT_MIPS_REGINFO
- Flags: [ SHF_ALLOC ]
- AddressAlign: 0x01
- Size: 0x18
- Name: .MIPS.abiflags
Type: SHT_MIPS_ABIFLAGS
Flags: [ SHF_ALLOC ]
diff --git a/lld/test/elf/Mips/mips-options-gp0.test b/lld/test/elf/Mips/mips-options-gp0.test
index 339ab97253b..6f4649121f8 100644
--- a/lld/test/elf/Mips/mips-options-gp0.test
+++ b/lld/test/elf/Mips/mips-options-gp0.test
@@ -1,12 +1,12 @@
# Check reading GP0 value from .MIPS.options section
#
# RUN: yaml2obj -format=elf %s > %t.o
-# RUN: lld -flavor gnu -target mipsel -e G1 -shared -o %t.so %t.o
+# RUN: lld -flavor gnu -target mips64el -e G1 -shared -o %t.so %t.o
# RUN: llvm-readobj -symbols %t.so | FileCheck -check-prefix=SYM %s
# RUN: llvm-objdump -s %t.so | FileCheck -check-prefix=SEC %s
# SYM: Name: L1 (1)
-# SYM-NEXT: Value: 0xCC
+# SYM-NEXT: Value: 0x134
# SYM-NEXT: Size: 4
# SYM-NEXT: Binding: Local (0x0)
# SYM-NEXT: Type: Function (0x2)
@@ -21,18 +21,17 @@
# SYM-NEXT: Other: 0
# SYM-NEXT: Section: Absolute (0xFFF1)
-# 0xffff80dc == 0x0 (addend) + 0x00cc (L1) + 0x1000 (GP0) - 0x8ff0 (_gp)
+# 0xffff8144 == 0x0 (addend) + 0x0134 (L1) + 0x1000 (GP0) - 0x8ff0 (_gp)
# SEC: Contents of section .rodata:
-# SEC-NEXT: 00d4 dc80ffff 00000000 00000000 00000000 ................
+# SEC-NEXT: 013c 4481ffff 00000000 00000000 00000000
!ELF
FileHeader:
- Class: ELFCLASS32
+ Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
- Flags: [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC,
- EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
+ Flags: [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ARCH_64R2 ]
Sections:
- Name: .text
Type: SHT_PROGBITS
@@ -47,7 +46,7 @@ Sections:
Size: 16
- Name: .rel.rodata
- Type: SHT_REL
+ Type: SHT_RELA
Link: .symtab
Info: .rodata
AddressAlign: 0x04
@@ -60,7 +59,7 @@ Sections:
Type: SHT_MIPS_OPTIONS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x01
- Content: "0128000000000000000000000000000000000000000000000000000000100000"
+ Content: "012800000000000000000000000000000000000000000000000000000000000000100000"
Symbols:
Local:
diff --git a/lld/test/elf/Mips/reginfo-01.test b/lld/test/elf/Mips/reginfo-01.test
new file mode 100644
index 00000000000..5076ef83470
--- /dev/null
+++ b/lld/test/elf/Mips/reginfo-01.test
@@ -0,0 +1,30 @@
+# Check that LLD does not write a .reginfo section if input
+# object file does not contain such section.
+
+# RUN: yaml2obj -format=elf %s > %t.o
+# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t.o
+# RUN: llvm-readobj -s %t.so | FileCheck %s
+
+# CHECK-NOT: Name: .reginfo
+
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+Symbols:
+ Global:
+ - Name: T0
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
diff --git a/lld/test/elf/Mips/reginfo-02.test b/lld/test/elf/Mips/reginfo-02.test
new file mode 100644
index 00000000000..1ab9391c7ce
--- /dev/null
+++ b/lld/test/elf/Mips/reginfo-02.test
@@ -0,0 +1,74 @@
+# Check merging input .reginfo sections.
+
+# RUN: yaml2obj -format=elf -docnum 1 %s > %t1.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t2.o
+# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t1.o %t2.o
+# RUN: llvm-objdump -s -t %t.so | FileCheck %s
+
+# CHECK: Contents of section .reginfo:
+# CHECK-NEXT: 00b4 f0000001 e0000002 d0000003 c0000004
+# CHECK-NEXT: 00c4 b0000005 f08f0000
+
+# CHECK: SYMBOL TABLE:
+# CHECK: 00008ff0 g *ABS* 00000000 _gp
+
+# t1.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .reginfo
+ Type: SHT_MIPS_REGINFO
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 4
+ Content: "F0000000E0000000D0000000C0000000B000000000100000"
+
+Symbols:
+ Global:
+ - Name: T0
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
+
+# t2.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .reginfo
+ Type: SHT_MIPS_REGINFO
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 4
+ Content: "000000010000000200000003000000040000000500000100"
+
+Symbols:
+ Global:
+ - Name: T1
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
+...
diff --git a/lld/test/elf/Mips/reginfo-03.test b/lld/test/elf/Mips/reginfo-03.test
new file mode 100644
index 00000000000..0f5ea0e78cf
--- /dev/null
+++ b/lld/test/elf/Mips/reginfo-03.test
@@ -0,0 +1,40 @@
+# Check handling a zero-filled input .reginfo section.
+
+# RUN: yaml2obj -format=elf %s > %t.o
+# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t.o
+# RUN: llvm-objdump -s -t %t.so | FileCheck %s
+
+# CHECK: Contents of section .reginfo:
+# CHECK-NEXT: 00b4 00000000 00000000 00000000 00000000
+# CHECK-NEXT: 00c4 00000000 f08f0000
+
+# CHECK: SYMBOL TABLE:
+# CHECK: 00008ff0 g *ABS* 00000000 _gp
+
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .reginfo
+ Type: SHT_MIPS_REGINFO
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 4
+ Content: "000000000000000000000000000000000000000000000000"
+
+Symbols:
+ Global:
+ - Name: T0
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
diff --git a/lld/test/elf/Mips/reginfo-04.test b/lld/test/elf/Mips/reginfo-04.test
new file mode 100644
index 00000000000..e3bd5f2d317
--- /dev/null
+++ b/lld/test/elf/Mips/reginfo-04.test
@@ -0,0 +1,76 @@
+# Check that .reginfo sections from shared libraries do not affect
+# output .reginfo section content.
+
+# RUN: yaml2obj -format=elf -docnum 1 %s > %t.so.o
+# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t.so.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t.exe.o
+# RUN: lld -flavor gnu -target mipsel -e T0 -o %t.exe %t.so %t.exe.o
+# RUN: llvm-objdump -s -t %t.exe | FileCheck %s
+
+# CHECK: Contents of section .reginfo:
+# CHECK-NEXT: 400104 44444444 44444444 44444444 44444444
+# CHECK-NEXT: 400114 44444444 f08f4000
+
+# CHECK: SYMBOL TABLE:
+# CHECK: 00408ff0 g *ABS* 00000000 _gp
+
+# t.so.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_PIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .reginfo
+ Type: SHT_MIPS_REGINFO
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 4
+ Content: "111111111111111111111111111111111111111100100000"
+
+Symbols:
+ Global:
+ - Name: T1
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
+
+# t.exe.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .reginfo
+ Type: SHT_MIPS_REGINFO
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 4
+ Content: "444444444444444444444444444444444444444400000000"
+
+Symbols:
+ Global:
+ - Name: T0
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
+...
diff --git a/lld/test/elf/Mips/reginfo-05.test b/lld/test/elf/Mips/reginfo-05.test
new file mode 100644
index 00000000000..f4212705f80
--- /dev/null
+++ b/lld/test/elf/Mips/reginfo-05.test
@@ -0,0 +1,118 @@
+# Check that .reginfo section gets register usage mask from "used" files only.
+# In this test case we take only t2.o from libreginfo.a and should not add
+# register usage masks from t1.o to the output .reginfo section.
+
+# RUN: yaml2obj -format=elf -docnum 1 %s > %t1.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t2.o
+# RUN: llvm-ar q %T/libreginfo.a %t1.o %t2.o
+# RUN: yaml2obj -format=elf -docnum 3 %s > %t3.o
+# RUN: lld -flavor gnu -target mipsel -e T0 -o %t.exe %t3.o -L%T -lreginfo
+# RUN: llvm-objdump -s -t %t.exe | FileCheck %s
+
+# CHECK: Contents of section .reginfo:
+# CHECK-NEXT: 400104 66666666 66666666 66666666 66666666
+# CHECK-NEXT: 400114 66666666 f08f4000
+
+# CHECK: SYMBOL TABLE:
+# CHECK: 00408ff0 g *ABS* 00000000 _gp
+
+# t1.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .reginfo
+ Type: SHT_MIPS_REGINFO
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 4
+ Content: "111111111111111111111111111111111111111100000000"
+
+Symbols:
+ Global:
+ - Name: T1
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
+
+# t2.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .reginfo
+ Type: SHT_MIPS_REGINFO
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 4
+ Content: "222222222222222222222222222222222222222200000000"
+
+Symbols:
+ Global:
+ - Name: T2
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
+
+# t3.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 4
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ AddressAlign: 4
+ Relocations:
+ - Offset: 0
+ Symbol: T2
+ Type: R_MIPS_32
+
+- Name: .reginfo
+ Type: SHT_MIPS_REGINFO
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 4
+ Content: "444444444444444444444444444444444444444400000000"
+
+Symbols:
+ Global:
+ - Name: T0
+ Section: .text
+ Type: STT_FUNC
+ Value: 0
+ Size: 4
+ - Name: T2
+...
diff --git a/lld/test/elf/Mips/rel-gprel16.test b/lld/test/elf/Mips/rel-gprel16.test
index dc188ea6825..84fc3ec5e97 100644
--- a/lld/test/elf/Mips/rel-gprel16.test
+++ b/lld/test/elf/Mips/rel-gprel16.test
@@ -6,20 +6,20 @@
# RUN: llvm-objdump -s %t.so | FileCheck -check-prefix=SEC %s
# SYM: Name: L1 (1)
-# SYM-NEXT: Value: 0xCC
+# SYM-NEXT: Value: 0x104
# SYM-NEXT: Size: 4
# SYM-NEXT: Binding: Local (0x0)
# SYM-NEXT: Type: Function (0x2)
# SYM-NEXT: Other: 0
-# SYM-NEXT: Section: .text (0x4)
+# SYM-NEXT: Section: .text (0x5)
# SYM: Name: G1 (4)
-# SYM-NEXT: Value: 0xD0
+# SYM-NEXT: Value: 0x108
# SYM-NEXT: Size: 4
# SYM-NEXT: Binding: Global (0x1)
# SYM-NEXT: Type: Function (0x2)
# SYM-NEXT: Other: 0
-# SYM-NEXT: Section: .text (0x4)
+# SYM-NEXT: Section: .text (0x5)
# SYM: Name: _gp (34)
# SYM-NEXT: Value: 0x8FF0
@@ -29,9 +29,9 @@
# SYM-NEXT: Other: 0
# SYM-NEXT: Section: Absolute (0xFFF1)
-# 0x160db == 0xffff (addend) + 0x00cc (L1) + 0x01f000 (GP0) - 0x8ff0 (_gp)
+# 0x6113 == 0xffff (addend) + 0x0104 (L1) + 0x01f000 (GP0) - 0x8ff0 (_gp)
# SEC: Contents of section .rodata:
-# SEC-NEXT: 00d4 db600008 00000000 00000000 00000000 .`..............
+# SEC-NEXT: 010c 13610008 00000000 00000000 00000000
!ELF
FileHeader:
diff --git a/lld/test/elf/Mips/rel-gprel32.test b/lld/test/elf/Mips/rel-gprel32.test
index 73ae6f16197..ced53f5f83e 100644
--- a/lld/test/elf/Mips/rel-gprel32.test
+++ b/lld/test/elf/Mips/rel-gprel32.test
@@ -6,12 +6,12 @@
# RUN: llvm-objdump -s %t-exe | FileCheck -check-prefix=SEC %s
# SYM: Name: $L1 (1)
-# SYM-NEXT: Value: 0x400108
+# SYM-NEXT: Value: 0x400140
# SYM-NEXT: Size: 4
# SYM-NEXT: Binding: Local (0x0)
# SYM-NEXT: Type: Function (0x2)
# SYM-NEXT: Other: 0
-# SYM-NEXT: Section: .text (0x5)
+# SYM-NEXT: Section: .text (0x6)
#
# SYM: Name: _gp (212)
# SYM-NEXT: Value: 0x408FF0
@@ -21,10 +21,10 @@
# SYM-NEXT: Other: 0
# SYM-NEXT: Section: Absolute (0xFFF1)
-# 0x08FF711B == 0x8000001 (addend) + 0x400108 ($L1) +
+# 0x08ff7153 == 0x8000001 (addend) + 0x400140 ($L1) +
# 0x1000002 (GP0) - 0x408FF0 (_gp)
# SEC: Contents of section .rodata:
-# SEC-NEXT: 400118 1b71ff08 00000000 00000000 00000000 .q..............
+# SEC-NEXT: 400150 5371ff08 00000000 00000000 00000000
!ELF
FileHeader:
OpenPOWER on IntegriCloud