From 9dec22dbe21f487c3ac96bb4467851510a88e01c Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Sat, 18 Jan 2014 16:59:19 +0000 Subject: [PATCH] [Mips] Use explicit assembler instructions in the tests. llvm-svn: 199556 --- lld/test/elf/Mips/Inputs/dynobj.c | 14 -- lld/test/elf/Mips/Inputs/dynobj.o | Bin 1448 -> 0 bytes lld/test/elf/Mips/dynlib-dynamic.test | 72 +++--- lld/test/elf/Mips/dynlib-dynsym.test | 268 +++++++++++++---------- lld/test/elf/Mips/dynlib-fileheader.test | 86 ++++---- 5 files changed, 249 insertions(+), 191 deletions(-) delete mode 100644 lld/test/elf/Mips/Inputs/dynobj.c delete mode 100644 lld/test/elf/Mips/Inputs/dynobj.o diff --git a/lld/test/elf/Mips/Inputs/dynobj.c b/lld/test/elf/Mips/Inputs/dynobj.c deleted file mode 100644 index 8e5a94cbe561..000000000000 --- a/lld/test/elf/Mips/Inputs/dynobj.c +++ /dev/null @@ -1,14 +0,0 @@ -// clang -O0 -EL -fPIC -target mipsel-linux-gnu -c dynobj.c -o dynobj.o -int xyz(const char *); -int abc(const char *); - -int bar(void) -{ - return 1; -} - -int foo(void) -{ - bar(); - return xyz("str1") + abc("str2"); -} diff --git a/lld/test/elf/Mips/Inputs/dynobj.o b/lld/test/elf/Mips/Inputs/dynobj.o deleted file mode 100644 index a4528d2582a2feb7a41307c15792bc93a06f16a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1448 zcmah|O=}ZT6g|nLHL+Tw1PmB-0+9ri!L+(4R0svdg^Mg(5aLXerYT7#OvaLkAV`;m z*|^Z1{~*7h8l*o$!9|uX)m0ZlJa=YZGLb?rygB#dy!-Lqo3~G%KaIs=P!dBDa|@Wz zxRgfqp-(7b6)TGBz{?{ihhIk?WbF9(!k~k?QG0_5Yd=uCzd?UAjFC#tV z=hHh3?;PhR73A=BlseOWeh%L~V3X^p2yA#c{P401@l(b=9s`A9zzsN=2q%M6FQ0w~ z>4)_^*7ZsYJq4X*fIoqD?zi%HI-ROWlFDtaJIVo!qw!KC-glic_*nyX+h(_^A2ytR z%kJvy#v>gt`ooTET13|ga9?Roqiwj2feWK_pFuW-r! z1ecuC-OvsnKoF!)iOP464&h(Kdq56*>%~<97RxG~D0Rht%q4v&$b!4Xgm*dA1!SA7T8J`_h(#yg;7krX*#b`msw;EnM-Dk=F>T^>Vct!8O2s2`IRK_d-gAgPy26|wopOh z>a>Fl8gE*i3CnYL^ag~V@_Uuo`El{iMVr0Wz^5_$%`jXb-e3iJucE&X?a06D*DBGk zM9%5HGKgZMKJ41ofw7B%{9VDf49j$|XWOVXd$oG2-@{<|8m2`Sw=As!l6RR{A+GQu lwuvb|tQX=Zz7+p8U?6_}0B^)kJQBZOnD@$kI_)?w^B;+}j28d^ diff --git a/lld/test/elf/Mips/dynlib-dynamic.test b/lld/test/elf/Mips/dynlib-dynamic.test index 89fdb566536c..9d27400f8ebf 100644 --- a/lld/test/elf/Mips/dynlib-dynamic.test +++ b/lld/test/elf/Mips/dynlib-dynamic.test @@ -1,27 +1,49 @@ # Check MIPS specific tags in the dynamic table. -RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \ -RUN: -o %t %p/Inputs/dynobj.o -RUN: llvm-readobj -dynamic-table %t | FileCheck %s -CHECK: Format: ELF32-mips -CHECK: Arch: mipsel -CHECK: AddressSize: 32bit -CHECK: LoadName: -CHECK: DynamicSection [ (15 entries) -CHECK: Tag Type Name/Value -CHECK: 0x00000004 HASH 0xE0 -CHECK: 0x00000005 STRTAB 0x158 -CHECK: 0x00000006 SYMTAB 0x108 -CHECK: 0x0000000A STRSZ 17 (bytes) -CHECK: 0x0000000B SYMENT 16 (bytes) -CHECK: 0x0000001A FINI_ARRAY 0x0 -CHECK: 0x0000001C FINI_ARRAYSZ 0 (bytes) -CHECK: 0x70000001 MIPS_RLD_VERSION 1 -CHECK: 0x70000005 MIPS_FLAGS 0x2 -CHECK: 0x70000006 MIPS_BASE_ADDRESS 0x0 -CHECK: 0x7000000A MIPS_LOCAL_GOTNO 4 -CHECK: 0x70000011 MIPS_SYMTABNO 5 -CHECK: 0x70000013 MIPS_GOTSYM 0x2 -CHECK: 0x00000003 PLTGOT 0x1000 -CHECK: 0x00000000 NULL 0x0 -CHECK: ] +# Build shared library +# RUN: llvm-mc -triple=mipsel -filetype=obj -relocation-model=pic -o=%t-obj %s +# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec -o %t-so %t-obj +# RUN: llvm-readobj -dynamic-table %t-so | FileCheck %s + +# CHECK: Format: ELF32-mips +# CHECK: Arch: mipsel +# CHECK: AddressSize: 32bit +# CHECK: LoadName: +# CHECK: DynamicSection [ (15 entries) +# CHECK: Tag Type Name/Value +# CHECK: 0x00000004 HASH 0xD4 +# CHECK: 0x00000005 STRTAB 0x138 +# CHECK: 0x00000006 SYMTAB 0xF8 +# CHECK: 0x0000000A STRSZ 17 (bytes) +# CHECK: 0x0000000B SYMENT 16 (bytes) +# CHECK: 0x0000001A FINI_ARRAY 0x0 +# CHECK: 0x0000001C FINI_ARRAYSZ 0 (bytes) +# CHECK: 0x70000001 MIPS_RLD_VERSION 1 +# CHECK: 0x70000005 MIPS_FLAGS 0x2 +# CHECK: 0x70000006 MIPS_BASE_ADDRESS 0x0 +# CHECK: 0x7000000A MIPS_LOCAL_GOTNO 4 +# CHECK: 0x70000011 MIPS_SYMTABNO 4 +# CHECK: 0x70000013 MIPS_GOTSYM 0x2 +# CHECK: 0x00000003 PLTGOT 0x1000 +# CHECK: 0x00000000 NULL 0x0 +# CHECK: ] + + .abicalls + .global glob + .ent glob +glob: + lw $gp, %got($.str1)($1) + addiu $4, $gp, %lo($.str1) + lw $4, %got($.str2)($1) + addiu $4, $4, %lo($.str2) + lw $25, %call16(glob2)($1) + lw $25, %call16(ext1)($1) + .end glob + + .section .rodata.str1 +$.str1: + .asciz "str1" + + .section .rodata.str2 +$.str2: + .asciz "str2" diff --git a/lld/test/elf/Mips/dynlib-dynsym.test b/lld/test/elf/Mips/dynlib-dynsym.test index de56a9019df3..8f750e68f6da 100644 --- a/lld/test/elf/Mips/dynlib-dynsym.test +++ b/lld/test/elf/Mips/dynlib-dynsym.test @@ -1,118 +1,158 @@ # Check sorting of .dynsym content accordingly to .got section. -RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \ -RUN: -o %t %p/Inputs/dynobj.o -RUN: llvm-readobj -dyn-symbols %t | FileCheck -check-prefix=CHECK-DYN %s -RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \ -RUN: --output-filetype=yaml -o %t %p/Inputs/dynobj.o -RUN: FileCheck -check-prefix=CHECK-GOT %s < %t +# Build shared library +# RUN: llvm-mc -triple=mipsel -filetype=obj -relocation-model=pic -o=%t-obj %s +# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec -o %t-so %t-obj +# RUN: llvm-readobj -dyn-symbols %t-so | FileCheck -check-prefix=CHECK-DYN %s -CHECK-DYN: Format: ELF32-mips -CHECK-DYN: Arch: mipsel -CHECK-DYN: AddressSize: 32bit -CHECK-DYN: LoadName: -CHECK-DYN: DynamicSymbols [ -CHECK-DYN: Symbol { -CHECK-DYN: Name: @ (0) -CHECK-DYN: Value: 0x0 -CHECK-DYN: Size: 0 -CHECK-DYN: Binding: Local (0x0) -CHECK-DYN: Type: None (0x0) -CHECK-DYN: Other: 0 -CHECK-DYN: Section: (0x0) -CHECK-DYN: } -CHECK-DYN: Symbol { -CHECK-DYN: Name: foo@ (5) -CHECK-DYN: Value: 0x194 -CHECK-DYN: Size: 156 -CHECK-DYN: Binding: Global (0x1) -CHECK-DYN: Type: Function (0x2) -CHECK-DYN: Other: 0 -CHECK-DYN: Section: .text (0x4) -CHECK-DYN: } -CHECK-DYN: Symbol { -CHECK-DYN: Name: bar@ (1) -CHECK-DYN: Value: 0x170 -CHECK-DYN: Size: 36 -CHECK-DYN: Binding: Global (0x1) -CHECK-DYN: Type: Function (0x2) -CHECK-DYN: Other: 0 -CHECK-DYN: Section: .text (0x4) -CHECK-DYN: } -CHECK-DYN: Symbol { -CHECK-DYN: Name: xyz@ (9) -CHECK-DYN: Value: 0x0 -CHECK-DYN: Size: 0 -CHECK-DYN: Binding: Global (0x1) -CHECK-DYN: Type: None (0x0) -CHECK-DYN: Other: 0 -CHECK-DYN: Section: (0x0) -CHECK-DYN: } -CHECK-DYN: Symbol { -CHECK-DYN: Name: abc@ (13) -CHECK-DYN: Value: 0x0 -CHECK-DYN: Size: 0 -CHECK-DYN: Binding: Global (0x1) -CHECK-DYN: Type: None (0x0) -CHECK-DYN: Other: 0 -CHECK-DYN: Section: (0x0) -CHECK-DYN: } -CHECK-DYN: ] +# Build shared library (yaml format) +# RUN: llvm-mc -triple=mipsel -filetype=obj -relocation-model=pic -o=%t-obj %s +# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \ +# RUN: --output-filetype=yaml -o %t-yaml %t-obj +# RUN: FileCheck -check-prefix=CHECK-GOT %s < %t-yaml -CHECK-GOT: - type: got -CHECK-GOT: content: [ 00, 00, 00, 00 ] -CHECK-GOT: alignment: 2^2 -CHECK-GOT: section-choice: custom-required -CHECK-GOT: section-name: .got -CHECK-GOT: permissions: rw- -CHECK-GOT: - type: got -CHECK-GOT: content: [ 00, 00, 00, 80 ] -CHECK-GOT: alignment: 2^2 -CHECK-GOT: section-choice: custom-required -CHECK-GOT: section-name: .got -CHECK-GOT: permissions: rw- -CHECK-GOT: - ref-name: L004 -CHECK-GOT: type: got -CHECK-GOT: content: [ 00, 00, 00, 00 ] -CHECK-GOT: alignment: 2^2 -CHECK-GOT: section-choice: custom-required -CHECK-GOT: section-name: .got -CHECK-GOT: permissions: rw- -CHECK-GOT: - ref-name: L006 -CHECK-GOT: type: got -CHECK-GOT: content: [ 00, 00, 00, 00 ] -CHECK-GOT: alignment: 2^2 -CHECK-GOT: section-choice: custom-required -CHECK-GOT: section-name: .got -CHECK-GOT: permissions: rw- -CHECK-GOT: - ref-name: L003 -CHECK-GOT: type: got -CHECK-GOT: content: [ 00, 00, 00, 00 ] -CHECK-GOT: alignment: 2^2 -CHECK-GOT: section-choice: custom-required -CHECK-GOT: section-name: .got -CHECK-GOT: permissions: rw- -CHECK-GOT: references: -CHECK-GOT: - kind: R_MIPS_32 -CHECK-GOT: offset: 0 -CHECK-GOT: target: bar -CHECK-GOT: - ref-name: L005 -CHECK-GOT: type: got -CHECK-GOT: content: [ 00, 00, 00, 00 ] -CHECK-GOT: alignment: 2^2 -CHECK-GOT: section-choice: custom-required -CHECK-GOT: section-name: .got -CHECK-GOT: permissions: rw- -CHECK-GOT: - ref-name: L007 -CHECK-GOT: type: got -CHECK-GOT: content: [ 00, 00, 00, 00 ] -CHECK-GOT: alignment: 2^2 -CHECK-GOT: section-choice: custom-required -CHECK-GOT: section-name: .got -CHECK-GOT: permissions: rw- -CHECK-GOT: - ref-name: L002 -CHECK-GOT: alignment: 2^4 -CHECK-GOT: references: -CHECK-GOT: - kind: layout-after -CHECK-GOT: offset: 0 -CHECK-GOT: target: bar +# CHECK-DYN: Format: ELF32-mips +# CHECK-DYN: Arch: mipsel +# CHECK-DYN: AddressSize: 32bit +# CHECK-DYN: LoadName: +# CHECK-DYN: DynamicSymbols [ +# CHECK-DYN: Symbol { +# CHECK-DYN: Name: @ (0) +# CHECK-DYN: Value: 0x0 +# CHECK-DYN: Size: 0 +# CHECK-DYN: Binding: Local (0x0) +# CHECK-DYN: Type: None (0x0) +# CHECK-DYN: Other: 0 +# CHECK-DYN: Section: (0x0) +# CHECK-DYN: } +# CHECK-DYN: Symbol { +# CHECK-DYN: Name: bar@ (5) +# CHECK-DYN: Value: 0x178 +# CHECK-DYN: Size: 4 +# CHECK-DYN: Binding: Global (0x1) +# CHECK-DYN: Type: Function (0x2) +# CHECK-DYN: Other: 0 +# CHECK-DYN: Section: .text (0x4) +# CHECK-DYN: } +# CHECK-DYN: Symbol { +# CHECK-DYN: Name: foo@ (1) +# CHECK-DYN: Value: 0x160 +# CHECK-DYN: Size: 24 +# CHECK-DYN: Binding: Global (0x1) +# CHECK-DYN: Type: Function (0x2) +# CHECK-DYN: Other: 0 +# CHECK-DYN: Section: .text (0x4) +# CHECK-DYN: } +# CHECK-DYN: Symbol { +# CHECK-DYN: Name: ext1@ (9) +# CHECK-DYN: Value: 0x0 +# CHECK-DYN: Size: 0 +# CHECK-DYN: Binding: Global (0x1) +# CHECK-DYN: Type: None (0x0) +# CHECK-DYN: Other: 0 +# CHECK-DYN: Section: (0x0) +# CHECK-DYN: } +# CHECK-DYN: Symbol { +# CHECK-DYN: Name: ext2@ (14) +# CHECK-DYN: Value: 0x0 +# CHECK-DYN: Size: 0 +# CHECK-DYN: Binding: Global (0x1) +# CHECK-DYN: Type: None (0x0) +# CHECK-DYN: Other: 0 +# CHECK-DYN: Section: (0x0) +# CHECK-DYN: } +# CHECK-DYN: ] + +# CHECK-GOT: - type: got +# CHECK-GOT: content: [ 00, 00, 00, 00 ] +# CHECK-GOT: alignment: 2^2 +# CHECK-GOT: section-choice: custom-required +# CHECK-GOT: section-name: .got +# CHECK-GOT: permissions: rw- +# CHECK-GOT: - type: got +# CHECK-GOT: content: [ 00, 00, 00, 80 ] +# CHECK-GOT: alignment: 2^2 +# CHECK-GOT: section-choice: custom-required +# CHECK-GOT: section-name: .got +# CHECK-GOT: permissions: rw- +# CHECK-GOT: - ref-name: L002 +# CHECK-GOT: type: got +# CHECK-GOT: content: [ 00, 00, 00, 00 ] +# CHECK-GOT: alignment: 2^2 +# CHECK-GOT: section-choice: custom-required +# CHECK-GOT: section-name: .got +# CHECK-GOT: permissions: rw- +# CHECK-GOT: references: +# CHECK-GOT: - kind: R_MIPS_32 +# CHECK-GOT: offset: 0 +# CHECK-GOT: target: L003 +# CHECK-GOT: - ref-name: L004 +# CHECK-GOT: type: got +# CHECK-GOT: content: [ 00, 00, 00, 00 ] +# CHECK-GOT: alignment: 2^2 +# CHECK-GOT: section-choice: custom-required +# CHECK-GOT: section-name: .got +# CHECK-GOT: permissions: rw- +# CHECK-GOT: references: +# CHECK-GOT: - kind: R_MIPS_32 +# CHECK-GOT: offset: 0 +# CHECK-GOT: target: L005 +# CHECK-GOT: - ref-name: L006 +# CHECK-GOT: type: got +# CHECK-GOT: content: [ 00, 00, 00, 00 ] +# CHECK-GOT: alignment: 2^2 +# CHECK-GOT: section-choice: custom-required +# CHECK-GOT: section-name: .got +# CHECK-GOT: permissions: rw- +# CHECK-GOT: references: +# CHECK-GOT: - kind: LLD_R_MIPS_GLOBAL_GOT +# CHECK-GOT: offset: 0 +# CHECK-GOT: target: foo +# CHECK-GOT: - ref-name: L007 +# CHECK-GOT: type: got +# CHECK-GOT: content: [ 00, 00, 00, 00 ] +# CHECK-GOT: alignment: 2^2 +# CHECK-GOT: section-choice: custom-required +# CHECK-GOT: section-name: .got +# CHECK-GOT: permissions: rw- +# CHECK-GOT: references: +# CHECK-GOT: - kind: LLD_R_MIPS_GLOBAL_GOT +# CHECK-GOT: offset: 0 +# CHECK-GOT: target: ext1 +# CHECK-GOT: - ref-name: L009 +# CHECK-GOT: type: got +# CHECK-GOT: content: [ 00, 00, 00, 00 ] +# CHECK-GOT: alignment: 2^2 +# CHECK-GOT: section-choice: custom-required +# CHECK-GOT: section-name: .got +# CHECK-GOT: permissions: rw- +# CHECK-GOT: references: +# CHECK-GOT: - kind: LLD_R_MIPS_GLOBAL_GOT +# CHECK-GOT: offset: 0 +# CHECK-GOT: target: ext2 + + .abicalls + .global foo + .ent foo +foo: + lw $gp, %got($.str1)($1) + addiu $4, $gp, %lo($.str1) + lw $4, %got($.str2)($1) + addiu $4, $4, %lo($.str2) + lw $25, %call16(foo)($1) + lw $25, %call16(ext1)($1) + .end foo + + .global bar + .ent brar +bar: + lw $25, %call16(ext2)($1) + .end bar + + .section .rodata.str1 +$.str1: + .asciz "str1" + + .section .rodata.str2 +$.str2: + .asciz "str2" diff --git a/lld/test/elf/Mips/dynlib-fileheader.test b/lld/test/elf/Mips/dynlib-fileheader.test index 0ecc293d1dfb..088cf71f4f3b 100644 --- a/lld/test/elf/Mips/dynlib-fileheader.test +++ b/lld/test/elf/Mips/dynlib-fileheader.test @@ -1,39 +1,49 @@ -RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \ -RUN: -o %t %p/Inputs/dynobj.o -RUN: llvm-readobj -file-headers %t | FileCheck %s +# Check ELF Header for shared library. -CHECK: Format: ELF32-mips -CHECK: Arch: mipsel -CHECK: AddressSize: 32bit -CHECK: LoadName: -CHECK: ElfHeader { -CHECK: Ident { -CHECK: Magic: (7F 45 4C 46) -CHECK: Class: 32-bit (0x1) -CHECK: DataEncoding: LittleEndian (0x1) -CHECK: FileVersion: 1 -CHECK: OS/ABI: SystemV (0x0) -CHECK: ABIVersion: 0 -CHECK: Unused: (00 00 00 00 00 00 00) -CHECK: } -CHECK: Type: SharedObject (0x3) -CHECK: Machine: EM_MIPS (0x8) -CHECK: Version: 1 -CHECK: Entry: 0x170 -CHECK: ProgramHeaderOffset: 0x34 -CHECK: SectionHeaderOffset: 0x21D8 -CHECK: Flags [ (0x70001007) -CHECK: 0x1 -CHECK: 0x2 -CHECK: 0x1000 -CHECK: 0x10000000 -CHECK: 0x20000000 -CHECK: 0x40000000 -CHECK: ] -CHECK: HeaderSize: 52 -CHECK: ProgramHeaderEntrySize: 32 -CHECK: ProgramHeaderCount: 5 -CHECK: SectionHeaderEntrySize: 40 -CHECK: SectionHeaderCount: 16 -CHECK: StringTableSectionIndex: 13 -CHECK:} +# Build shared library +# RUN: llvm-mc -triple=mipsel -filetype=obj -relocation-model=pic -o=%t-obj %s +# RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-obj +# RUN: llvm-readobj -file-headers %t-so | FileCheck %s + +# CHECK: Format: ELF32-mips +# CHECK: Arch: mipsel +# CHECK: AddressSize: 32bit +# CHECK: LoadName: +# CHECK: ElfHeader { +# CHECK: Ident { +# CHECK: Magic: (7F 45 4C 46) +# CHECK: Class: 32-bit (0x1) +# CHECK: DataEncoding: LittleEndian (0x1) +# CHECK: FileVersion: 1 +# CHECK: OS/ABI: SystemV (0x0) +# CHECK: ABIVersion: 0 +# CHECK: Unused: (00 00 00 00 00 00 00) +# CHECK: } +# CHECK: Type: SharedObject (0x3) +# CHECK: Machine: EM_MIPS (0x8) +# CHECK: Version: 1 +# CHECK: Entry: 0x110 +# CHECK: ProgramHeaderOffset: 0x34 +# CHECK: SectionHeaderOffset: 0x20E0 +# CHECK: Flags [ (0x70001007) +# CHECK: 0x1 +# CHECK: 0x2 +# CHECK: 0x1000 +# CHECK: 0x10000000 +# CHECK: 0x20000000 +# CHECK: 0x40000000 +# CHECK: ] +# CHECK: HeaderSize: 52 +# CHECK: ProgramHeaderEntrySize: 32 +# CHECK: ProgramHeaderCount: 5 +# CHECK: SectionHeaderEntrySize: 40 +# CHECK: SectionHeaderCount: 12 +# CHECK: StringTableSectionIndex: 9 +# CHECK:} + + .abicalls + .global glob + .ent glob +glob: + nop + .end glob