aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2024-11-18 11:36:30 +0100
committerJan Beulich <jbeulich@suse.com>2024-11-18 11:36:30 +0100
commit70ab7e0acfaf1cb32dfc184794e28408620a34f9 (patch)
tree49ff81d48d26a6c400e3e87971a629cebfd890e6
parentd5cbf916be4a049580dfed8682f3f8795e57ecfa (diff)
downloadbinutils-70ab7e0acfaf1cb32dfc184794e28408620a34f9.zip
binutils-70ab7e0acfaf1cb32dfc184794e28408620a34f9.tar.gz
binutils-70ab7e0acfaf1cb32dfc184794e28408620a34f9.tar.bz2
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.
-rw-r--r--bfd/merge.c1
-rw-r--r--gas/config/obj-elf.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/bfd/merge.c b/bfd/merge.c
index a4b928d..947f2ce 100644
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -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;
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 4f09b8d..deb902e 100644
--- 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;