diff options
author | Daniel Paoliello <danpao@microsoft.com> | 2024-03-12 14:10:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-12 14:10:49 -0700 |
commit | 1a6ec906fb3781c2fc98979ec37a2a76479b0b08 (patch) | |
tree | 9de33284d5b3f51175eaec5616d05a243faaeb71 /llvm/lib/Object/ArchiveWriter.cpp | |
parent | 498b7d2f86b4bceb381e66b093670c7ec4bc6cc4 (diff) | |
download | llvm-1a6ec906fb3781c2fc98979ec37a2a76479b0b08.zip llvm-1a6ec906fb3781c2fc98979ec37a2a76479b0b08.tar.gz llvm-1a6ec906fb3781c2fc98979ec37a2a76479b0b08.tar.bz2 |
[Arm64EC] Copy import descriptors to the EC Map (#84834)
As noted in <https://github.com/llvm/llvm-project/pull/78537>, MSVC
places import descriptors in both the EC and regular map - that PR moved
the descriptors to ONLY the regular map, however this causes linking
errors when linking as Arm64EC:
```
bcryptprimitives.lib(bcryptprimitives.dll) : error LNK2001: unresolved external symbol __IMPORT_DESCRIPTOR_bcryptprimitives (EC Symbol)
```
This change copies import descriptors from the regular map to the EC
map, which fixes this linking error.
Diffstat (limited to 'llvm/lib/Object/ArchiveWriter.cpp')
-rw-r--r-- | llvm/lib/Object/ArchiveWriter.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp index be51093..e062974 100644 --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -677,6 +677,13 @@ static bool isECObject(object::SymbolicFile &Obj) { return false; } +bool isImportDescriptor(StringRef Name) { + return Name.starts_with(ImportDescriptorPrefix) || + Name == StringRef{NullImportDescriptorSymbolName} || + (Name.starts_with(NullThunkDataPrefix) && + Name.ends_with(NullThunkDataSuffix)); +} + static Expected<std::vector<unsigned>> getSymbols(SymbolicFile *Obj, uint16_t Index, raw_ostream &SymNames, @@ -704,6 +711,10 @@ static Expected<std::vector<unsigned>> getSymbols(SymbolicFile *Obj, if (Map == &SymMap->Map) { Ret.push_back(SymNames.tell()); SymNames << Name << '\0'; + // If EC is enabled, then the import descriptors are NOT put into EC + // objects so we need to copy them to the EC map manually. + if (SymMap->UseECMap && isImportDescriptor(Name)) + SymMap->ECMap[Name] = Index; } } else { Ret.push_back(SymNames.tell()); |