Skip to content

Commit d5da557

Browse files
authored
[LLD][COFF] Allow -arm64xsameaddress in ARM64EC directives (#139631)
Make it a no-op for now, which is sufficient for non-hybrid images. Fixes #131712.
1 parent e3867cb commit d5da557

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

lld/COFF/Driver.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ void LinkerDriver::parseDirectives(InputFile *file) {
491491
case OPT_alternatename:
492492
file->symtab.parseAlternateName(arg->getValue());
493493
break;
494+
case OPT_arm64xsameaddress:
495+
if (!file->symtab.isEC())
496+
Warn(ctx) << arg->getSpelling()
497+
<< " is not allowed in non-ARM64EC files (" << toString(file)
498+
<< ")";
499+
break;
494500
case OPT_defaultlib:
495501
if (std::optional<StringRef> path = findLibIfNew(arg->getValue()))
496502
enqueuePath(*path, false, false);

lld/COFF/Options.td

+1
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,4 @@ def tlbid : P_priv<"tlbid">;
356356
def tlbout : P_priv<"tlbout">;
357357
def verbose_all : P_priv<"verbose">;
358358
def guardsym : P_priv<"guardsym">;
359+
def arm64xsameaddress : P_priv<"arm64xsameaddress">;

lld/test/COFF/arm64x-sameaddress.test

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
REQUIRES: aarch64
2+
RUN: split-file %s %t.dir && cd %t.dir
3+
4+
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows func-arm64ec.s -o func-arm64ec.obj
5+
RUN: llvm-mc -filetype=obj -triple=aarch64-windows func-arm64.s -o func-arm64.obj
6+
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows drectve.s -o drectve.obj
7+
RUN: llvm-mc -filetype=obj -triple=aarch64-windows drectve.s -o drectve-arm64.obj
8+
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
9+
RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj
10+
11+
RUN: lld-link -machine:arm64x -dll -noentry -out:out.dll loadconfig-arm64.obj loadconfig-arm64ec.obj \
12+
RUN: func-arm64.obj func-arm64ec.obj drectve.obj
13+
14+
RUN: lld-link -machine:arm64x -dll -noentry -out:out-cmd.dll loadconfig-arm64.obj loadconfig-arm64ec.obj \
15+
RUN: func-arm64.obj func-arm64ec.obj -arm64xsameaddress:func
16+
17+
RUN: lld-link -machine:arm64ec -dll -noentry -out:out-ec.dll loadconfig-arm64ec.obj func-arm64ec.obj drectve.obj
18+
19+
RUN: lld-link -machine:arm64x -dll -noentry -out:out-warn.dll loadconfig-arm64.obj loadconfig-arm64ec.obj \
20+
RUN: func-arm64.obj func-arm64ec.obj drectve-arm64.obj 2>&1 | FileCheck --check-prefix=WARN %s
21+
WARN: lld-link: warning: -arm64xsameaddress: is not allowed in non-ARM64EC files (drectve-arm64.obj)
22+
23+
#--- func-arm64.s
24+
.section .text,"xr",discard,func
25+
.globl func
26+
func:
27+
mov x0, #1
28+
ret
29+
30+
#--- func-arm64ec.s
31+
.section .text,"xr",discard,"#func"
32+
.globl "#func"
33+
"#func":
34+
mov x0, #2
35+
ret
36+
37+
.weak_anti_dep func
38+
.set func,"#func"
39+
40+
.section .wowthk,"xr",discard,entry_thunk
41+
.globl entry_thunk
42+
entry_thunk:
43+
mov x0, #3
44+
ret
45+
46+
.section .test,"dr"
47+
.rva func
48+
49+
.section .hybmp$x,"yi"
50+
.symidx "#func"
51+
.symidx entry_thunk
52+
.word 1
53+
54+
#--- drectve.s
55+
.section .drectve, "yn"
56+
.ascii " -arm64xsameaddress:func"

0 commit comments

Comments
 (0)