diff options
Diffstat (limited to 'bfd/archive.c')
-rw-r--r-- | bfd/archive.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/bfd/archive.c b/bfd/archive.c index 52d3119..d2a9fd1 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -141,9 +141,7 @@ SUBSECTION #include "hashtab.h" #include "filenames.h" #include "bfdlink.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin.h" -#endif #ifndef errno extern int errno; @@ -950,8 +948,8 @@ bfd_generic_archive_p (bfd *abfd) if (first != NULL) { first->target_defaulted = false; - if (bfd_check_format (first, bfd_object) - && first->xvec != abfd->xvec) + if (!bfd_check_format (first, bfd_object) + || first->xvec != abfd->xvec) bfd_set_error (bfd_error_wrong_object_format); bfd_close (first); } @@ -1189,7 +1187,7 @@ do_slurp_coff_armap (bfd *abfd) bool bfd_slurp_armap (bfd *abfd) { - char nextname[17]; + char nextname[16]; int i = bfd_read (nextname, 16, abfd); if (i == 0) @@ -1200,12 +1198,13 @@ bfd_slurp_armap (bfd *abfd) if (bfd_seek (abfd, -16, SEEK_CUR) != 0) return false; - if (startswith (nextname, "__.SYMDEF ") - || startswith (nextname, "__.SYMDEF/ ")) /* Old Linux archives. */ + if (memcmp (nextname, "__.SYMDEF ", 16) == 0 + /* Old Linux archives. */ + || memcmp (nextname, "__.SYMDEF/ ", 16) == 0) return do_slurp_bsd_armap (abfd); - else if (startswith (nextname, "/ ")) + else if (memcmp (nextname, "/ ", 16) == 0) return do_slurp_coff_armap (abfd); - else if (startswith (nextname, "/SYM64/ ")) + else if (memcmp (nextname, "/SYM64/ ", 16) == 0) { /* 64bit (Irix 6) archive. */ #ifdef BFD64 @@ -1215,13 +1214,27 @@ bfd_slurp_armap (bfd *abfd) return false; #endif } - else if (startswith (nextname, "#1/20 ")) + else if (memcmp (nextname, "________", 8) == 0 + && ((nextname[8] == '_' && nextname[9] == '_') + || (nextname[8] == '6' && nextname[9] == '4')) + && nextname[10] == 'E' + && (nextname[11] == 'B' || nextname[11] == 'L') + && nextname[12] == 'E' + && (nextname[13] == 'B' || nextname[13] == 'L') + && nextname[14] == '_' + && (nextname[15] == ' ' || nextname[15] == 'X')) + { + /* ECOFF archive. */ + bfd_set_error (bfd_error_wrong_format); + return false; + } + else if (memcmp (nextname, "#1/20 ", 16) == 0) { /* Mach-O has a special name for armap when the map is sorted by name. However because this name has a space it is slightly more difficult to check it. */ struct ar_hdr hdr; - char extname[21]; + char extname[20]; if (bfd_read (&hdr, sizeof (hdr), abfd) != sizeof (hdr)) return false; @@ -1230,9 +1243,8 @@ bfd_slurp_armap (bfd *abfd) return false; if (bfd_seek (abfd, -(file_ptr) (sizeof (hdr) + 20), SEEK_CUR) != 0) return false; - extname[20] = 0; - if (startswith (extname, "__.SYMDEF SORTED") - || startswith (extname, "__.SYMDEF")) + if (memcmp (extname, "__.SYMDEF SORTED", 16) == 0 + || memcmp (extname, "__.SYMDEF", 9) == 0) return do_slurp_bsd_armap (abfd); } @@ -2346,9 +2358,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength) long src_count; if (bfd_get_lto_type (current) == lto_slim_ir_object -#if BFD_SUPPORTS_PLUGINS && !bfd_plugin_target_p (current->xvec) -#endif && report_plugin_err) { report_plugin_err = false; @@ -2406,9 +2416,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength) if (bfd_lto_slim_symbol_p (current, syms[src_count]->name) -#if BFD_SUPPORTS_PLUGINS && !bfd_plugin_target_p (current->xvec) -#endif && report_plugin_err) { report_plugin_err = false; |