summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Driver.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2019-11-08 14:39:14 +0900
committerRui Ueyama <ruiu@google.com>2019-11-08 19:08:15 +0900
commitf95273f75aaa5db5493aea7902416ce3d5a09043 (patch)
tree13a90d3352b7a7a731a0e6826cf3fe0d04bdadef /lld/ELF/Driver.cpp
parent41449c58c58e466bcf9cdc4f7415950382bad8d7 (diff)
downloadbcm5719-llvm-f95273f75aaa5db5493aea7902416ce3d5a09043.tar.gz
bcm5719-llvm-f95273f75aaa5db5493aea7902416ce3d5a09043.zip
Keep symbols passed by -init and -fini
Previously, symbols passed by -init and -fini look as if they are not referenced by anyone, and the LTO might eliminate them. This patch fixes the issue. Fixes a bug reported in https://bugs.llvm.org/show_bug.cgi?id=43927 Differential Revision: https://reviews.llvm.org/D69985
Diffstat (limited to 'lld/ELF/Driver.cpp')
-rw-r--r--lld/ELF/Driver.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 1b1a50bf6d1..616a9d4c4e8 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1782,6 +1782,12 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
for (StringRef pat : args::getStrings(args, OPT_undefined_glob))
handleUndefinedGlob(pat);
+ // Mark -init and -fini symbols so that the LTO doesn't eliminate them.
+ if (Symbol *sym = symtab->find(config->init))
+ sym->isUsedInRegularObj = true;
+ if (Symbol *sym = symtab->find(config->fini))
+ sym->isUsedInRegularObj = true;
+
// If any of our inputs are bitcode files, the LTO code generator may create
// references to certain library functions that might not be explicit in the
// bitcode file's symbol table. If any of those library functions are defined
OpenPOWER on IntegriCloud