[lld] lld: add support for NOCROSSREFS(_TO) (PR #95714)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 21 12:05:02 PDT 2024
================
@@ -0,0 +1,149 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS(.text .text1); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: not ld.lld %t.o -o %t --script %t.script 2>&1 | FileCheck -check-prefix=ERR %s
+// ERR: ld.lld: error: {{.*}}.o:(.text+{{.*}}): prohibited cross reference from .text to in .text1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS_TO(.text1 .text); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: not ld.lld %t.o -o %t --script %t.script 2>&1 | FileCheck -check-prefix=ERR1 %s
+// ERR1: ld.lld: error: {{.*}}.o:(.text+{{.*}}): prohibited cross reference from .text to in .text1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS(.text1 .text .text2); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: not ld.lld %t.o -o %t --script %t.script 2>&1 | FileCheck -check-prefix=ERR2 %s
+// ERR2: ld.lld: error: {{.*}}.o:(.text+{{.*}}): prohibited cross reference from .text to in .text1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS_TO(.text .text1); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS_TO(); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS(); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS(.text); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS_TO(.text); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS_TO(.text2 .text); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS(.text .text2); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS(.text .text2); \
+// RUN: SECTIONS { \
+// RUN: foo = ABSOLUTE(.); \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS(.text .text2); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: .bss : { *(.unused) } \
+// RUN: } " > %t.script
+// RUN: ld.lld %t.o -o %t --script %t.script 2>&1
+
+// RUN: llvm-mc --triple=x86_64-unknown-linux -filetype=obj -o %t.o %s
+// RUN: echo "NOCROSSREFS(.text .bss); \
+// RUN: SECTIONS { \
+// RUN: .text : { *(.text) } \
+// RUN: .text1 : { *(.text1) } \
+// RUN: .text2 : { *(.text2) } \
+// RUN: .bss : { *(.unused) } \
+// RUN: } " > %t.script
+// RUN: not ld.lld %t.o -o %t --script %t.script 2>&1 | FileCheck -check-prefix=ERR3 %s
+// ERR3: ld.lld: error: {{.*}}.o:(.text+{{.*}}): prohibited cross reference from .text to unused in .bss
----------------
MaskRay wrote:
> In this test split-file + rm should be run before each test, since each script file has its own NOCROSSREFS. On windows this fails, since it's not possible to remove cwd.
You currently create scripts with echo. With split-file, you place scripts as split-file parts. See `addr.test`
https://github.com/llvm/llvm-project/pull/95714
More information about the llvm-commits
mailing list