public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] readelf: Warn zero-sized relocation sections
@ 2020-04-14 12:25 H.J. Lu
  2020-04-14 12:42 ` Jan Beulich
  0 siblings, 1 reply; 29+ messages in thread
From: H.J. Lu @ 2020-04-14 12:25 UTC (permalink / raw)
  To: binutils

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


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2020-04-29 15:04 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 12:25 [PATCH] readelf: Warn zero-sized relocation sections H.J. Lu
2020-04-14 12:42 ` Jan Beulich
2020-04-14 13:03   ` H.J. Lu
2020-04-14 13:25     ` Jan Beulich
2020-04-14 13:30       ` H.J. Lu
2020-04-14 13:38         ` Jan Beulich
2020-04-14 13:54           ` H.J. Lu
2020-04-17 15:46             ` Nick Clifton
2020-04-17 17:57               ` H.J. Lu
2020-04-18  0:26                 ` Alan Modra
2020-04-18 16:51                   ` [PATCH] elf: Strip zero-sized dynamic sections H.J. Lu
2020-04-20  9:35                     ` Alan Modra
2020-04-20 13:25                       ` V2 " H.J. Lu
2020-04-21 10:20                         ` Nick Clifton
2020-04-20  5:33               ` [PATCH] readelf: Warn zero-sized relocation sections Jan Beulich
2020-04-20 10:28                 ` Nick Clifton
2020-04-20 12:19                   ` Jan Beulich
2020-04-20 17:25                     ` Hans-Peter Nilsson
2020-04-21 10:01                       ` Nick Clifton
2020-04-21 10:31                         ` Jan Beulich
2020-04-22  2:51                           ` Hans-Peter Nilsson
2020-04-24 14:04                             ` Nick Clifton
2020-04-24 16:20                               ` Hans-Peter Nilsson
2020-04-29 15:04                                 ` Nick Clifton
2020-04-24 17:19                               ` Fangrui Song
2020-04-26 15:26                                 ` Nick Clifton
2020-04-26 15:59                                   ` H.J. Lu
2020-04-24 17:50                               ` Jan Beulich
2020-04-27 11:24                                 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).