aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Longo <matthieu.longo@arm.com>2024-11-06 17:59:46 +0000
committerMatthieu Longo <matthieu.longo@arm.com>2024-12-02 15:18:40 +0000
commitddbd1a4c98794de8a66d86dcfd8139e7a25088d2 (patch)
treeb1f0d007d641b9f7dcee37ad91e2e97f9df5429f
parent2ad1fffee5f0eb055d7919dd1098107fa131501d (diff)
downloadbinutils-ddbd1a4c98794de8a66d86dcfd8139e7a25088d2.zip
binutils-ddbd1a4c98794de8a66d86dcfd8139e7a25088d2.tar.gz
binutils-ddbd1a4c98794de8a66d86dcfd8139e7a25088d2.tar.bz2
aarch64: bugfix when finding 1st bfd input with GNU property
The current implementation of searching the first input BFD with GNU properties has a bug. The search was not filtering on object inputs belonging to the output link unit only, but was also including dynamic objects, BFD plugins, and linker-created files. This means that the initial initialization of the output properties were skewed, and warnings on input files that should have been emitted were not. This patch fixes the filtering to exclude the object input files not belonging to the output link unit, not having the same ELF class, and not the same target architecture.
-rw-r--r--bfd/elfxx-aarch64.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index 896497a..c01e0ab 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -707,11 +707,16 @@ _bfd_aarch64_elf_find_1st_bfd_input_with_gnu_property (
bool *has_gnu_property)
{
BFD_ASSERT (has_gnu_property);
+ const struct elf_backend_data *obfd = get_elf_backend_data (info->output_bfd);
bfd *pbfd = info->input_bfds;
bfd *prev = NULL;
for (; pbfd != NULL; pbfd = pbfd->link.next)
if (bfd_get_flavour (pbfd) == bfd_target_elf_flavour
- && bfd_count_sections (pbfd) != 0)
+ && bfd_count_sections (pbfd) != 0
+ && (pbfd->flags & (DYNAMIC | BFD_PLUGIN | BFD_LINKER_CREATED)) == 0
+ && (obfd->elf_machine_code
+ == get_elf_backend_data (pbfd)->elf_machine_code)
+ && (obfd->s->elfclass == get_elf_backend_data (pbfd)->s->elfclass))
{
/* Does the input have a list of GNU properties ? */
if (elf_properties (pbfd) != NULL)