diff options
Diffstat (limited to 'bfd/archive.c')
-rw-r--r-- | bfd/archive.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/bfd/archive.c b/bfd/archive.c index 8e20554..d2a9fd1 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -141,6 +141,7 @@ SUBSECTION #include "hashtab.h" #include "filenames.h" #include "bfdlink.h" +#include "plugin.h" #ifndef errno extern int errno; @@ -947,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); } @@ -1186,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) @@ -1197,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 @@ -1212,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; @@ -1227,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); } @@ -2299,7 +2314,6 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength) { char *first_name = NULL; bfd *current; - file_ptr elt_no = 0; struct orl *map = NULL; unsigned int orl_max = 1024; /* Fine initial default. */ unsigned int orl_count = 0; @@ -2334,7 +2348,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength) /* Map over each element. */ for (current = arch->archive_head; current != NULL; - current = current->archive_next, elt_no++) + current = current->archive_next) { if (bfd_check_format (current, bfd_object) && (bfd_get_file_flags (current) & HAS_SYMS) != 0) @@ -2344,6 +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 + && !bfd_plugin_target_p (current->xvec) && report_plugin_err) { report_plugin_err = false; @@ -2401,6 +2416,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength) if (bfd_lto_slim_symbol_p (current, syms[src_count]->name) + && !bfd_plugin_target_p (current->xvec) && report_plugin_err) { report_plugin_err = false; |