From a83c3f787969ac4c71b87ecffc10f92aa98e7a0d Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Tue, 25 Jul 2017 19:42:32 +0000 Subject: [LTO] Prevent dead stripping and internalization of symbols with sections Summary: ELF linkers generate __start_ and __stop_ symbols when there is a value in a section where the name is a valid C identifier. If dead stripping determines that the values declared in section are dead, and we then internalize (and delete) such a symbol, programs that reference the corresponding start and end section symbols will get undefined reference linking errors. To fix this, add the section name to the IRSymtab entry when a symbol is defined in a specific section. Then use this in the gold-plugin to mark the symbol as external and visible from outside the summary when the section name is a valid C identifier. Reviewers: pcc Subscribers: mehdi_amini, inglorion, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D35639 llvm-svn: 309009 --- llvm/lib/Object/IRSymtab.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Object/IRSymtab.cpp') diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp index 7a6424a76a9..668cf62d1e8 100644 --- a/llvm/lib/Object/IRSymtab.cpp +++ b/llvm/lib/Object/IRSymtab.cpp @@ -156,6 +156,7 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab, Unc = &Uncommons.back(); *Unc = {}; setStr(Unc->COFFWeakExternFallbackName, ""); + setStr(Unc->SectionName, ""); return *Unc; }; @@ -240,6 +241,9 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab, } } + if (!Base->getSection().empty()) + setStr(Uncommon().SectionName, Saver.save(Base->getSection())); + return Error::success(); } -- cgit v1.2.3