Object: account for short output names (#66532)

The import library thunk name suffix uses the stem of the file. We
currently would attempt to trim the suffix by dropping the trailing 4
characters (under the assumption that the output name was `.lib`). This
now uses the `llvm::sys::path` API for computing the stem. This avoids
an assertion failure when the name is less the 4 characters and
assertions are enabled.
This commit is contained in:
Saleem Abdulrasool 2023-09-15 12:58:23 -07:00 committed by GitHub
parent cbdccb30c2
commit 401296f697
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -70,3 +70,4 @@ CHECK-NODEF-DLL: default.dll
CHECK-NODEF-DLL: default.dll
CHECK-NODEF-DLL: default.dll
# RUN: lld-link /nologo /machine:x64 /out:%T/exe %T/object.obj /entry:f /subsystem:CONSOLE

View File

@ -140,7 +140,7 @@ class ObjectFactory {
public:
ObjectFactory(StringRef S, MachineTypes M)
: Machine(M), ImportName(S), Library(S.drop_back(4)),
: Machine(M), ImportName(S), Library(llvm::sys::path::stem(S)),
ImportDescriptorSymbolName(("__IMPORT_DESCRIPTOR_" + Library).str()),
NullThunkSymbolName(("\x7f" + Library + "_NULL_THUNK_DATA").str()) {}