David Abdurachmanov
ccbd31cb6c
This caused compilation errors for glib package. Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
60 lines
2.0 KiB
Diff
60 lines
2.0 KiB
Diff
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
|
|
index 69cadaa2..ac6f136a 100644
|
|
--- a/bfd/elfnn-riscv.c
|
|
+++ b/bfd/elfnn-riscv.c
|
|
@@ -3084,8 +3084,7 @@ static bfd_boolean
|
|
_bfd_riscv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
|
|
{
|
|
bfd *obfd = info->output_bfd;
|
|
- flagword new_flags = elf_elfheader (ibfd)->e_flags;
|
|
- flagword old_flags = elf_elfheader (obfd)->e_flags;
|
|
+ flagword new_flags, old_flags;
|
|
|
|
if (!is_riscv_elf (ibfd) || !is_riscv_elf (obfd))
|
|
return TRUE;
|
|
@@ -3105,6 +3104,9 @@ _bfd_riscv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
|
|
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;
|
|
@@ -3112,6 +3114,34 @@ _bfd_riscv_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
|
|
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
|
|
+ section list may be emptied by elf_link_add_object_symbols.
|
|
+
|
|
+ Also check to see if there are no code sections in the input. In this
|
|
+ case, there is no need to check for code specific flags. */
|
|
+ if (!(ibfd->flags & DYNAMIC))
|
|
+ {
|
|
+ bfd_boolean null_input_bfd = TRUE;
|
|
+ bfd_boolean only_data_sections = TRUE;
|
|
+ asection *sec;
|
|
+
|
|
+ for (sec = ibfd->sections; sec != NULL; sec = sec->next)
|
|
+ {
|
|
+ if ((bfd_get_section_flags (ibfd, sec)
|
|
+ & (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
|
|
+ == (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
|
|
+ only_data_sections = FALSE;
|
|
+
|
|
+ null_input_bfd = FALSE;
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ if (null_input_bfd || only_data_sections)
|
|
+ return TRUE;
|
|
+ }
|
|
+
|
|
/* Disallow linking different float ABIs. */
|
|
if ((old_flags ^ new_flags) & EF_RISCV_FLOAT_ABI)
|
|
{
|