Skip to contentSkip to conversation

x86, relocs: avoid calling qsort() with NULL pointer

PATCH New Markus Trippelsdorf 1 participant 1 message Nov 13, 2013 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, relocs: avoid calling qsort() with NULL pointer

Current gcc trunk inserts a trap into arch/x86/tools/relocs:

% arch/x86/tools/relocs --realmode arch/x86/realmode/rm/realmode.elf
[1] 31456 illegal hardware instruction arch/x86/tools/relocs --realmode arch/x86/realmode/rm/realmode.elf

This happens because in the case of ELF_BITS==32 qsort is called with a NULL pointer.

arch/x86/tools/relocs.c +2 -1
index f7bab68a4b83..592abb938de7 100644
@@ -976,7 +976,8 @@ static void emit_relocs(int as_text, int use_real_mode)
 	/* Order the relocations for more efficient processing */
 	sort_relocs(&relocs16);
 	sort_relocs(&relocs32);
-	sort_relocs(&relocs64);
+	if (ELF_BITS == 64)
+		sort_relocs(&relocs64);
 
 	/* Print the relocations */
 	if (as_text) {
Signature · 1 line
Markus