From 47daa70fe08c57aaafa6fe1a7e762072909d0f8f Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 18 Nov 2015 10:33:11 +0100 Subject: mach-o cleanup: remove useless calls to bfd_seek. Also support new commands. bfd/ * mach-o.h (struct mach_o_data_struct): Add hdr_offset field. (bfd_mach_o_fat_archive_p): Renames prototype. (bfd_mach_o_fat_openr_next_archived_file): Renames. (bfd_mach_o_header_p): Add argument. * mach-o.c (bfd_mach_o_read_header): Add hdr_off argument and use it. (bfd_mach_o_read_section_32, bfd_mach_o_read_section_64) (bfd_mach_o_read_section): Remove offset argument. (bfd_mach_o_read_dylinker): Remove bfd_seek call. (bfd_mach_o_read_dylib, bfd_mach_o_read_prebound_dylib) (bfd_mach_o_read_prebind_cksum, bfd_mach_o_read_twolevel_hints) (bfd_mach_o_read_fvmlib, bfd_mach_o_read_dysymtab) (bfd_mach_o_read_symtab, bfd_mach_o_read_uuid) (bfd_mach_o_read_linkedit, bfd_mach_o_read_str) (bfd_mach_o_read_dyld_info, bfd_mach_o_read_version_min) (bfd_mach_o_read_encryption_info): Likewise. (bfd_mach_o_read_encryption_info_64): New function. (bfd_mach_o_read_main, bfd_mach_o_read_source_version) (bfd_mach_o_read_segment): Remove call to bfd_seek. (bfd_mach_o_read_command): Use hdr_offset in bfd_seek. Handle BFD_MACH_O_LC_LINKER_OPTIMIZATION_HINT, BFD_MACH_O_LC_ENCRYPTION_INFO_64, BFD_MACH_O_LC_VERSION_MIN_WATCHOS. (bfd_mach_o_header_p): Add hdr_off argument. (bfd_mach_o_gen_object_p, bfd_mach_o_gen_core_p): Adjust calls. (bfd_mach_o_fat_archive_p): Renames. (bfd_mach_o_fat_openr_next_archived_file): Renames. (bfd_mach_o_close_and_cleanup): Remove useless code. (bfd_mach_o_close_and_cleanup): Define. * mach-o-x86-64.c (bfd_mach_o_x86_64_object_p) (bfd_mach_o_x86_64_core_p): Adjust calls. * mach-o-target.c: Move defines for archive from mach-o.c. Remove check on TARGET_ARCHIVE. * mach-o-i386.c (bfd_mach_o_i386_object_p) (bfd_mach_o_i386_core_p): Adjust calls. --- bfd/mach-o.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bfd/mach-o.h') diff --git a/bfd/mach-o.h b/bfd/mach-o.h index 0445398..1b62c0f 100644 --- a/bfd/mach-o.h +++ b/bfd/mach-o.h @@ -23,6 +23,7 @@ #include "bfd.h" #include "mach-o/loader.h" +#include "mach-o/external.h" #ifdef __cplusplus extern "C" { @@ -591,6 +592,10 @@ typedef struct mach_o_data_struct { /* Mach-O header. */ bfd_mach_o_header header; + + /* File offset of the header. Usually this is 0. */ + file_ptr hdr_offset; + /* Array of load commands (length is given by header.ncmds). */ bfd_mach_o_load_command *first_command; bfd_mach_o_load_command *last_command; @@ -641,8 +646,8 @@ bfd_boolean bfd_mach_o_valid (bfd *); bfd_boolean bfd_mach_o_mkobject_init (bfd *); const bfd_target *bfd_mach_o_object_p (bfd *); const bfd_target *bfd_mach_o_core_p (bfd *); -const bfd_target *bfd_mach_o_archive_p (bfd *); -bfd *bfd_mach_o_openr_next_archived_file (bfd *, bfd *); +const bfd_target *bfd_mach_o_fat_archive_p (bfd *); +bfd *bfd_mach_o_fat_openr_next_archived_file (bfd *, bfd *); bfd_boolean bfd_mach_o_set_arch_mach (bfd *, enum bfd_architecture, unsigned long); int bfd_mach_o_lookup_command (bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **); @@ -672,7 +677,7 @@ char *bfd_mach_o_core_file_failing_command (bfd *); int bfd_mach_o_core_file_failing_signal (bfd *); bfd_boolean bfd_mach_o_core_file_matches_executable_p (bfd *, bfd *); bfd *bfd_mach_o_fat_extract (bfd *, bfd_format , const bfd_arch_info_type *); -const bfd_target *bfd_mach_o_header_p (bfd *, bfd_mach_o_filetype, +const bfd_target *bfd_mach_o_header_p (bfd *, file_ptr, bfd_mach_o_filetype, bfd_mach_o_cpu_type); bfd_boolean bfd_mach_o_build_commands (bfd *); bfd_boolean bfd_mach_o_set_section_contents (bfd *, asection *, const void *, -- cgit v1.1