diff --git a/lld/COFF/Symbols.h b/lld/COFF/Symbols.h --- a/lld/COFF/Symbols.h +++ b/lld/COFF/Symbols.h @@ -80,6 +80,9 @@ // is a waste of time. if (nameData == nullptr) computeName(); + if (nameData == nullptr) + return StringRef{}; // I don't know, if we can be sure, that nameSize is 0 + // in this case. return StringRef(nameData, nameSize); } diff --git a/lld/COFF/Symbols.cpp b/lld/COFF/Symbols.cpp --- a/lld/COFF/Symbols.cpp +++ b/lld/COFF/Symbols.cpp @@ -55,7 +55,9 @@ void Symbol::computeName() { assert(nameData == nullptr && "should only compute the name once for DefinedCOFF symbols"); - auto *d = cast(this); + auto *d = dyn_cast(this); + if (d == nullptr) + return; StringRef nameStr = check(cast(d->file)->getCOFFObj()->getSymbolName(d->sym)); nameData = nameStr.data(); diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -396,7 +396,7 @@ default: llvm_unreachable("Unexpected architecture"); } - Defined *d = make("", c); + Defined *d = make("range_extension_thunk", c); lastThunk = d; return {d, true}; } diff --git a/lld/test/COFF/arm-thumb-thunks.s b/lld/test/COFF/arm-thumb-thunks.s --- a/lld/test/COFF/arm-thumb-thunks.s +++ b/lld/test/COFF/arm-thumb-thunks.s @@ -1,6 +1,6 @@ // REQUIRES: arm // RUN: llvm-mc -filetype=obj -triple=thumbv7-windows %s -o %t.obj -// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s +// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -map -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s // RUN: llvm-objdump -d %t.exe --start-address=0x401000 --stop-address=0x401022 | FileCheck --check-prefix=MAIN %s // RUN: llvm-objdump -d %t.exe --start-address=0x501022 --stop-address=0x501032 | FileCheck --check-prefix=FUNC1 %s // RUN: llvm-objdump -d %t.exe --start-address=0x601032 | FileCheck --check-prefix=FUNC2 %s