blob: 5626782d7d6e8c5dd4bb864b193de32385c9313d [file] [log] [blame]
Seiya Nutaf923d9b2019-06-21 00:21:50 +00001#include "Object.h"
2#include "../llvm-objcopy.h"
3
4namespace llvm {
5namespace objcopy {
6namespace macho {
7
8const SymbolEntry *SymbolTable::getSymbolByIndex(uint32_t Index) const {
9 assert(Index < Symbols.size() && "invalid symbol index");
10 return Symbols[Index].get();
11}
12
Seiya Nuta9bbf2a12019-10-31 13:51:11 +090013SymbolEntry *SymbolTable::getSymbolByIndex(uint32_t Index) {
14 return const_cast<SymbolEntry *>(
15 static_cast<const SymbolTable *>(this)->getSymbolByIndex(Index));
16}
17
18void SymbolTable::removeSymbols(
19 function_ref<bool(const std::unique_ptr<SymbolEntry> &)> ToRemove) {
20 Symbols.erase(
21 std::remove_if(std::begin(Symbols), std::end(Symbols), ToRemove),
22 std::end(Symbols));
23}
24
Seiya Nuta7f19dd12019-10-28 15:40:37 +090025void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
26 for (LoadCommand &LC : LoadCommands)
27 LC.Sections.erase(std::remove_if(std::begin(LC.Sections),
28 std::end(LC.Sections), ToRemove),
29 std::end(LC.Sections));
30}
31
Seiya Nutaf923d9b2019-06-21 00:21:50 +000032} // end namespace macho
33} // end namespace objcopy
34} // end namespace llvm