From: Tristan Gingold Date: Wed, 4 Jan 2012 09:58:55 +0000 (+0000) Subject: bfd/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fc55a902573b7f73d8f138b843f31f5adbe7331e;p=binutils-gdb.git bfd/ 2012-01-04 Tristan Gingold * mach-o.h: Reindent header. (bfd_mach_o_encryption_info_command): New structure. (bfd_mach_o_load_command): Add encryption_info field. * mach-o.c (bfd_mach_o_read_encryption_info): New function. (bfd_mach_o_read_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO. (bfd_mach_o_read_command): Adjust error message. binutils/ 2012-01-04 Tristan Gingold * od-macho.c: Update copyright year. (dump_load_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO. include/mach-o/ 2012-01-04 Tristan Gingold * external.h: Update copyright year. (mach_o_symtab_command_external): Add comments. (mach_o_encryption_info_command_external): New structure. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 0974a0aae8f..e3d2a4882b8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2012-01-04 Tristan Gingold + + * mach-o.h: Reindent header. + (bfd_mach_o_encryption_info_command): New structure. + (bfd_mach_o_load_command): Add encryption_info field. + + * mach-o.c (bfd_mach_o_read_encryption_info): New function. + (bfd_mach_o_read_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO. + (bfd_mach_o_read_command): Adjust error message. + 2012-01-04 Shinichiro Hamaji * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Factor out the part diff --git a/bfd/mach-o.c b/bfd/mach-o.c index 30b77d8057a..57c37d88dec 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -3411,6 +3411,22 @@ bfd_mach_o_read_version_min (bfd *abfd, bfd_mach_o_load_command *command) return TRUE; } +static bfd_boolean +bfd_mach_o_read_encryption_info (bfd *abfd, bfd_mach_o_load_command *command) +{ + bfd_mach_o_encryption_info_command *cmd = &command->command.encryption_info; + struct mach_o_encryption_info_command_external raw; + + if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0 + || bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw)) + return FALSE; + + cmd->cryptoff = bfd_get_32 (abfd, raw.cryptoff); + cmd->cryptsize = bfd_get_32 (abfd, raw.cryptsize); + cmd->cryptid = bfd_get_32 (abfd, raw.cryptid); + return TRUE; +} + static int bfd_mach_o_read_segment (bfd *abfd, bfd_mach_o_load_command *command, @@ -3587,6 +3603,10 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command) if (bfd_mach_o_read_linkedit (abfd, command) != 0) return -1; break; + case BFD_MACH_O_LC_ENCRYPTION_INFO: + if (!bfd_mach_o_read_encryption_info (abfd, command)) + return -1; + break; case BFD_MACH_O_LC_DYLD_INFO: if (bfd_mach_o_read_dyld_info (abfd, command) != 0) return -1; @@ -3597,7 +3617,7 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command) return -1; break; default: - (*_bfd_error_handler)(_("%B: unable to read unknown load command 0x%lx"), + (*_bfd_error_handler)(_("%B: unknown load command 0x%lx"), abfd, (unsigned long) command->type); break; } diff --git a/bfd/mach-o.h b/bfd/mach-o.h index da4363bee9c..b32b6a8962f 100644 --- a/bfd/mach-o.h +++ b/bfd/mach-o.h @@ -1,6 +1,7 @@ /* Mach-O support for BFD. Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2011, - 2012 Free Software Foundation, Inc. + 2012 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -482,6 +483,14 @@ typedef struct bfd_mach_o_version_min_command } bfd_mach_o_version_min_command; +typedef struct bfd_mach_o_encryption_info_command +{ + unsigned int cryptoff; + unsigned int cryptsize; + unsigned int cryptid; +} +bfd_mach_o_encryption_info_command; + typedef struct bfd_mach_o_load_command { bfd_mach_o_load_command_type type; @@ -502,6 +511,7 @@ typedef struct bfd_mach_o_load_command bfd_mach_o_str_command str; bfd_mach_o_dyld_info_command dyld_info; bfd_mach_o_version_min_command version_min; + bfd_mach_o_encryption_info_command encryption_info; } command; } diff --git a/binutils/ChangeLog b/binutils/ChangeLog index b81c81d40f2..a7a78c4d960 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2012-01-04 Tristan Gingold + + * od-macho.c: Update copyright year. + (dump_load_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO. + 2011-12-28 Ian Lance Taylor * dwarf.c (read_and_display_attr_value): Handle DW_LANG_Go. diff --git a/binutils/od-macho.c b/binutils/od-macho.c index c5e315dad3d..fbdd53f3aa7 100644 --- a/binutils/od-macho.c +++ b/binutils/od-macho.c @@ -1,5 +1,5 @@ /* od-macho.c -- dump information about an Mach-O object file. - Copyright 2011 Free Software Foundation, Inc. + Copyright 2011, 2012 Free Software Foundation, Inc. Written by Tristan Gingold, Adacore. This file is part of GNU Binutils. @@ -949,6 +949,19 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd, case BFD_MACH_O_LC_UNIXTHREAD: dump_thread (abfd, cmd); break; + case BFD_MACH_O_LC_ENCRYPTION_INFO: + { + bfd_mach_o_encryption_info_command *cryp = + &cmd->command.encryption_info; + printf + ("\n" + " cryptoff: 0x%08x cryptsize: 0x%08x (endoff 0x%08x)" + " cryptid: %u\n", + cryp->cryptoff, cryp->cryptsize, + cryp->cryptoff + cryp->cryptsize, + cryp->cryptid); + } + break; case BFD_MACH_O_LC_DYLD_INFO: putchar ('\n'); dump_dyld_info (abfd, cmd); diff --git a/include/mach-o/ChangeLog b/include/mach-o/ChangeLog index 9e5150582ce..2cbd47a4c58 100644 --- a/include/mach-o/ChangeLog +++ b/include/mach-o/ChangeLog @@ -1,3 +1,9 @@ +2012-01-04 Tristan Gingold + + * external.h: Update copyright year. + (mach_o_symtab_command_external): Add comments. + (mach_o_encryption_info_command_external): New structure. + 2011-12-16 Tristan Gingold * codesign.h: New file. diff --git a/include/mach-o/external.h b/include/mach-o/external.h index ebb09a7761e..23d9a5c0060 100644 --- a/include/mach-o/external.h +++ b/include/mach-o/external.h @@ -1,5 +1,5 @@ /* Mach-O support for BFD. - Copyright 2011 + Copyright 2011, 2012 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -118,10 +118,10 @@ struct mach_o_reloc_info_external struct mach_o_symtab_command_external { - unsigned char symoff[4]; - unsigned char nsyms[4]; - unsigned char stroff[4]; - unsigned char strsize[4]; + unsigned char symoff[4]; /* File offset of the symbol table. */ + unsigned char nsyms[4]; /* Number of symbols. */ + unsigned char stroff[4]; /* File offset of the string table. */ + unsigned char strsize[4]; /* String table size. */ }; struct mach_o_nlist_external @@ -255,6 +255,13 @@ struct mach_o_version_min_command_external unsigned char reserved[4]; }; +struct mach_o_encryption_info_command_external +{ + unsigned char cryptoff[4]; /* File offset of the encrypted area. */ + unsigned char cryptsize[4]; /* Size of the encrypted area. */ + unsigned char cryptid[4]; /* Encryption method. */ +}; + struct mach_o_fat_header_external { unsigned char magic[4];