readelf: Check missing DT_REL and DT_RELA dynamic tags

Message ID CAMe9rOqTYSQuSHropEaSKymWSMoCe0wcTAJYMqP4QqfnVH15Jg@mail.gmail.com
State New
Headers
Series readelf: Check missing DT_REL and DT_RELA dynamic tags |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 fail Patch failed to apply

Commit Message

H.J. Lu July 1, 2026, 6:21 a.m. UTC
  PR binutils/34324
* readelf.c (process_relocs): Return error on missing DT_REL and
DT_RELA dynamic tags.
  

Comments

H.J. Lu July 1, 2026, 10:21 p.m. UTC | #1
On Wed, Jul 1, 2026 at 2:21 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> PR binutils/34324
> * readelf.c (process_relocs): Return error on missing DT_REL and
> DT_RELA dynamic tags.
>

I am checking it in as an obvious fix.
  

Patch

From 579b3e22794e1d40e00a740855dcd7e94a6ddbe5 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 1 Jul 2026 07:31:42 +0800
Subject: [PATCH] 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 <hjl.tools@gmail.com>
---
 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";
-- 
2.54.0