]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
readelf: Call qsort only if all_relocations_count > 1
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 1 Sep 2025 13:55:00 +0000 (06:55 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 3 Sep 2025 12:38:23 +0000 (05:38 -0700)
Don't call qsort if all_relocations_count < 1.

PR binutils/33351
* readelf.c (process_got_section_contents): Call qsort only if
all_relocations_count > 1.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
binutils/readelf.c

index 2f8dda889134bb6ab273ac4b902afcac10d9cb65..3205cf2e69eec2a8cb4f112b0e56c236a2f71d25 100644 (file)
@@ -21025,8 +21025,9 @@ process_got_section_contents (Filedata * filedata)
       goto out;
     }
 
-  qsort (all_relocations_root, all_relocations_count,
-        sizeof (elf_relocation), elf_relocation_cmp);
+  if (all_relocations_count > 1)
+    qsort (all_relocations_root, all_relocations_count,
+          sizeof (elf_relocation), elf_relocation_cmp);
 
   initialise_dumps_byname (filedata);