[PATCH 2/4] ELF: SHF_MERGE vs SHT_NOBITS
Jan Beulich
jbeulich@suse.com
Mon Nov 11 08:43:41 GMT 2024
More information about the Binutils mailing list
Mon Nov 11 08:43:41 GMT 2024
- Previous message (by thread): [PATCH 1/4] gas/ELF: also reject merge entity size being zero
- Next message (by thread): [PATCH 3/4] ELF: SHF_STRINGS isn't really tied to SHF_MERGE
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
---
I further wonder whether SHF_MERGE for writable sections can do much
good.
Similarly I wonder whether SHF_MERGE together with e.g. SHF_GROUP or
SHF_LINK_ORDER shouldn't be at least warned about.
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -624,6 +624,7 @@ _bfd_add_merge_section (bfd *abfd, void
if (sec->size == 0
|| (sec->flags & SEC_EXCLUDE) != 0
+ || (sec->flags & SEC_HAS_CONTENTS) == 0
|| sec->entsize == 0)
return true;
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -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;
- Previous message (by thread): [PATCH 1/4] gas/ELF: also reject merge entity size being zero
- Next message (by thread): [PATCH 3/4] ELF: SHF_STRINGS isn't really tied to SHF_MERGE
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list