From 4dff757ba5f22b3ac633d7c792f720d12f4f19f8 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 7 Jun 2010 11:26:11 -0700 Subject: [PATCH] outelf32: handle compilers without 64-bit switch() support OpenWatcom, in particular, doesn't handle switch() statements with 64-bit expressions, sigh. Signed-off-by: H. Peter Anvin --- output/outelf32.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 8a14af4..14df371 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "nasm.h" #include "nasmlib.h" @@ -788,20 +789,27 @@ static void elf_out(int32_t segto, const void *data, " segment base references"); } else { if (wrt == NO_SEG) { - switch (size) { - case 1: - gnu16 = true; - elf_add_reloc(s, segment, R_386_8); - break; - case 2: - gnu16 = true; - elf_add_reloc(s, segment, R_386_16); - break; - case 4: - elf_add_reloc(s, segment, R_386_32); - break; - default: /* Error issued further down */ - break; + /* + * The if() is a hack to deal with compilers which + * don't handle switch() statements with 64-bit + * expressions. + */ + if (size < UINT_MAX) { + switch ((unsigned int)size) { + case 1: + gnu16 = true; + elf_add_reloc(s, segment, R_386_8); + break; + case 2: + gnu16 = true; + elf_add_reloc(s, segment, R_386_16); + break; + case 4: + elf_add_reloc(s, segment, R_386_32); + break; + default: /* Error issued further down */ + break; + } } } else if (wrt == elf_gotpc_sect + 1) { /* -- 2.7.4