mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 02:31:09 +00:00
macho-dump: Add support for dumping dysymtab indirect symbol table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120214 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4aeb489043
commit
4c55e0db0f
@ -220,6 +220,15 @@ namespace macho {
|
|||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
/// @name Indirect Symbol Table
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
struct IndirectSymbolTableEntry {
|
||||||
|
uint32_t Index;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
// See <mach-o/nlist.h>.
|
// See <mach-o/nlist.h>.
|
||||||
enum SymbolTypeType {
|
enum SymbolTypeType {
|
||||||
STT_Undefined = 0x00,
|
STT_Undefined = 0x00,
|
||||||
|
@ -125,6 +125,10 @@ public:
|
|||||||
void ReadDysymtabLoadCommand(
|
void ReadDysymtabLoadCommand(
|
||||||
const LoadCommandInfo &LCI,
|
const LoadCommandInfo &LCI,
|
||||||
InMemoryStruct<macho::DysymtabLoadCommand> &Res) const;
|
InMemoryStruct<macho::DysymtabLoadCommand> &Res) const;
|
||||||
|
void ReadIndirectSymbolTableEntry(
|
||||||
|
const macho::DysymtabLoadCommand &DLC,
|
||||||
|
unsigned Index,
|
||||||
|
InMemoryStruct<macho::IndirectSymbolTableEntry> &Res) const;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
@ -230,3 +230,16 @@ void MachOObject::ReadDysymtabLoadCommand(const LoadCommandInfo &LCI,
|
|||||||
InMemoryStruct<macho::DysymtabLoadCommand> &Res) const {
|
InMemoryStruct<macho::DysymtabLoadCommand> &Res) const {
|
||||||
ReadInMemoryStruct(*this, Buffer->getBuffer(), LCI.Offset, Res);
|
ReadInMemoryStruct(*this, Buffer->getBuffer(), LCI.Offset, Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void SwapStruct(macho::IndirectSymbolTableEntry &Value) {
|
||||||
|
SwapValue(Value.Index);
|
||||||
|
}
|
||||||
|
void
|
||||||
|
MachOObject::ReadIndirectSymbolTableEntry(const macho::DysymtabLoadCommand &DLC,
|
||||||
|
unsigned Index,
|
||||||
|
InMemoryStruct<macho::IndirectSymbolTableEntry> &Res) const {
|
||||||
|
uint64_t Offset = (DLC.IndirectSymbolTableOffset +
|
||||||
|
Index * sizeof(macho::IndirectSymbolTableEntry));
|
||||||
|
ReadInMemoryStruct(*this, Buffer->getBuffer(), Offset, Res);
|
||||||
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "llvm/Object/MachOObject.h"
|
#include "llvm/Object/MachOObject.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@ -154,7 +155,24 @@ static int DumpDysymtabCommand(MachOObject &Obj,
|
|||||||
outs() << " ('locreloff', " << DLC->LocalRelocationTableOffset << ")\n";
|
outs() << " ('locreloff', " << DLC->LocalRelocationTableOffset << ")\n";
|
||||||
outs() << " ('nlocrel', " << DLC->NumLocalRelocationTableEntries << ")\n";
|
outs() << " ('nlocrel', " << DLC->NumLocalRelocationTableEntries << ")\n";
|
||||||
|
|
||||||
return 0;
|
// Dump the indirect symbol table.
|
||||||
|
int Res = 0;
|
||||||
|
outs() << " ('_indirect_symbols', [\n";
|
||||||
|
for (unsigned i = 0; i != DLC->NumIndirectSymbolTableEntries; ++i) {
|
||||||
|
InMemoryStruct<macho::IndirectSymbolTableEntry> ISTE;
|
||||||
|
Obj.ReadIndirectSymbolTableEntry(*DLC, i, ISTE);
|
||||||
|
if (!ISTE) {
|
||||||
|
Res = Error("unable to read segment load command");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
outs() << " # Indirect Symbol " << i << "\n";
|
||||||
|
outs() << " (('symbol_index', "
|
||||||
|
<< format("%#x", ISTE->Index) << "),),\n";
|
||||||
|
}
|
||||||
|
outs() << " ])\n";
|
||||||
|
|
||||||
|
return Res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DumpLoadCommand(MachOObject &Obj, unsigned Index) {
|
static int DumpLoadCommand(MachOObject &Obj, unsigned Index) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user