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 | |
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.
-rw-r--r-- | bfd/ChangeLog | 17 | ||||
-rw-r--r-- | bfd/mach-o.c | 68 | ||||
-rw-r--r-- | bfd/mach-o.h | 12 | ||||
-rw-r--r-- | include/mach-o/ChangeLog | 8 | ||||
-rw-r--r-- | include/mach-o/external.h | 6 | ||||
-rw-r--r-- | include/mach-o/loader.h | 7 |
6 files changed, 112 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9cad7fe..89b459e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,22 @@ 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. + +2011-08-08 Tristan Gingold <gingold@adacore.com> + * mach-o.h: Move size macros to external.h Move reloc macros to reloc.h and x86-64.h. * mach-o-i386.c: Includes mach-o/reloc.h 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); diff --git a/bfd/mach-o.h b/bfd/mach-o.h index de9640a..1da79ff 100644 --- a/bfd/mach-o.h +++ b/bfd/mach-o.h @@ -453,6 +453,15 @@ typedef struct bfd_mach_o_dyld_info_command } bfd_mach_o_dyld_info_command; +typedef struct bfd_mach_o_version_min_command +{ + unsigned char rel; + unsigned char maj; + unsigned char min; + unsigned int reserved; +} +bfd_mach_o_version_min_command; + typedef struct bfd_mach_o_load_command { bfd_mach_o_load_command_type type; @@ -472,6 +481,7 @@ typedef struct bfd_mach_o_load_command bfd_mach_o_linkedit_command linkedit; bfd_mach_o_str_command str; bfd_mach_o_dyld_info_command dyld_info; + bfd_mach_o_version_min_command version_min; } command; } @@ -493,7 +503,7 @@ typedef struct mach_o_data_struct ufile_ptr filelen; /* As symtab is referenced by other load command, it is handy to have - a direct access to it. Also it is not clearly stated, only one symtab + a direct access to it. Although it is not clearly stated, only one symtab is expected. */ bfd_mach_o_symtab_command *symtab; bfd_mach_o_dysymtab_command *dysymtab; diff --git a/include/mach-o/ChangeLog b/include/mach-o/ChangeLog index dff287a..2276d01 100644 --- a/include/mach-o/ChangeLog +++ b/include/mach-o/ChangeLog @@ -1,5 +1,13 @@ 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. + +2011-08-08 Tristan Gingold <gingold@adacore.com> + * loader.h: Reorder declarations. * x86-64.h: New file. * external.h: New file. diff --git a/include/mach-o/external.h b/include/mach-o/external.h index c2fe7e3..ebb09a7 100644 --- a/include/mach-o/external.h +++ b/include/mach-o/external.h @@ -249,6 +249,12 @@ struct mach_o_dyld_info_command_external unsigned char export_size[4]; }; +struct mach_o_version_min_command_external +{ + unsigned char version[4]; + unsigned char reserved[4]; +}; + struct mach_o_fat_header_external { unsigned char magic[4]; diff --git a/include/mach-o/loader.h b/include/mach-o/loader.h index 1105204..357f65e 100644 --- a/include/mach-o/loader.h +++ b/include/mach-o/loader.h @@ -148,7 +148,12 @@ typedef enum bfd_mach_o_load_command_type BFD_MACH_O_LC_REEXPORT_DYLIB = 0x1f, /* Load and re-export lib. */ BFD_MACH_O_LC_LAZY_LOAD_DYLIB = 0x20, /* Delay load of lib until use. */ BFD_MACH_O_LC_ENCRYPTION_INFO = 0x21, /* Encrypted segment info. */ - BFD_MACH_O_LC_DYLD_INFO = 0x22 /* Compressed dyld information. */ + BFD_MACH_O_LC_DYLD_INFO = 0x22, /* Compressed dyld information. */ + BFD_MACH_O_LC_LOAD_UPWARD_DYLIB = 0x23, /* Load upward dylib. */ + BFD_MACH_O_LC_VERSION_MIN_MACOSX = 0x24, /* Minimal MacOSX version. */ + BFD_MACH_O_LC_VERSION_MIN_IPHONEOS = 0x25, /* Minimal IOS version. */ + BFD_MACH_O_LC_FUNCTION_STARTS = 0x26, /* Compressed table of func start. */ + BFD_MACH_O_LC_DYLD_ENVIRONMENT = 0x27 /* Env variable string for dyld. */ } bfd_mach_o_load_command_type; |