From 4b592831e6a9cd4874fd51f535e95cf18e74f020 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 4 Jan 2012 10:37:34 +0000 Subject: [PATCH] bfd/ 2012-01-04 Tristan Gingold * mach-o.h (bfd_mach_o_fvmlib_command): New structure. (bfd_mach_o_load_command): Add fvmlib field. * mach-o.c (bfd_mach_o_read_fvmlib): New function. (bfd_mach_o_read_command): Handle fvmlib. binutils/ 2012-01-04 Tristan Gingold * od-macho.c (dump_load_command): Handle fvmlib. include/mach-o/ 2012-01-04 Tristan Gingold * external.h (mach_o_fvmlib_command_external): New structure. --- bfd/ChangeLog | 8 ++++++++ bfd/mach-o.c | 29 +++++++++++++++++++++++++++++ bfd/mach-o.h | 11 +++++++++++ binutils/ChangeLog | 4 ++++ binutils/od-macho.c | 11 ++++++++++- include/mach-o/ChangeLog | 4 ++++ include/mach-o/external.h | 7 +++++++ 7 files changed, 73 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2fd6ae039..4eac2d419 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,13 @@ 2012-01-04 Tristan Gingold + * mach-o.h (bfd_mach_o_fvmlib_command): New structure. + (bfd_mach_o_load_command): Add fvmlib field. + + * mach-o.c (bfd_mach_o_read_fvmlib): New function. + (bfd_mach_o_read_command): Handle fvmlib. + +2012-01-04 Tristan Gingold + * mach-o.c (bfd_mach_o_convert_architecture): Reindent. Decode msubtype for ARM. diff --git a/bfd/mach-o.c b/bfd/mach-o.c index a72cba020..d2fd7e186 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -3045,6 +3045,32 @@ bfd_mach_o_read_prebound_dylib (bfd *abfd ATTRIBUTE_UNUSED, } static int +bfd_mach_o_read_fvmlib (bfd *abfd, bfd_mach_o_load_command *command) +{ + bfd_mach_o_fvmlib_command *fvm = &command->command.fvmlib; + struct mach_o_fvmlib_command_external raw; + unsigned int nameoff; + + if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0 + || bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw)) + return -1; + + nameoff = bfd_h_get_32 (abfd, raw.name); + fvm->minor_version = bfd_h_get_32 (abfd, raw.minor_version); + fvm->header_addr = bfd_h_get_32 (abfd, raw.header_addr); + + fvm->name_offset = command->offset + nameoff; + fvm->name_len = command->len - nameoff; + fvm->name_str = bfd_alloc (abfd, fvm->name_len); + if (fvm->name_str == NULL) + return -1; + if (bfd_seek (abfd, fvm->name_offset, SEEK_SET) != 0 + || bfd_bread (fvm->name_str, fvm->name_len, abfd) != fvm->name_len) + return -1; + return 0; +} + +static int bfd_mach_o_read_thread (bfd *abfd, bfd_mach_o_load_command *command) { bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd); @@ -3618,6 +3644,9 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command) break; case BFD_MACH_O_LC_LOADFVMLIB: case BFD_MACH_O_LC_IDFVMLIB: + if (bfd_mach_o_read_fvmlib (abfd, command) != 0) + return -1; + break; case BFD_MACH_O_LC_IDENT: case BFD_MACH_O_LC_FVMFILE: case BFD_MACH_O_LC_PREPAGE: diff --git a/bfd/mach-o.h b/bfd/mach-o.h index b32b6a896..123eddafe 100644 --- a/bfd/mach-o.h +++ b/bfd/mach-o.h @@ -450,6 +450,16 @@ typedef struct bfd_mach_o_str_command } bfd_mach_o_str_command; +typedef struct bfd_mach_o_fvmlib_command +{ + unsigned int name_offset; + unsigned int name_len; + char *name_str; + unsigned int minor_version; + unsigned int header_addr; +} +bfd_mach_o_fvmlib_command; + typedef struct bfd_mach_o_dyld_info_command { /* File offset and size to rebase info. */ @@ -512,6 +522,7 @@ typedef struct bfd_mach_o_load_command bfd_mach_o_dyld_info_command dyld_info; bfd_mach_o_version_min_command version_min; bfd_mach_o_encryption_info_command encryption_info; + bfd_mach_o_fvmlib_command fvmlib; } command; } diff --git a/binutils/ChangeLog b/binutils/ChangeLog index a7a78c4d9..88397d2c7 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,5 +1,9 @@ 2012-01-04 Tristan Gingold + * od-macho.c (dump_load_command): Handle fvmlib. + +2012-01-04 Tristan Gingold + * od-macho.c: Update copyright year. (dump_load_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO. diff --git a/binutils/od-macho.c b/binutils/od-macho.c index fbdd53f3a..91e080e9b 100644 --- a/binutils/od-macho.c +++ b/binutils/od-macho.c @@ -896,8 +896,8 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd, dylib->current_version); printf (" comptibility version: 0x%08lx\n", dylib->compatibility_version); - break; } + break; case BFD_MACH_O_LC_LOAD_DYLINKER: case BFD_MACH_O_LC_ID_DYLINKER: printf (" %s\n", cmd->command.dylinker.name_str); @@ -920,6 +920,15 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd, putchar ('\n'); dump_dysymtab (abfd, cmd, verbose); break; + case BFD_MACH_O_LC_LOADFVMLIB: + case BFD_MACH_O_LC_IDFVMLIB: + { + bfd_mach_o_fvmlib_command *fvmlib = &cmd->command.fvmlib; + printf (" %s\n", fvmlib->name_str); + printf (" minor version: 0x%08x\n", fvmlib->minor_version); + printf (" header address: 0x%08x\n", fvmlib->header_addr); + } + break; case BFD_MACH_O_LC_CODE_SIGNATURE: case BFD_MACH_O_LC_SEGMENT_SPLIT_INFO: case BFD_MACH_O_LC_FUNCTION_STARTS: diff --git a/include/mach-o/ChangeLog b/include/mach-o/ChangeLog index 0280ca778..2cd71c963 100644 --- a/include/mach-o/ChangeLog +++ b/include/mach-o/ChangeLog @@ -1,5 +1,9 @@ 2012-01-04 Tristan Gingold + * external.h (mach_o_fvmlib_command_external): New structure. + +2012-01-04 Tristan Gingold + * loader.h: Update copyright year. (bfd_mach_o_cpu_subtype): Add ARM subtypes. diff --git a/include/mach-o/external.h b/include/mach-o/external.h index 23d9a5c00..ad419ef54 100644 --- a/include/mach-o/external.h +++ b/include/mach-o/external.h @@ -262,6 +262,13 @@ struct mach_o_encryption_info_command_external unsigned char cryptid[4]; /* Encryption method. */ }; +struct mach_o_fvmlib_command_external +{ + unsigned char name[4]; /* Offset of the name. */ + unsigned char minor_version[4]; + unsigned char header_addr[4]; +}; + struct mach_o_fat_header_external { unsigned char magic[4]; -- 2.11.4.GIT