[binutils-gdb] readelf: Check missing DT_REL and DT_RELA dynamic tags

"H.J. Lu via Binutils-cvs" <[email protected]> Wed, 1 Jul 2026 22:21:58 +0000 (GMT)
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1913e1cb7bf5dce76ffcc2ee4b00d693178bf816

commit 1913e1cb7bf5dce76ffcc2ee4b00d693178bf816
Author: H.J. Lu <[email protected]>
Date:   Wed Jul 1 07:31:42 2026 +0800

    readelf: Check missing DT_REL and DT_RELA dynamic tags
    
            PR binutils/34324
            * readelf.c (process_relocs): Return error on missing DT_REL and
            DT_RELA dynamic tags.
    
    Signed-off-by: H.J. Lu <[email protected]>

Diff:
---
 binutils/readelf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/binutils/readelf.c b/binutils/readelf.c
index bf94f4d5caa..33b95da8b7e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -10080,8 +10080,9 @@ process_relocs (Filedata * filedata)
 
 	  switch (rel_type)
 	    {
-	    default:
-	      abort ();
+	    case reltype_unknown:
+	      error (_("missing DT_REL and DT_RELA dynamic tags\n"));
+	      return false;
 	    case reltype_rel:
 	      rel_entsz = filedata->dynamic_info[DT_RELENT];
 	      entsz_name = "DT_RELENT";