[PATCH] readelf: Warn zero-sized relocation sections
H.J. Lu
hjl.tools@gmail.com
Tue Apr 14 12:25:52 GMT 2020
Older linkers may fail with zero-sized relocation section in section
group.
PR ld/25767
* readelf.c (process_section_headers): Warn zero-sized
relocation sections.
---
binutils/readelf.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index cd456b0290..535d47a58e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -6315,9 +6315,19 @@ process_section_headers (Filedata * filedata)
else if (section->sh_type == SHT_GROUP)
CHECK_ENTSIZE_VALUES (section, i, GRP_ENTRY_SIZE, GRP_ENTRY_SIZE);
else if (section->sh_type == SHT_REL)
- CHECK_ENTSIZE (section, i, Rel);
+ {
+ CHECK_ENTSIZE (section, i, Rel);
+ if (section->sh_size == 0)
+ warn (_("Section '%s': zero-sized relocation section\n"),
+ name);
+ }
else if (section->sh_type == SHT_RELA)
- CHECK_ENTSIZE (section, i, Rela);
+ {
+ CHECK_ENTSIZE (section, i, Rela);
+ if (section->sh_size == 0)
+ warn (_("Section '%s': zero-sized relocation section\n"),
+ name);
+ }
else if ((do_debugging || do_debug_info || do_debug_abbrevs
|| do_debug_lines || do_debug_pubnames || do_debug_pubtypes
|| do_debug_aranges || do_debug_frames || do_debug_macinfo
--
2.25.2
More information about the Binutils
mailing list