diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-26 13:57:44 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-26 13:57:44 +0000 |
commit | 6c2e2d1c6b29534e99630fedbaa5e39652258449 (patch) | |
tree | 570b26ad9a325d7ef9a0cc69b020d5af13a27f68 /test/Scripts | |
parent | a421de11df9d2a07b9f95a1ad817467af426803a (diff) | |
download | external_llvm-6c2e2d1c6b29534e99630fedbaa5e39652258449.zip external_llvm-6c2e2d1c6b29534e99630fedbaa5e39652258449.tar.gz external_llvm-6c2e2d1c6b29534e99630fedbaa5e39652258449.tar.bz2 |
llvm-mc/Mach-O: Dump relocations and section data (optionally) in my Mach-O dumper.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80087 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Scripts')
-rwxr-xr-x | test/Scripts/macho-dump | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/test/Scripts/macho-dump b/test/Scripts/macho-dump index 800015e..12ec26d 100755 --- a/test/Scripts/macho-dump +++ b/test/Scripts/macho-dump @@ -208,20 +208,42 @@ def dumpSection32(f, i, opts): print " (('section_name', %r)" % f.read(16) print " ('segment_name', %r)" % f.read(16) print " ('address', %r)" % f.read32() - print " ('size', %r)" % f.read32() - print " ('offset', %r)" % f.read32() - print " ('alignment', %r)" % f.read32() - print " ('reloc_offset', %r)" % f.read32() - print " ('num_reloc', %r)" % f.read32() + size = f.read32() + print " ('size', %r)" % size + offset = f.read32() + print " ('offset', %r)" % offset + print " ('alignment', %r)" % f.read32() + reloc_offset = f.read32() + print " ('reloc_offset', %r)" % reloc_offset + num_reloc = f.read32() + print " ('num_reloc', %r)" % num_reloc print " ('flags', %#x)" % f.read32() print " ('reserved1', %r)" % f.read32() print " ('reserved2', %r)" % f.read32() print " )," + + prev_pos = f.tell() + + f.seek(reloc_offset) + print " ('_relocations', [" + for i in range(num_reloc): + print " # Relocation %r" % i + print " (('word-0', %#x)," % f.read32() + print " ('word-1', %#x))," % f.read32() + print " ])" + + if opts.dumpSectionData: + f.seek(offset) + print " ('_section_data', %r)" % f.read(size) + + f.seek(prev_pos) def main(): from optparse import OptionParser, OptionGroup parser = OptionParser("usage: %prog [options] {files}") - + parser.add_option("", "--dump-section-data", dest="dumpSectionData", + help="Dump the contents of sections", + action="store_true", default=False) (opts, args) = parser.parse_args() if not args: |