ELF: SHF_MERGE vs SHT_NOBITS

bfd/merge.c puts in quite some effort to track mergable sections. That's
all wasted for sections which don't have contents, as for them
_bfd_write_merged_section() will never be called.

With the combination not having any useful effect, also warn about this
in gas.
This commit is contained in:
Jan Beulich 2024-11-18 11:36:30 +01:00
parent d5cbf916be
commit 70ab7e0acf
2 changed files with 4 additions and 0 deletions

View File

@ -627,6 +627,7 @@ _bfd_add_merge_section (bfd *abfd, void **psinfo, asection *sec,
if (sec->size == 0
|| (sec->flags & SEC_EXCLUDE) != 0
|| (sec->flags & SEC_HAS_CONTENTS) == 0
|| sec->entsize == 0)
return true;

View File

@ -1346,6 +1346,9 @@ obj_elf_section (int push)
attr &= ~SHF_MERGE;
}
if ((attr & SHF_MERGE) != 0 && type == SHT_NOBITS)
as_warn (_("bogus SHF_MERGE for SHT_NOBITS section"));
if ((attr & SHF_LINK_ORDER) != 0 && *input_line_pointer == ',')
{
++input_line_pointer;