1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00
Alexander Shaposhnikov c942981326 Introduce llvm-install-name-tool
This diff adds a new "driver" for llvm-objcopy
which is supposed to emulate the behavior of install-name-tool.
This is a recommit of b5913e6 with ubsan, test dependencies issues fixed.

Differential revision: https://reviews.llvm.org/D69146

Test plan: make check-all
2019-11-19 23:42:37 -08:00

39 lines
1.1 KiB
C++

#include "Object.h"
#include "../llvm-objcopy.h"
namespace llvm {
namespace objcopy {
namespace macho {
const SymbolEntry *SymbolTable::getSymbolByIndex(uint32_t Index) const {
assert(Index < Symbols.size() && "invalid symbol index");
return Symbols[Index].get();
}
SymbolEntry *SymbolTable::getSymbolByIndex(uint32_t Index) {
return const_cast<SymbolEntry *>(
static_cast<const SymbolTable *>(this)->getSymbolByIndex(Index));
}
void SymbolTable::removeSymbols(
function_ref<bool(const std::unique_ptr<SymbolEntry> &)> ToRemove) {
Symbols.erase(
std::remove_if(std::begin(Symbols), std::end(Symbols), ToRemove),
std::end(Symbols));
}
void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
for (LoadCommand &LC : LoadCommands)
LC.Sections.erase(std::remove_if(std::begin(LC.Sections),
std::end(LC.Sections), ToRemove),
std::end(LC.Sections));
}
void Object::addLoadCommand(LoadCommand LC) {
LoadCommands.push_back(std::move(LC));
}
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm