forked from OSchip/llvm-project
Print error message in LinkOnce handler.
Rather than outside of the handler function to make the code simple. llvm-svn: 210241
This commit is contained in:
parent
f3cb9d1d57
commit
52edc49031
|
@ -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();
|
||||
|
|
|
@ -148,26 +148,30 @@ bool Resolver::doUndefinedAtom(const UndefinedAtom &atom) {
|
|||
}
|
||||
|
||||
/// \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::maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom) {
|
|||
_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 DefinedAtom &atom) {
|
|||
_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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue