[lld] de266ce - [lld/mac] Don't assert when using -exported_symbol with private symbol
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 24 07:22:04 PDT 2021
Author: Nico Weber
Date: 2021-04-24T10:21:51-04:00
New Revision: de266ce4f9f2dfc989d2f9f82017229be5f535eb
URL: https://github.com/llvm/llvm-project/commit/de266ce4f9f2dfc989d2f9f82017229be5f535eb
DIFF: https://github.com/llvm/llvm-project/commit/de266ce4f9f2dfc989d2f9f82017229be5f535eb.diff
LOG: [lld/mac] Don't assert when using -exported_symbol with private symbol
When I added this assert in D93609, it asserted that a symbol that
is privateExtern is also isExternal().
In D98381 the privateExtern check moved into shouldExportSymbol()
but the assert didn't -- now it checked that _every_ non-exported
symbol is isExternal(), which isn't true. Move the assert into the
privateExtern check where it used to be.
Fixes PR50098.
Differential Revision: https://reviews.llvm.org/D101223
Added:
Modified:
lld/MachO/SyntheticSections.cpp
lld/test/MachO/export-options.s
Removed:
################################################################################
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 8b1616f415a4..387bfc2ca462 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -585,8 +585,10 @@ static void validateExportSymbol(const Defined *defined) {
}
static bool shouldExportSymbol(const Defined *defined) {
- if (defined->privateExtern)
+ if (defined->privateExtern) {
+ assert(defined->isExternal() && "invalid input file");
return false;
+ }
// TODO: Is this a performance bottleneck? If a build has mostly
// global symbols in the input but uses -exported_symbols to filter
// out most of them, then it would be better to set the value of
@@ -844,7 +846,6 @@ template <class LP> void SymtabSectionImpl<LP>::writeTo(uint8_t *buf) const {
if (!shouldExportSymbol(defined)) {
// Private external -- dylib scoped symbol.
// Promote to non-external at link time.
- assert(defined->isExternal() && "invalid input file");
scope = N_PEXT;
} else if (defined->isExternal()) {
// Normal global symbol.
diff --git a/lld/test/MachO/export-options.s b/lld/test/MachO/export-options.s
index f219dfaea321..d7c904e842bc 100644
--- a/lld/test/MachO/export-options.s
+++ b/lld/test/MachO/export-options.s
@@ -38,6 +38,8 @@ _hide_globl:
.private_extern _private_extern
_private_extern:
retq
+_private:
+ retq
## Check that the export trie is unaltered
# RUN: %lld -dylib %t/default.o -o %t/default
More information about the llvm-commits
mailing list