mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
[llvm-objdump] support -rebase option for mach-o to dump rebasing info
Similar to my previous -exports-trie option, the -rebase option dumps info from the LC_DYLD_INFO load command. The rebasing info is a list of the the locations that dyld needs to adjust if a mach-o image is not loaded at its preferred address. Since ASLR is now the default, images almost never load at their preferred address, and thus need to be rebased by dyld. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217709 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -100,6 +100,42 @@ private:
|
||||
};
|
||||
typedef content_iterator<ExportEntry> export_iterator;
|
||||
|
||||
/// MachORebaseEntry encapsulates the current state in the decompression of
|
||||
/// rebasing opcodes. This allows you to iterate through the compressed table of
|
||||
/// rebasing using:
|
||||
/// for (const llvm::object::MachORebaseEntry &Entry : Obj->rebaseTable()) {
|
||||
/// }
|
||||
class MachORebaseEntry {
|
||||
public:
|
||||
MachORebaseEntry(ArrayRef<uint8_t> opcodes, bool is64Bit);
|
||||
|
||||
uint32_t segmentIndex() const;
|
||||
uint64_t segmentOffset() const;
|
||||
StringRef typeName() const;
|
||||
|
||||
bool operator==(const MachORebaseEntry &) const;
|
||||
|
||||
void moveNext();
|
||||
|
||||
private:
|
||||
friend class MachOObjectFile;
|
||||
void moveToFirst();
|
||||
void moveToEnd();
|
||||
uint64_t readULEB128();
|
||||
|
||||
ArrayRef<uint8_t> Opcodes;
|
||||
const uint8_t *Ptr;
|
||||
uint64_t SegmentOffset;
|
||||
uint32_t SegmentIndex;
|
||||
uint64_t RemainingLoopCount;
|
||||
uint64_t AdvanceAmount;
|
||||
uint8_t RebaseType;
|
||||
uint8_t PointerSize;
|
||||
bool Malformed;
|
||||
bool Done;
|
||||
};
|
||||
typedef content_iterator<MachORebaseEntry> rebase_iterator;
|
||||
|
||||
class MachOObjectFile : public ObjectFile {
|
||||
public:
|
||||
struct LoadCommandInfo {
|
||||
@@ -202,6 +238,13 @@ public:
|
||||
/// For use examining a trie not in a MachOObjectFile.
|
||||
static iterator_range<export_iterator> exports(ArrayRef<uint8_t> Trie);
|
||||
|
||||
/// For use iterating over all rebase table entries.
|
||||
iterator_range<rebase_iterator> rebaseTable() const;
|
||||
|
||||
/// For use examining rebase opcodes not in a MachOObjectFile.
|
||||
static iterator_range<rebase_iterator> rebaseTable(ArrayRef<uint8_t> Opcodes,
|
||||
bool is64);
|
||||
|
||||
// In a MachO file, sections have a segment name. This is used in the .o
|
||||
// files. They have a single segment, but this field specifies which segment
|
||||
// a section should be put in in the final object.
|
||||
|
Reference in New Issue
Block a user