}
/// \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");
_symbolTable.add(*target);
}
}
- return true;
}
// Called on each atom when a file is added. Returns true if a given
_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);
}