forked from OSchip/llvm-project
parent
7ce0fe015e
commit
c53b3b0809
|
@ -41,10 +41,9 @@ public:
|
||||||
if (_liveAtoms.count(atom))
|
if (_liveAtoms.count(atom))
|
||||||
return false;
|
return false;
|
||||||
// don't remove if marked never-dead-strip
|
// don't remove if marked never-dead-strip
|
||||||
if (const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(atom)) {
|
if (const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(atom))
|
||||||
if (defAtom->deadStrip() == DefinedAtom::deadStripNever)
|
if (defAtom->deadStrip() == DefinedAtom::deadStripNever)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
// do remove this atom
|
// do remove this atom
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -249,16 +248,14 @@ void Resolver::doAbsoluteAtom(const AbsoluteAtom &atom) {
|
||||||
_atoms.push_back(&atom);
|
_atoms.push_back(&atom);
|
||||||
|
|
||||||
// tell symbol table
|
// tell symbol table
|
||||||
if (atom.scope() != Atom::scopeTranslationUnit) {
|
if (atom.scope() != Atom::scopeTranslationUnit)
|
||||||
_symbolTable.add(atom);
|
_symbolTable.add(atom);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility to add a vector of atoms
|
// utility to add a vector of atoms
|
||||||
void Resolver::addAtoms(const std::vector<const DefinedAtom *> &newAtoms) {
|
void Resolver::addAtoms(const std::vector<const DefinedAtom *> &newAtoms) {
|
||||||
for (const DefinedAtom *newAtom : newAtoms) {
|
for (const DefinedAtom *newAtom : newAtoms)
|
||||||
this->doDefinedAtom(*newAtom);
|
this->doDefinedAtom(*newAtom);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep adding atoms until _context.nextFile() returns an error. This function
|
// Keep adding atoms until _context.nextFile() returns an error. This function
|
||||||
|
@ -363,9 +360,8 @@ void Resolver::deadStripOptimize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark all roots as live, and recursively all atoms they reference
|
// mark all roots as live, and recursively all atoms they reference
|
||||||
for (const Atom *dsrAtom : _deadStripRoots) {
|
for (const Atom *dsrAtom : _deadStripRoots)
|
||||||
this->markLive(*dsrAtom);
|
this->markLive(*dsrAtom);
|
||||||
}
|
|
||||||
|
|
||||||
// now remove all non-live atoms from _atoms
|
// now remove all non-live atoms from _atoms
|
||||||
_atoms.erase(
|
_atoms.erase(
|
||||||
|
@ -443,10 +439,9 @@ bool Resolver::resolve() {
|
||||||
return false;
|
return false;
|
||||||
this->updateReferences();
|
this->updateReferences();
|
||||||
this->deadStripOptimize();
|
this->deadStripOptimize();
|
||||||
if (this->checkUndefines(false)) {
|
if (this->checkUndefines(false))
|
||||||
if (!_context.allowRemainingUndefines())
|
if (!_context.allowRemainingUndefines())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
this->removeCoalescedAwayAtoms();
|
this->removeCoalescedAwayAtoms();
|
||||||
this->linkTimeOptimize();
|
this->linkTimeOptimize();
|
||||||
this->_result->addAtoms(_atoms);
|
this->_result->addAtoms(_atoms);
|
||||||
|
|
|
@ -100,8 +100,8 @@ void GOTPass::perform(std::unique_ptr<MutableFile> &mergedFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all created GOT Atoms to master file
|
// add all created GOT Atoms to master file
|
||||||
for (auto &it : targetToGOT) {
|
for (auto &it : targetToGOT)
|
||||||
mergedFile->addAtom(*it.second);
|
mergedFile->addAtom(*it.second);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namesapce lld
|
||||||
|
|
|
@ -416,19 +416,17 @@ void LayoutPass::buildInGroupTable(MutableFile::DefinedAtomRange &range) {
|
||||||
// Check if the current atom is part of the chain
|
// Check if the current atom is part of the chain
|
||||||
bool isAtomInChain = false;
|
bool isAtomInChain = false;
|
||||||
const DefinedAtom *lastAtom = rootAtom;
|
const DefinedAtom *lastAtom = rootAtom;
|
||||||
while (true) {
|
for (;;) {
|
||||||
AtomToAtomT::iterator followOnAtomsIter =
|
AtomToAtomT::iterator followOnAtomsIter =
|
||||||
_followOnNexts.find(lastAtom);
|
_followOnNexts.find(lastAtom);
|
||||||
if (followOnAtomsIter != _followOnNexts.end()) {
|
if (followOnAtomsIter != _followOnNexts.end()) {
|
||||||
lastAtom = followOnAtomsIter->second;
|
lastAtom = followOnAtomsIter->second;
|
||||||
if (lastAtom == ai) {
|
if (lastAtom != ai)
|
||||||
isAtomInChain = true;
|
continue;
|
||||||
break;
|
isAtomInChain = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
break;
|
}
|
||||||
} // findAtomInChain
|
|
||||||
|
|
||||||
if (!isAtomInChain)
|
if (!isAtomInChain)
|
||||||
_followOnNexts[lastAtom] = ai;
|
_followOnNexts[lastAtom] = ai;
|
||||||
|
@ -517,9 +515,8 @@ void LayoutPass::buildOrdinalOverrideMap(MutableFile::DefinedAtomRange &range) {
|
||||||
for (const DefinedAtom *nextAtom = start->second; nextAtom != NULL;
|
for (const DefinedAtom *nextAtom = start->second; nextAtom != NULL;
|
||||||
nextAtom = _followOnNexts[nextAtom]) {
|
nextAtom = _followOnNexts[nextAtom]) {
|
||||||
AtomToOrdinalT::iterator pos = _ordinalOverrideMap.find(nextAtom);
|
AtomToOrdinalT::iterator pos = _ordinalOverrideMap.find(nextAtom);
|
||||||
if (pos == _ordinalOverrideMap.end()) {
|
if (pos == _ordinalOverrideMap.end())
|
||||||
_ordinalOverrideMap[nextAtom] = index++;
|
_ordinalOverrideMap[nextAtom] = index++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue