aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-06-07 11:26:11 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-06-07 11:26:11 -0700
commit4dff757ba5f22b3ac633d7c792f720d12f4f19f8 (patch)
treee064e60d099e5a4229473654d8a93c3ca470d9a7
parentb1a1e69a8f3cff77479d1dbdb67a20b69f6a704f (diff)
downloadnasm-test-4dff757ba5f22b3ac633d7c792f720d12f4f19f8.tar.gz
nasm-test-4dff757ba5f22b3ac633d7c792f720d12f4f19f8.tar.xz
nasm-test-4dff757ba5f22b3ac633d7c792f720d12f4f19f8.zip
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 <hpa@linux.intel.com>
-rw-r--r--output/outelf32.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/output/outelf32.c b/output/outelf32.c
index 8a14af45..14df371f 100644
--- a/output/outelf32.c
+++ b/output/outelf32.c
@@ -43,6 +43,7 @@
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
+#include <limits.h>
#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) {
/*