+2021-02-17 Nelson Chu <nelson.chu@sifive.com>
+
+ PR 27200
+ * elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Delay
+ copying the elf flags from input BFD to output BFD, until we have
+ checked if the input BFD has no code section or not. Also fix the
+ problem that we only check the first section rather than the entire
+ sections for input BFD.
+
2021-02-16 Alan Modra <amodra@gmail.com>
* libbfd.c (_bfd_read_unsigned_leb128): Avoid excessive shift.
if (!riscv_merge_attributes (ibfd, info))
return FALSE;
- new_flags = elf_elfheader (ibfd)->e_flags;
- old_flags = elf_elfheader (obfd)->e_flags;
-
- if (! elf_flags_init (obfd))
- {
- elf_flags_init (obfd) = TRUE;
- elf_elfheader (obfd)->e_flags = new_flags;
- return TRUE;
- }
-
/* Check to see if the input BFD actually contains any sections. If not,
its flags may not have been initialized either, but it cannot actually
cause any incompatibility. Do not short-circuit dynamic objects; their
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
{
+ null_input_bfd = FALSE;
+
if ((bfd_section_flags (sec)
& (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
== (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
- only_data_sections = FALSE;
-
- null_input_bfd = FALSE;
- break;
+ {
+ only_data_sections = FALSE;
+ break;
+ }
}
if (null_input_bfd || only_data_sections)
return TRUE;
}
+ new_flags = elf_elfheader (ibfd)->e_flags;
+ old_flags = elf_elfheader (obfd)->e_flags;
+
+ if (!elf_flags_init (obfd))
+ {
+ elf_flags_init (obfd) = TRUE;
+ elf_elfheader (obfd)->e_flags = new_flags;
+ return TRUE;
+ }
+
/* Disallow linking different float ABIs. */
if ((old_flags ^ new_flags) & EF_RISCV_FLOAT_ABI)
{