[llvm-objdump] for mach-o add -bind, -lazy-bind, and -weak-bind options

This finishes the ability of llvm-objdump to print out all information from
the LC_DYLD_INFO load command.

The -bind option prints out symbolic references that dyld must resolve 
immediately.

The -lazy-bind option prints out symbolc reference that are lazily resolved on 
first use.

The -weak-bind option prints out information about symbols which dyld must
try to coalesce across images.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Kledzik
2014-09-16 01:41:51 +00:00
parent 2e363ece75
commit 367cf70f27
11 changed files with 544 additions and 3 deletions

View File

@ -136,6 +136,54 @@ private:
};
typedef content_iterator<MachORebaseEntry> rebase_iterator;
/// MachOBindEntry encapsulates the current state in the decompression of
/// binding opcodes. This allows you to iterate through the compressed table of
/// bindings using:
/// for (const llvm::object::MachOBindEntry &Entry : Obj->bindTable()) {
/// }
class MachOBindEntry {
public:
enum class Kind { Regular, Lazy, Weak };
MachOBindEntry(ArrayRef<uint8_t> Opcodes, bool is64Bit, MachOBindEntry::Kind);
uint32_t segmentIndex() const;
uint64_t segmentOffset() const;
StringRef typeName() const;
StringRef symbolName() const;
uint32_t flags() const;
int64_t addend() const;
int ordinal() const;
bool operator==(const MachOBindEntry &) const;
void moveNext();
private:
friend class MachOObjectFile;
void moveToFirst();
void moveToEnd();
uint64_t readULEB128();
int64_t readSLEB128();
ArrayRef<uint8_t> Opcodes;
const uint8_t *Ptr;
uint64_t SegmentOffset;
uint32_t SegmentIndex;
StringRef SymbolName;
int Ordinal;
uint32_t Flags;
int64_t Addend;
uint64_t RemainingLoopCount;
uint64_t AdvanceAmount;
uint8_t BindType;
uint8_t PointerSize;
Kind TableKind;
bool Malformed;
bool Done;
};
typedef content_iterator<MachOBindEntry> bind_iterator;
class MachOObjectFile : public ObjectFile {
public:
struct LoadCommandInfo {
@ -245,6 +293,21 @@ public:
static iterator_range<rebase_iterator> rebaseTable(ArrayRef<uint8_t> Opcodes,
bool is64);
/// For use iterating over all bind table entries.
iterator_range<bind_iterator> bindTable() const;
/// For use iterating over all lazy bind table entries.
iterator_range<bind_iterator> lazyBindTable() const;
/// For use iterating over all lazy bind table entries.
iterator_range<bind_iterator> weakBindTable() const;
/// For use examining bind opcodes not in a MachOObjectFile.
static iterator_range<bind_iterator> bindTable(ArrayRef<uint8_t> Opcodes,
bool is64,
MachOBindEntry::Kind);
// 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.
@ -342,6 +405,8 @@ public:
bool isRelocatableObject() const override;
bool hasPageZeroSegment() const { return HasPageZeroSegment; }
static bool classof(const Binary *v) {
return v->isMachO();
}
@ -357,6 +422,7 @@ private:
const char *DysymtabLoadCmd;
const char *DataInCodeLoadCmd;
const char *DyldInfoLoadCmd;
bool HasPageZeroSegment;
};
/// DiceRef