PR 33743 readelf abort during RELR relocation handling

Alan Modra amodra@gmail.com
Fri Feb 27 10:20:16 GMT 2026


Rather than aborting, use "unknown relative" as the reloc type should
display_elf_relocation_at want to print a relocation.  Also fix
another case where readelf doesn't understand the relocation and sets
all_relocations[i].r_name to NULL.

	PR 33743
	* readelf.c (dump_relr_relocations): Don't abort on unknown
	e_machine.
	(dump_relocations): Don't assume we can pass NULL to a %s
	format.

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 0c3e24e8bf7..3b6d606b36c 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -1976,7 +1976,8 @@ dump_relr_relocations (Filedata *          filedata,
     switch (filedata->file_header.e_machine)
       {
       default:
-	abort ();
+	rtype = "unknown relative";
+	break;
 
       case EM_386:
       case EM_IAMCU:
@@ -2888,7 +2889,7 @@ dump_relocations (Filedata *          filedata,
       if (do_got_section_contents)
 	{
 	  all_relocations[i].r_offset = offset;
-	  all_relocations[i].r_name = rtype;
+	  all_relocations[i].r_name = rtype ? rtype : "unknown";
 	  all_relocations[i].r_symbol = symbol_name;
 	  all_relocations[i].r_addend = rels[i].r_addend;
 	  all_relocations[i].r_type = rel_type;

-- 
Alan Modra


More information about the Binutils mailing list