[lld] r210241 - Print error message in LinkOnce handler.
Rui Ueyama
ruiu at google.com
Thu Jun 5 00:37:25 PDT 2014
Author: ruiu
Date: Thu Jun 5 02:37:25 2014
New Revision: 210241
URL: http://llvm.org/viewvc/llvm-project?rev=210241&view=rev
Log:
Print error message in LinkOnce handler.
Rather than outside of the handler function to make the code simple.
Modified:
lld/trunk/include/lld/Core/Resolver.h
lld/trunk/lib/Core/Resolver.cpp
Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=210241&r1=210240&r2=210241&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Thu Jun 5 02:37:25 2014
@@ -57,7 +57,7 @@ private:
typedef std::function<void(StringRef, bool)> UndefCallback;
/// \brief Add section group/.gnu.linkonce if it does not exist previously.
- bool maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom);
+ void maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom);
/// \brief The main function that iterates over the files to resolve
bool resolveUndefines();
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=210241&r1=210240&r2=210241&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Jun 5 02:37:25 2014
@@ -148,26 +148,30 @@ bool Resolver::doUndefinedAtom(const Und
}
/// \brief Add the section group and the group-child reference members.
-bool Resolver::maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom) {
+void Resolver::maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom) {
// First time adding a group?
bool isFirstTime = _symbolTable.addGroup(atom);
if (!isFirstTime) {
// If duplicate symbols are allowed, select the first group.
if (_context.getAllowDuplicates())
- return true;
- const DefinedAtom *prevGroup =
- dyn_cast<DefinedAtom>(_symbolTable.findGroup(atom.name()));
+ return;
+ auto *prevGroup = dyn_cast<DefinedAtom>(_symbolTable.findGroup(atom.name()));
assert(prevGroup &&
"Internal Error: The group atom could only be a defined atom");
// The atoms should be of the same content type, reject invalid group
// resolution behaviors.
- return atom.contentType() == prevGroup->contentType();
+ if (atom.contentType() == prevGroup->contentType())
+ return;
+ llvm::errs() << "SymbolTable: error while merging " << atom.name()
+ << "\n";
+ llvm::report_fatal_error("duplicate symbol error");
+ return;
}
for (const Reference *r : atom) {
- if ((r->kindNamespace() == lld::Reference::KindNamespace::all) &&
- (r->kindValue() == lld::Reference::kindGroupChild)) {
+ if (r->kindNamespace() == lld::Reference::KindNamespace::all &&
+ r->kindValue() == lld::Reference::kindGroupChild) {
const DefinedAtom *target = dyn_cast<DefinedAtom>(r->target());
assert(target && "Internal Error: kindGroupChild references need to "
"be associated with Defined Atoms only");
@@ -175,7 +179,6 @@ bool Resolver::maybeAddSectionGroupOrGnu
_symbolTable.add(*target);
}
}
- return true;
}
// Called on each atom when a file is added. Returns true if a given
@@ -202,12 +205,7 @@ void Resolver::doDefinedAtom(const Defin
_atoms.push_back(&atom);
if (atom.isGroupParent()) {
- // Raise error if there exists a similar gnu linkonce section.
- if (!maybeAddSectionGroupOrGnuLinkOnce(atom)) {
- llvm::errs() << "SymbolTable: error while merging " << atom.name()
- << "\n";
- llvm::report_fatal_error("duplicate symbol error");
- }
+ maybeAddSectionGroupOrGnuLinkOnce(atom);
} else {
_symbolTable.add(atom);
}
More information about the llvm-commits
mailing list