[PATCH] D98686: [lld:elf] Weaken the requirement for a computed binding to be STB_LOCAL
Nathan Lanza via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 16 01:41:09 PDT 2021
lanza created this revision.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: MaskRay.
lanza requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In https://reviews.llvm.org/D77280 the test for `isDefined` was added to
account for lazy symbols (e.g. __udivid3) but `isDefined` also includes
anything `external`.
The motivating case here is:
a.cpp:
struct Animal { virtual void makeNoise() = 0; };
struct Cat : public Animal { virtual void makeNoise() override; };
void Cat::makeNoise() { puts("hi"); }
b.cpp
struct Animal { virtual void makeNoise() = 0; };
struct Cat : public Animal { virtual void makeNoise() override; };
void doThingWithCat(Cat *c) { c->makeNoise(); }
version.exp
{
global:
_Z12doThingWithCat3Cat;
local:
*;
}
b.cpp being part of the link causes the vtbl for `_ZTV3Cat` to be
`STB_GLOBAL` since it's `external`.
Changing the test here to be `!isLocal` lets the version-script win.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98686
Files:
lld/ELF/Symbols.cpp
Index: lld/ELF/Symbols.cpp
===================================================================
--- lld/ELF/Symbols.cpp
+++ lld/ELF/Symbols.cpp
@@ -277,7 +277,7 @@
if (config->relocatable)
return binding;
if ((visibility != STV_DEFAULT && visibility != STV_PROTECTED) ||
- (versionId == VER_NDX_LOCAL && isDefined()))
+ (versionId == VER_NDX_LOCAL && !isLazy()))
return STB_LOCAL;
if (!config->gnuUnique && binding == STB_GNU_UNIQUE)
return STB_GLOBAL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98686.330900.patch
Type: text/x-patch
Size: 486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210316/9e5ae36e/attachment.bin>
More information about the llvm-commits
mailing list