Skip to content

Commit 27b5223

Browse files
cjacektmsri
authored andcommitted
[LLD][COFF] Process all ARM64EC import symbols in MapFile's getSymbols (llvm#109118)
1 parent 8794892 commit 27b5223

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

lld/COFF/Chunks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ class ImportThunkChunkARM64EC : public ImportThunkChunk {
625625
void writeTo(uint8_t *buf) const override;
626626

627627
Defined *exitThunk;
628+
Defined *sym = nullptr;
628629

629630
private:
630631
ImportFile *file;

lld/COFF/InputFiles.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,8 @@ void ImportFile::parse() {
11261126

11271127
StringRef impChkName = saver().save("__impchk_" + name);
11281128
impchkThunk = make<ImportThunkChunkARM64EC>(this);
1129-
ctx.symtab.addImportThunk(impChkName, impSym, impchkThunk);
1129+
impchkThunk->sym =
1130+
ctx.symtab.addImportThunk(impChkName, impSym, impchkThunk);
11301131
ctx.driver.pullArm64ECIcallHelper();
11311132
}
11321133
}

lld/COFF/MapFile.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ static void getSymbols(const COFFLinkerContext &ctx,
126126
syms.push_back(file->impSym);
127127
if (file->thunkSym && file->thunkSym->isLive())
128128
syms.push_back(file->thunkSym);
129+
if (file->auxThunkSym && file->auxThunkSym->isLive())
130+
syms.push_back(file->auxThunkSym);
131+
if (file->impchkThunk)
132+
syms.push_back(file->impchkThunk->sym);
133+
if (file->impECSym)
134+
syms.push_back(file->impECSym);
135+
if (file->auxImpCopySym)
136+
syms.push_back(file->auxImpCopySym);
129137
}
130138

131139
sortUniqueSymbols(syms, ctx.config.imageBase);

lld/test/COFF/arm64ec-import.test

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ RUN: llvm-lib -machine:x64 -def:test.def -out:test-x86_64.lib
1212

1313
Link using ARM64EC import library:
1414
RUN: lld-link -machine:arm64ec -dll -noentry -out:out.dll loadconfig-arm64ec.obj icall.obj hybmp.obj \
15-
RUN: test.obj test-arm64ec.lib test2-arm64ec.lib
15+
RUN: test.obj test-arm64ec.lib test2-arm64ec.lib -map
1616

1717
Link using x86_64 import library:
1818
RUN: lld-link -machine:arm64ec -dll -noentry -out:out2.dll loadconfig-arm64ec.obj icall.obj hybmp.obj \
19-
RUN: test.obj test-x86_64.lib test2-arm64ec.lib
19+
RUN: test.obj test-x86_64.lib test2-arm64ec.lib -map
2020

2121
Link using x86_64 object file:
2222
RUN: lld-link -machine:arm64ec -dll -noentry -out:out3.dll loadconfig-arm64ec.obj icall.obj hybmp.obj \
23-
RUN: test-x86_64.obj test-arm64ec.lib test2-arm64ec.lib
23+
RUN: test-x86_64.obj test-arm64ec.lib test2-arm64ec.lib -map
2424

2525
RUN: llvm-readobj --coff-imports out.dll | FileCheck --check-prefix=IMPORTS %s
2626
RUN: llvm-readobj --coff-imports out2.dll | FileCheck --check-prefix=IMPORTS %s
@@ -87,6 +87,28 @@ TESTSEC-X64-NEXT: 0x180007010 08300000 00500000 10300000 20300000
8787
TESTSEC-X64-NEXT: 0x180007020 14100000 28100000 00200000 08100000
8888
TESTSEC-X64-NEXT: 0x180007030 3c100000 a0420000
8989

90+
RUN: FileCheck --check-prefix=MAP %s < out.map
91+
RUN: FileCheck --check-prefix=MAP %s < out2.map
92+
RUN: FileCheck --check-prefix=MAP %s < out3.map
93+
MAP: 0001:00000008 #func 0000000180001008 test{{.*}}:test.dll
94+
MAP-NEXT: 0001:00000014 __impchk_func 0000000180001014 test{{.*}}:test.dll
95+
MAP-NEXT: 0001:00000028 __impchk_func2 0000000180001028 test{{.*}}:test.dll
96+
MAP-NEXT: 0001:0000003c #t2func 000000018000103c test2{{.*}}:test2.dll
97+
MAP-NEXT: 0001:00000048 __impchk_t2func 0000000180001048 test2{{.*}}:test2.dll
98+
MAP: 0001:00001000 func 0000000180002000 test{{.*}}:test.dll
99+
MAP-NEXT: 0002:00000000 __imp_data 0000000180003000 test{{.*}}:test.dll
100+
MAP-NEXT: 0002:00000008 __imp_aux_func 0000000180003008 test{{.*}}:test.dll
101+
MAP-NEXT: 0002:00000010 __imp_aux_func2 0000000180003010 test{{.*}}:test.dll
102+
MAP-NEXT: 0002:00000020 __imp_aux_t2func 0000000180003020 test2{{.*}}:test2.dll
103+
MAP: 0002:00001298 __auximpcopy_data 0000000180004298 test{{.*}}:test.dll
104+
MAP-NEXT: 0002:000012a0 __auximpcopy_func 00000001800042a0 test{{.*}}:test.dll
105+
MAP-NEXT: 0002:000012a8 __auximpcopy_func2 00000001800042a8 test{{.*}}:test.dll
106+
MAP-NEXT: 0002:000012b8 __auximpcopy_t2func 00000001800042b8 test2{{.*}}:test2.dll
107+
MAP: 0002:00002000 __imp_aux_data 0000000180005000 test{{.*}}:test.dll
108+
MAP-NEXT: 0002:00002008 __imp_func 0000000180005008 test{{.*}}:test.dll
109+
MAP-NEXT: 0002:00002010 __imp_func2 0000000180005010 test{{.*}}:test.dll
110+
MAP-NEXT: 0002:00002020 __imp_t2func 0000000180005020 test2{{.*}}:test2.dll
111+
90112
RUN: llvm-readobj --headers out.dll | FileCheck -check-prefix=HEADERS %s
91113
RUN: llvm-readobj --headers out2.dll | FileCheck -check-prefix=HEADERS %s
92114
RUN: llvm-readobj --headers out3.dll | FileCheck -check-prefix=HEADERS %s

0 commit comments

Comments
 (0)