[lld] lld: add support for NOCROSSREFS(_TO) (PR #95714)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 11:01:10 PDT 2024
================
@@ -0,0 +1,110 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -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 -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 -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 -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 -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 -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 -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 -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 -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 -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
+
+.global _start
+_start:
+ nop
+
+.section .text
+test:
+ call test1
----------------
smithp35 wrote:
Can you add a call to test here? This would check that calls within the same OutputSection are permitted.
https://github.com/llvm/llvm-project/pull/95714
More information about the llvm-commits
mailing list