[ELF][test] Reorganize some R_*_NONE tests

Change R_{386,AARCH64}_NONE yaml2obj tests/icf10.test to use assembly

Add relocation-none-{arm,x86_64}.s.
  Check the referenced section survives under --gc-sections.
  Check -r copies R_X86_64_NONE R_AARCH64_NONE. (Elf*_Rel arches currently have a bug)
  Delete the dtrace tests as they are covered by the R_X86_64_NONE test.

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D62051

llvm-svn: 361013
This commit is contained in:
Fangrui Song 2019-05-17 10:44:05 +00:00
parent a6d3bd486b
commit ef9b8e03fd
11 changed files with 99 additions and 114 deletions

Binary file not shown.

View File

@ -1,8 +0,0 @@
RUN: ld.lld -r -o %t.o %p/Inputs/dtrace-r.o
RUN: llvm-readobj -r %t.o | FileCheck %s
CHECK: Relocations [
CHECK-NEXT: Section ({{.*}}) .rela.text {
CHECK-NEXT: 0x0 R_X86_64_NONE - 0x0
CHECK-NEXT: }
CHECK-NEXT: ]

17
lld/test/ELF/icf10.s Normal file
View File

@ -0,0 +1,17 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %s -o %t.o
# RUN: ld.lld --icf=all %t.o -o /dev/null --print-icf-sections 2>&1 | FileCheck %s
# Checks that ICF does not merge 2 sections the offset of
# the relocations of which differ.
# CHECK-NOT: selected
.section .text.foo,"ax"
.quad -1
.reloc 0, R_X86_64_NONE, 0
.section .text.bar,"ax"
.quad -1
.reloc 1, R_X86_64_NONE, 0

View File

@ -1,38 +0,0 @@
# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld --icf=all %t.o -o /dev/null --print-icf-sections 2>&1 | FileCheck %s
# Checks that ICF does not merge 2 sections the offset of
# the relocations of which differ.
# CHECK-NOT: selected
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
OSABI: ELFOSABI_FREEBSD
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text.foo
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR]
Content: "FFFFFFFFFFFFFFFF"
- Name: .text.bar
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR]
Content: "FFFFFFFFFFFFFFFF"
- Name: .rela.text.foo
Type: SHT_RELA
Link: .symtab
Info: .text.foo
Relocations:
- Offset: 0x0000000000000000
Type: R_X86_64_NONE
- Name: .rela.text.bar
Type: SHT_RELA
Link: .symtab
Info: .text.bar
Relocations:
- Offset: 0x0000000000000001
Type: R_X86_64_NONE

View File

@ -1,23 +0,0 @@
# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld -shared %t.o -o /dev/null
# Test that we can handle R_X86_64_NONE as produced by dtrace.
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
OSABI: ELFOSABI_FREEBSD
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
- Name: .rela.text
Type: SHT_RELA
Link: .symtab
Info: .text
Relocations:
- Offset: 0x0000000000000000
Type: R_X86_64_NONE

View File

@ -0,0 +1,24 @@
# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-musl %s -o %t.o
# RUN: ld.lld --gc-sections %t.o -o %t
# RUN: llvm-readelf -S -r %t | FileCheck %s
# Test that we discard R_AARCH64_NONE, but respect the references it creates
# among sections.
# CHECK: .data
# CHECK: There are no relocations in this file.
# RUN: ld.lld -r %t.o -o %t
# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
# RELOC: Section ({{.*}}) .rela.text {
# RELOC-NEXT: 0x0 R_AARCH64_NONE .data 0x0
# RELOC-NEXT: }
.globl _start
_start:
ret
.reloc 0, R_AARCH64_NONE, .data
.data
.long 0

View File

@ -1,23 +0,0 @@
# REQUIRES: aarch64
# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld %t.o -o /dev/null
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_AARCH64
Sections:
- Type: SHT_PROGBITS
Name: .text
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Content: "00000000"
- Type: SHT_RELA
Name: .rela.text
Link: .symtab
Info: .text
Relocations:
- Offset: 0
Type: R_AARCH64_NONE

View File

@ -0,0 +1,17 @@
# RUN: llvm-mc -filetype=obj -triple=armv7-linux-musl %s -o %t.o
# RUN: ld.lld --gc-sections %t.o -o %t
# RUN: llvm-readelf -S -r %t | FileCheck %s
# Test that we discard R_ARM_NONE, but respect the references it creates among
# sections.
# CHECK: .data
# CHECK: There are no relocations in this file.
.globl _start
_start:
nop
.reloc 0, R_ARM_NONE, .data
.data
.long 0

View File

@ -0,0 +1,17 @@
# RUN: llvm-mc -filetype=obj -triple=i386-linux-musl %s -o %t.o
# RUN: ld.lld --gc-sections %t.o -o %t
# RUN: llvm-readelf -S -r %t | FileCheck %s
# Test that we discard R_386_NONE, but respect the
# references it creates among sections.
# CHECK: .data
# CHECK: There are no relocations in this file.
.globl _start
_start:
ret
.reloc 0, R_386_NONE, .data
.data
.long 0

View File

@ -1,22 +0,0 @@
# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld %t.o -o /dev/null
# Test that we can handle R_386_NONE.
!ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
- Name: .rel.text
Type: SHT_RELA
Link: .symtab
Info: .text
Relocations:
- Offset: 0x0000000000000000
Type: R_386_NONE

View File

@ -0,0 +1,24 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-linux-musl %s -o %t.o
# RUN: ld.lld --gc-sections %t.o -o %t
# RUN: llvm-readelf -S -r %t | FileCheck %s
# Test that we discard R_X86_64_NONE, but respect the
# references it creates among sections.
# CHECK: .data
# CHECK: There are no relocations in this file.
# RUN: ld.lld -r %t.o -o %t
# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
# RELOC: Section ({{.*}}) .rela.text {
# RELOC-NEXT: 0x0 R_X86_64_NONE .data 0x0
# RELOC-NEXT: }
.globl _start
_start:
ret
.reloc 0, R_X86_64_NONE, .data
.data
.long 0