[lld] r361013 - [ELF][test] Reorganize some R_*_NONE tests

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 03:44:05 PDT 2019


Author: maskray
Date: Fri May 17 03:44:05 2019
New Revision: 361013

URL: http://llvm.org/viewvc/llvm-project?rev=361013&view=rev
Log:
[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

Added:
    lld/trunk/test/ELF/icf10.s
    lld/trunk/test/ELF/relocation-none-aarch64.s
    lld/trunk/test/ELF/relocation-none-arm.s
    lld/trunk/test/ELF/relocation-none-i386.s
    lld/trunk/test/ELF/relocation-none-x86-64.s
Removed:
    lld/trunk/test/ELF/Inputs/dtrace-r.o
    lld/trunk/test/ELF/dtrace-r.test
    lld/trunk/test/ELF/icf10.test
    lld/trunk/test/ELF/relocation-dtrace.test
    lld/trunk/test/ELF/relocation-none-aarch64.test
    lld/trunk/test/ELF/relocation-none-i686.test

Removed: lld/trunk/test/ELF/Inputs/dtrace-r.o
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/dtrace-r.o?rev=361012&view=auto
==============================================================================
Binary files lld/trunk/test/ELF/Inputs/dtrace-r.o (original) and lld/trunk/test/ELF/Inputs/dtrace-r.o (removed) differ

Removed: lld/trunk/test/ELF/dtrace-r.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/dtrace-r.test?rev=361012&view=auto
==============================================================================
--- lld/trunk/test/ELF/dtrace-r.test (original)
+++ lld/trunk/test/ELF/dtrace-r.test (removed)
@@ -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: ]

Added: lld/trunk/test/ELF/icf10.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf10.s?rev=361013&view=auto
==============================================================================
--- lld/trunk/test/ELF/icf10.s (added)
+++ lld/trunk/test/ELF/icf10.s Fri May 17 03:44:05 2019
@@ -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

Removed: lld/trunk/test/ELF/icf10.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf10.test?rev=361012&view=auto
==============================================================================
--- lld/trunk/test/ELF/icf10.test (original)
+++ lld/trunk/test/ELF/icf10.test (removed)
@@ -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

Removed: lld/trunk/test/ELF/relocation-dtrace.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-dtrace.test?rev=361012&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocation-dtrace.test (original)
+++ lld/trunk/test/ELF/relocation-dtrace.test (removed)
@@ -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

Added: lld/trunk/test/ELF/relocation-none-aarch64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-none-aarch64.s?rev=361013&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocation-none-aarch64.s (added)
+++ lld/trunk/test/ELF/relocation-none-aarch64.s Fri May 17 03:44:05 2019
@@ -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

Removed: lld/trunk/test/ELF/relocation-none-aarch64.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-none-aarch64.test?rev=361012&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocation-none-aarch64.test (original)
+++ lld/trunk/test/ELF/relocation-none-aarch64.test (removed)
@@ -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

Added: lld/trunk/test/ELF/relocation-none-arm.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-none-arm.s?rev=361013&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocation-none-arm.s (added)
+++ lld/trunk/test/ELF/relocation-none-arm.s Fri May 17 03:44:05 2019
@@ -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

Added: lld/trunk/test/ELF/relocation-none-i386.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-none-i386.s?rev=361013&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocation-none-i386.s (added)
+++ lld/trunk/test/ELF/relocation-none-i386.s Fri May 17 03:44:05 2019
@@ -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

Removed: lld/trunk/test/ELF/relocation-none-i686.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-none-i686.test?rev=361012&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocation-none-i686.test (original)
+++ lld/trunk/test/ELF/relocation-none-i686.test (removed)
@@ -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

Added: lld/trunk/test/ELF/relocation-none-x86-64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-none-x86-64.s?rev=361013&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocation-none-x86-64.s (added)
+++ lld/trunk/test/ELF/relocation-none-x86-64.s Fri May 17 03:44:05 2019
@@ -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




More information about the llvm-commits mailing list