diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2013-11-04 09:17:45 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-10-16 13:57:07 -0700 |
commit | 5005041f0833c81bfa6d92909ecee2fd8cdf83a2 (patch) | |
tree | 88a99ee02f7720a3ab921c85cf18b3d01ae5c8aa /bfd/format.c | |
parent | 774ee6d252eba19d3e23c936d14bfc1f7fa70651 (diff) | |
download | binutils-gdb-5005041f0833c81bfa6d92909ecee2fd8cdf83a2.tar.gz |
Add lto and none-lto input support for ld -r
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; } |