From: H. Peter Anvin Date: Mon, 7 Jun 2010 18:26:11 +0000 (-0700) Subject: outelf32: handle compilers without 64-bit switch() support X-Git-Tag: nasm-2.11.05~614 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4dff757ba5f22b3ac633d7c792f720d12f4f19f8;p=platform%2Fupstream%2Fnasm.git 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 --- 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) { /*