[PATCH] x86, relocs: avoid calling qsort() with NULL pointer
From: Markus Trippelsdorf
Date: Wed Nov 13 2013 - 08:43:59 EST
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.
Signed-off-by: Markus Trippelsdorf <markus@xxxxxxxxxxxxxxx>
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index f7bab68a4b83..592abb938de7 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -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) {
--
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/