[lld] a495b2f - [ELF][test] Improve tests about non-SHF_ALLOC sections relocated by non-ABS relocations

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 21:02:32 PDT 2023


Author: Fangrui Song
Date: 2023-09-19T21:02:27-07:00
New Revision: a495b2f8cbcadf52dab0d29b7fafdc97f2a8b1da

URL: https://github.com/llvm/llvm-project/commit/a495b2f8cbcadf52dab0d29b7fafdc97f2a8b1da
DIFF: https://github.com/llvm/llvm-project/commit/a495b2f8cbcadf52dab0d29b7fafdc97f2a8b1da.diff

LOG: [ELF][test] Improve tests about non-SHF_ALLOC sections relocated by non-ABS relocations

Added: 
    

Modified: 
    lld/test/ELF/non-abs-reloc.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/non-abs-reloc.s b/lld/test/ELF/non-abs-reloc.s
index 6053afbdc3faff0..2212421c2373df6 100644
--- a/lld/test/ELF/non-abs-reloc.s
+++ b/lld/test/ELF/non-abs-reloc.s
@@ -1,17 +1,27 @@
 // REQUIRES: x86
-// RUN: split-file %s %t
-// RUN: llvm-mc -filetype=obj -triple=i386 %t/asm -o %t.o
-// RUN: ld.lld -T %t/lds %t.o -o %t.exe 2>&1 | FileCheck %s --implicit-check-not=warning: --implicit-check-not=error:
+// RUN: rm -rf %t && split-file %s %t && cd %t
+// RUN: llvm-mc -filetype=obj -triple=i386 --defsym X86_32=1 asm -o a.o
+// RUN: ld.lld -T lds a.o -o a 2>&1 | FileCheck %s --implicit-check-not=warning:
 // CHECK:      warning: {{.*}}.o:(.nonalloc1+0x1): has non-ABS relocation R_386_PC32 against symbol '_start'
 // CHECK-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_386_PC32 against symbol '_start'
 
-// RUN: llvm-objdump -D --no-show-raw-insn %t.exe | FileCheck --check-prefix=DISASM %s
+// RUN: llvm-objdump -D --no-show-raw-insn a | FileCheck --check-prefix=DISASM %s
 // DISASM:      Disassembly of section .nonalloc:
 // DISASM-EMPTY:
 // DISASM-NEXT: <.nonalloc>:
 // DISASM-NEXT:   0: nop
-// DISASM-NEXT:   1: calll 0x0
-// DISASM-NEXT:   6: calll 0x0
+// DISASM-NEXT:   1: call{{.}} 0x0
+// DISASM-NEXT:   6: call{{.}} 0x0
+
+/// There is currently no error for -r. See also https://github.com/ClangBuiltLinux/linux/issues/1937
+// RUN: ld.lld -T lds -r a.o -o /dev/null --fatal-warnings
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64 asm -o b.o
+// RUN: ld.lld -T lds b.o -o b 2>&1 | FileCheck %s --check-prefix=CHECK2 --implicit-check-not=warning:
+// RUN: llvm-objdump -D --no-show-raw-insn b | FileCheck --check-prefix=DISASM %s
+// RUN: ld.lld -T lds -r b.o -o /dev/null --fatal-warnings
+// CHECK2:      warning: {{.*}}.o:(.nonalloc1+0x1): has non-ABS relocation R_X86_64_PC32 against symbol '_start'
+// CHECK2-NEXT: warning: {{.*}}.o:(.nonalloc1+0x6): has non-ABS relocation R_X86_64_PC32 against symbol '_start'
 
 //--- lds
 SECTIONS {
@@ -34,5 +44,7 @@ _start:
 
 // GCC may relocate DW_AT_GNU_call_site_value with R_386_GOTOFF.
 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98946
+.ifdef X86_32
 .section .debug_random
   .long .L0 at gotoff
+.endif


        


More information about the llvm-commits mailing list