]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR 33743 readelf abort during RELR relocation handling
authorAlan Modra <amodra@gmail.com>
Fri, 27 Feb 2026 07:44:36 +0000 (18:14 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 27 Feb 2026 10:19:12 +0000 (20:49 +1030)
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.

binutils/readelf.c

index 0c3e24e8bf75293e7d7242c33047b3e71dbc7359..3b6d606b36c2270a041b73f61d47b28dd40eb972 100644 (file)
@@ -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;