diff options
Diffstat (limited to 'bfd/format.c')
-rw-r--r-- | bfd/format.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/bfd/format.c b/bfd/format.c index dd6dc8a32ce..97cbd2261ac 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -179,6 +179,33 @@ bfd_preserve_finish (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_preserve *preserve) preserve->marker = NULL; } +/* Set lto_type in ABFD. */ + +static void +bfd_set_lto_type (bfd *abfd) +{ + if (abfd->format == bfd_object + && abfd->lto_type == lto_non_object + && (abfd->flags & (DYNAMIC | EXEC_P)) == 0) + { + asection *sec; + enum bfd_lto_object_type type = lto_non_ir_object; + for (sec = abfd->sections; sec != NULL; sec = sec->next) + { + if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0) + { + type = lto_mixed_object; + abfd->object_only_section = sec; + break; + } + else if (type != lto_ir_object + && strncmp (sec->name, ".gnu.lto_", 9) == 0) + type = lto_ir_object; + } + abfd->lto_type = type; + } +} + /* FUNCTION bfd_check_format_matches @@ -221,7 +248,10 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) } if (abfd->format != bfd_unknown) - return abfd->format == format; + { + bfd_set_lto_type (abfd); + return abfd->format == format; + } if (matching != NULL || *bfd_associated_vector != NULL) { @@ -449,6 +479,8 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) if (matching_vector) free (matching_vector); + bfd_set_lto_type (abfd); + /* File position has moved, BTW. */ return TRUE; } |