diff options
author | Tristan Gingold <gingold@adacore.com> | 2011-08-08 10:21:02 +0000 |
---|---|---|
committer | Tristan Gingold <gingold@adacore.com> | 2011-08-08 10:21:02 +0000 |
commit | edbdea0ed776219d6ce4584a05213ec210b779f9 (patch) | |
tree | 1d1f2ccf0056156eed3184dbef6d3044b8c512de /bfd/mach-o.c | |
parent | 46d1c23bceb2b8923af0d00a7f536a88524d6a74 (diff) | |
download | gdb-edbdea0ed776219d6ce4584a05213ec210b779f9.zip gdb-edbdea0ed776219d6ce4584a05213ec210b779f9.tar.gz gdb-edbdea0ed776219d6ce4584a05213ec210b779f9.tar.bz2 |
bfd/
2011-08-08 Tristan Gingold <gingold@adacore.com>
* mach-o.h (bfd_mach_o_version_min_command): New structure.
(bfd_mach_o_load_command): Add version_min.
(mach_o_data_struct): Fix comment.
* mach-o.c (bfd_mach_o_read_version_min): New function.
(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_FUNCTION_STARTS,
BFD_MACH_O_LC_VERSION_MIN_MACOSX and
BFD_MACH_O_LC_VERSION_MIN_IPHONEOS.
(bfd_mach_o_get_name_or_null): New function.
(bfd_mach_o_get_name): Use the above new one.
(bfd_mach_o_load_command_name): Add the above new commands.
(bfd_mach_o_bfd_print_private_bfd_data): Display numerically
unknown commands. Handle BFD_MACH_O_LC_FUNCTION_STARTS,
BFD_MACH_O_LC_VERSION_MIN_MACOSX and
BFD_MACH_O_LC_VERSION_MIN_IPHONEOS.
include/mach-o/
2011-08-08 Tristan Gingold <gingold@adacore.com>
* loader.h (bfd_mach_o_load_command_type): Add
BFD_MACH_O_LC_LOAD_UPWARD_DYLIB, BFD_MACH_O_LC_VERSION_MIN_MACOSX,
BFD_MACH_O_LC_VERSION_MIN_IPHONEOS, BFD_MACH_O_LC_FUNCTION_STARTS,
and BFD_MACH_O_LC_DYLD_ENVIRONMENT.
* external.h (mach_o_version_min_command_external): New structure.
Diffstat (limited to 'bfd/mach-o.c')
-rw-r--r-- | bfd/mach-o.c | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/bfd/mach-o.c b/bfd/mach-o.c index 5973df7..445ad18 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -2433,6 +2433,25 @@ bfd_mach_o_read_dyld_info (bfd *abfd, bfd_mach_o_load_command *command) return 0; } +static bfd_boolean +bfd_mach_o_read_version_min (bfd *abfd, bfd_mach_o_load_command *command) +{ + bfd_mach_o_version_min_command *cmd = &command->command.version_min; + struct mach_o_version_min_command_external raw; + unsigned int ver; + + if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0 + || bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw)) + return FALSE; + + ver = bfd_get_32 (abfd, raw.version); + cmd->rel = ver >> 16; + cmd->maj = ver >> 8; + cmd->min = ver; + cmd->reserved = bfd_get_32 (abfd, raw.reserved); + return TRUE; +} + static int bfd_mach_o_read_segment (bfd *abfd, bfd_mach_o_load_command *command, @@ -2606,6 +2625,7 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command) break; case BFD_MACH_O_LC_CODE_SIGNATURE: case BFD_MACH_O_LC_SEGMENT_SPLIT_INFO: + case BFD_MACH_O_LC_FUNCTION_STARTS: if (bfd_mach_o_read_linkedit (abfd, command) != 0) return -1; break; @@ -2613,6 +2633,11 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command) if (bfd_mach_o_read_dyld_info (abfd, command) != 0) return -1; break; + case BFD_MACH_O_LC_VERSION_MIN_MACOSX: + case BFD_MACH_O_LC_VERSION_MIN_IPHONEOS: + if (!bfd_mach_o_read_version_min (abfd, command)) + return -1; + break; default: (*_bfd_error_handler) (_("unable to read unknown load command 0x%lx"), (unsigned long) command->type); @@ -3308,12 +3333,24 @@ bfd_mach_o_print_flags (const bfd_mach_o_xlat_name *table, } static const char * -bfd_mach_o_get_name (const bfd_mach_o_xlat_name *table, unsigned long val) +bfd_mach_o_get_name_or_null (const bfd_mach_o_xlat_name *table, + unsigned long val) { for (; table->name; table++) if (table->val == val) return table->name; - return "*UNKNOWN*"; + return NULL; +} + +static const char * +bfd_mach_o_get_name (const bfd_mach_o_xlat_name *table, unsigned long val) +{ + const char *res = bfd_mach_o_get_name_or_null (table, val); + + if (res == NULL) + return "*UNKNOWN*"; + else + return res; } static bfd_mach_o_xlat_name bfd_mach_o_cpu_name[] = @@ -3451,6 +3488,11 @@ static bfd_mach_o_xlat_name bfd_mach_o_load_command_name[] = { "lazy_load_dylib", BFD_MACH_O_LC_LAZY_LOAD_DYLIB}, { "encryption_info", BFD_MACH_O_LC_ENCRYPTION_INFO}, { "dyld_info", BFD_MACH_O_LC_DYLD_INFO}, + { "load_upward_lib", BFD_MACH_O_LC_LOAD_UPWARD_DYLIB}, + { "version_min_macosx", BFD_MACH_O_LC_VERSION_MIN_MACOSX}, + { "version_min_iphoneos", BFD_MACH_O_LC_VERSION_MIN_IPHONEOS}, + { "function_starts", BFD_MACH_O_LC_FUNCTION_STARTS}, + { "dyld_environment", BFD_MACH_O_LC_DYLD_ENVIRONMENT}, { NULL, 0} }; @@ -3843,9 +3885,16 @@ bfd_mach_o_bfd_print_private_bfd_data (bfd *abfd, void * ptr) for (i = 0; i < mdata->header.ncmds; i++) { bfd_mach_o_load_command *cmd = &mdata->commands[i]; + const char *cmd_name; - fprintf (file, "Load command %s:", - bfd_mach_o_get_name (bfd_mach_o_load_command_name, cmd->type)); + cmd_name = bfd_mach_o_get_name_or_null + (bfd_mach_o_load_command_name, cmd->type); + fprintf (file, "Load command "); + if (cmd_name == NULL) + fprintf (file, "0x%02x:", cmd->type); + else + fprintf (file, "%s:", cmd_name); + switch (cmd->type) { case BFD_MACH_O_LC_SEGMENT: @@ -3903,6 +3952,7 @@ bfd_mach_o_bfd_print_private_bfd_data (bfd *abfd, void * ptr) break; case BFD_MACH_O_LC_CODE_SIGNATURE: case BFD_MACH_O_LC_SEGMENT_SPLIT_INFO: + case BFD_MACH_O_LC_FUNCTION_STARTS: { bfd_mach_o_linkedit_command *linkedit = &cmd->command.linkedit; fprintf @@ -3957,8 +4007,18 @@ bfd_mach_o_bfd_print_private_bfd_data (bfd *abfd, void * ptr) fprintf (file, "\n"); bfd_mach_o_print_dyld_info (abfd, cmd, file); break; + case BFD_MACH_O_LC_VERSION_MIN_MACOSX: + case BFD_MACH_O_LC_VERSION_MIN_IPHONEOS: + { + bfd_mach_o_version_min_command *ver = &cmd->command.version_min; + + fprintf (file, " %u.%u.%u\n", ver->rel, ver->maj, ver->min); + } + break; default: fprintf (file, "\n"); + fprintf (file, " offset: 0x%08lx\n", (unsigned long)cmd->offset); + fprintf (file, " size: 0x%08lx\n", (unsigned long)cmd->len); break; } fputc ('\n', file); |