X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Fmach-o.c;h=917335d86e8c8cfe7219412c07ec27fc6ab8fd07;hb=d5dcaf1b59e77047e10a1f246095d6b21f7d9772;hp=d58e62d94e81d6d043d073d951581d8973299fb6;hpb=c6643fcc058d6b4aebca75818fbbb705837a9fa3;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/mach-o.c b/bfd/mach-o.c index d58e62d94e..917335d86e 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -1,5 +1,5 @@ /* Mach-O support for BFD. - Copyright (C) 1999-2018 Free Software Foundation, Inc. + Copyright (C) 1999-2019 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -19,10 +19,10 @@ MA 02110-1301, USA. */ #include "sysdep.h" -#include "mach-o.h" #include "bfd.h" #include "libbfd.h" #include "libiberty.h" +#include "mach-o.h" #include "aout/stab_gnu.h" #include "mach-o/reloc.h" #include "mach-o/external.h" @@ -2497,11 +2497,14 @@ bfd_mach_o_mangle_symbols (bfd *abfd) } else s->n_type = BFD_MACH_O_N_SECT; - - if (s->symbol.flags & BSF_GLOBAL) - s->n_type |= BFD_MACH_O_N_EXT; } + /* Update external symbol bit in case objcopy changed it. */ + if (s->symbol.flags & BSF_GLOBAL) + s->n_type |= BFD_MACH_O_N_EXT; + else + s->n_type &= ~BFD_MACH_O_N_EXT; + /* Put the section index in, where required. */ if ((s->symbol.section != bfd_abs_section_ptr && s->symbol.section != bfd_und_section_ptr @@ -4595,16 +4598,12 @@ 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_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); + cmd->version = bfd_get_32 (abfd, raw.version); + cmd->sdk = bfd_get_32 (abfd, raw.sdk); return TRUE; } @@ -4678,6 +4677,37 @@ bfd_mach_o_read_source_version (bfd *abfd, bfd_mach_o_load_command *command) return TRUE; } +static bfd_boolean +bfd_mach_o_read_note (bfd *abfd, bfd_mach_o_load_command *command) +{ + bfd_mach_o_note_command *cmd = &command->command.note; + struct mach_o_note_command_external raw; + + if (bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw)) + return FALSE; + + memcpy (cmd->data_owner, raw.data_owner, 16); + cmd->offset = bfd_get_64 (abfd, raw.offset); + cmd->size = bfd_get_64 (abfd, raw.size); + return TRUE; +} + +static bfd_boolean +bfd_mach_o_read_build_version (bfd *abfd, bfd_mach_o_load_command *command) +{ + bfd_mach_o_build_version_command *cmd = &command->command.build_version; + struct mach_o_build_version_command_external raw; + + if (bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw)) + return FALSE; + + cmd->platform = bfd_get_32 (abfd, raw.platform); + cmd->minos = bfd_get_32 (abfd, raw.minos); + cmd->sdk = bfd_get_32 (abfd, raw.sdk); + cmd->ntools = bfd_get_32 (abfd, raw.ntools); + return TRUE; +} + static bfd_boolean bfd_mach_o_read_segment (bfd *abfd, bfd_mach_o_load_command *command, @@ -4874,6 +4904,7 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command) case BFD_MACH_O_LC_VERSION_MIN_MACOSX: case BFD_MACH_O_LC_VERSION_MIN_IPHONEOS: case BFD_MACH_O_LC_VERSION_MIN_WATCHOS: + case BFD_MACH_O_LC_VERSION_MIN_TVOS: if (!bfd_mach_o_read_version_min (abfd, command)) return FALSE; break; @@ -4885,6 +4916,16 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command) if (!bfd_mach_o_read_source_version (abfd, command)) return FALSE; break; + case BFD_MACH_O_LC_LINKER_OPTIONS: + break; + case BFD_MACH_O_LC_NOTE: + if (!bfd_mach_o_read_note (abfd, command)) + return FALSE; + break; + case BFD_MACH_O_LC_BUILD_VERSION: + if (!bfd_mach_o_read_build_version (abfd, command)) + return FALSE; + break; default: command->len = 0; _bfd_error_handler (_("%pB: unknown load command %#x"), @@ -5532,6 +5573,13 @@ bfd_mach_o_fat_extract (bfd *abfd, return NULL; } +static bfd_boolean +bfd_mach_o_fat_close_and_cleanup (bfd *abfd) +{ + _bfd_unlink_from_archive_parent (abfd); + return TRUE; +} + int bfd_mach_o_lookup_command (bfd *abfd, bfd_mach_o_load_command_type type, @@ -6026,7 +6074,7 @@ bfd_mach_o_free_cached_info (bfd *abfd) /* Not yet handled: creating an archive. */ #define bfd_mach_o_mkarchive _bfd_noarchive_mkarchive -#define bfd_mach_o_close_and_cleanup _bfd_bool_bfd_true +#define bfd_mach_o_close_and_cleanup bfd_mach_o_fat_close_and_cleanup /* Not used. */ #define bfd_mach_o_generic_stat_arch_elt bfd_mach_o_fat_stat_arch_elt