From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28624 invoked by alias); 20 Jan 2012 10:40:57 -0000 Received: (qmail 28609 invoked by uid 22791); 20 Jan 2012 10:40:55 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Jan 2012 10:40:41 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 47BA3CB3BB9 for ; Fri, 20 Jan 2012 11:40:41 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2dTZBe9-95+3 for ; Fri, 20 Jan 2012 11:40:41 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 34DABCB3BB8 for ; Fri, 20 Jan 2012 11:40:41 +0100 (CET) From: Tristan Gingold Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: [Patch] Darwin: dump segment split info Date: Fri, 20 Jan 2012 10:40:00 -0000 Message-Id: <0E946F02-57B7-43DF-81DF-34F1C0744160@adacore.com> To: binutils Development Mime-Version: 1.0 (Apple Message framework v1251.1) X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00211.txt.bz2 Hi, I am committing this patch to display Mach-O segment split info data. Tristan. binutils/ 2012-01-20 Tristan Gingold * od-macho.c (OPT_SEG_SPLIT_INFO): New macro. (options): Add an entry for seg_split_info. (mach_o_help): Document it. (dump_segment_split_info): New function. (dump_load_command): Handle seg_split_info. Index: od-macho.c =================================================================== RCS file: /cvs/src/src/binutils/od-macho.c,v retrieving revision 1.4 diff -c -r1.4 od-macho.c *** od-macho.c 4 Jan 2012 10:37:36 -0000 1.4 --- od-macho.c 20 Jan 2012 10:39:22 -0000 *************** *** 27,32 **** --- 27,33 ---- #include "objdump.h" #include "bucomm.h" #include "bfdlink.h" + #include "libbfd.h" #include "mach-o.h" #include "mach-o/external.h" #include "mach-o/codesign.h" *************** *** 38,43 **** --- 39,45 ---- #define OPT_LOAD 3 #define OPT_DYSYMTAB 4 #define OPT_CODESIGN 5 + #define OPT_SEG_SPLIT_INFO 6 /* List of actions. */ static struct objdump_private_option options[] = *************** *** 48,53 **** --- 50,56 ---- { "load", 0 }, { "dysymtab", 0 }, { "codesign", 0 }, + { "seg_split_info", 0 }, { NULL, 0 } }; *************** *** 58,69 **** { fprintf (stream, _("\ For Mach-O files:\n\ ! header Display the file header\n\ ! section Display the segments and sections commands\n\ ! map Display the section map\n\ ! load Display the load commands\n\ ! dysymtab Display the dynamic symbol table\n\ ! codesign Display code signature section\n\ ")); } --- 61,73 ---- { fprintf (stream, _("\ For Mach-O files:\n\ ! header Display the file header\n\ ! section Display the segments and sections commands\n\ ! map Display the section map\n\ ! load Display the load commands\n\ ! dysymtab Display the dynamic symbol table\n\ ! codesign Display code signature\n\ ! seg_split_info Display segment split info\n\ ")); } *************** *** 852,857 **** --- 856,908 ---- } static void + dump_segment_split_info (bfd *abfd, bfd_mach_o_linkedit_command *cmd) + { + unsigned char *buf = xmalloc (cmd->datasize); + unsigned char *p; + unsigned int len; + bfd_vma addr = 0; + + if (bfd_seek (abfd, cmd->dataoff, SEEK_SET) != 0 + || bfd_bread (buf, cmd->datasize, abfd) != cmd->datasize) + { + non_fatal (_("cannot read segment split info")); + free (buf); + return; + } + if (buf[cmd->datasize - 1] != 0) + { + non_fatal (_("segment split info is not nul terminated")); + free (buf); + return; + } + + switch (buf[0]) + { + case 0: + printf (_(" 32 bit pointers:\n")); + break; + case 1: + printf (_(" 64 bit pointers:\n")); + break; + case 2: + printf (_(" PPC hi-16:\n")); + break; + default: + printf (_(" Unhandled location type %u\n"), buf[0]); + break; + } + for (p = buf + 1; *p != 0; p += len) + { + addr += read_unsigned_leb128 (abfd, p, &len); + fputs (" ", stdout); + bfd_printf_vma (abfd, addr); + putchar ('\n'); + } + free (buf); + } + + static void dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd, bfd_boolean verbose) { *************** *** 942,947 **** --- 993,1000 ---- if (verbose && cmd->type == BFD_MACH_O_LC_CODE_SIGNATURE) dump_code_signature (abfd, linkedit); + else if (verbose && cmd->type == BFD_MACH_O_LC_SEGMENT_SPLIT_INFO) + dump_segment_split_info (abfd, linkedit); break; } case BFD_MACH_O_LC_SUB_FRAMEWORK: *************** *** 1026,1031 **** --- 1079,1086 ---- dump_load_commands (abfd, BFD_MACH_O_LC_DYSYMTAB, 0); if (options[OPT_CODESIGN].selected) dump_load_commands (abfd, BFD_MACH_O_LC_CODE_SIGNATURE, 0); + if (options[OPT_SEG_SPLIT_INFO].selected) + dump_load_commands (abfd, BFD_MACH_O_LC_SEGMENT_SPLIT_INFO, 0); } /* Vector for Mach-O. */