mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-02-17 17:19:35 +08:00
Fix building under OpenWatcom
OpenWatcom doesn't like 64-bit switch arguments; the change to 64-bit type arguments caused that to happen in outmacho.c. Hack around it for now; however, realistically speaking the whole bit stealing thing is probably a bad idea, especially since virtually all CPUs handle short immediates better than long ones.
This commit is contained in:
parent
88602aa53a
commit
44d7dcf87b
17
nasm.h
17
nasm.h
@ -840,14 +840,15 @@ struct ofmt {
|
|||||||
* OUT_RAWDATA, in which case it points to an "uint8_t"
|
* OUT_RAWDATA, in which case it points to an "uint8_t"
|
||||||
* array.
|
* array.
|
||||||
*/
|
*/
|
||||||
#define OUT_RAWDATA (uint64_t)0x0000000000000000
|
#define OUT_RAWDATA UINT64_C(0x0000000000000000)
|
||||||
#define OUT_ADDRESS (uint64_t)0x1000000000000000
|
#define OUT_ADDRESS UINT64_C(0x1000000000000000)
|
||||||
#define OUT_REL2ADR (uint64_t)0x2000000000000000
|
#define OUT_REL2ADR UINT64_C(0x2000000000000000)
|
||||||
#define OUT_REL4ADR (uint64_t)0x3000000000000000
|
#define OUT_REL4ADR UINT64_C(0x3000000000000000)
|
||||||
#define OUT_RESERVE (uint64_t)0x4000000000000000
|
#define OUT_RESERVE UINT64_C(0x4000000000000000)
|
||||||
#define OUT_REL8ADR (uint64_t)0x5000000000000000
|
#define OUT_REL8ADR UINT64_C(0x5000000000000000)
|
||||||
#define OUT_TYPMASK (uint64_t)0xF000000000000000
|
#define OUT_TYPMASK UINT64_C(0xF000000000000000)
|
||||||
#define OUT_SIZMASK (uint64_t)0x0FFFFFFFFFFFFFFF
|
#define OUT_SIZMASK UINT64_C(0x0FFFFFFFFFFFFFFF)
|
||||||
|
#define OUT_TYPE(x) ((int)((x) >> 60))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------------
|
* ------------------------------------------------------------
|
||||||
|
@ -386,15 +386,14 @@ static void add_reloc(struct section *sect, int32_t section,
|
|||||||
++sect->nreloc;
|
++sect->nreloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void macho_output(int32_t secto, const void *data, uint64_t type,
|
static void macho_output(int32_t secto, const void *data, uint64_t xtype,
|
||||||
int32_t section, int32_t wrt)
|
int32_t section, int32_t wrt)
|
||||||
{
|
{
|
||||||
struct section *s, *sbss;
|
struct section *s, *sbss;
|
||||||
int32_t realbytes = type & OUT_SIZMASK;
|
int64_t realbytes = xtype & OUT_SIZMASK;
|
||||||
int32_t addr;
|
int32_t addr;
|
||||||
uint8_t mydata[4], *p;
|
uint8_t mydata[4], *p;
|
||||||
|
int type = OUT_TYPE(xtype);
|
||||||
type &= OUT_TYPMASK;
|
|
||||||
|
|
||||||
if (wrt != NO_SEG) {
|
if (wrt != NO_SEG) {
|
||||||
wrt = NO_SEG;
|
wrt = NO_SEG;
|
||||||
@ -403,7 +402,7 @@ static void macho_output(int32_t secto, const void *data, uint64_t type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (secto == NO_SEG) {
|
if (secto == NO_SEG) {
|
||||||
if (type != OUT_RESERVE)
|
if (type != OUT_TYPE(OUT_RESERVE))
|
||||||
error(ERR_NONFATAL, "attempt to assemble code in "
|
error(ERR_NONFATAL, "attempt to assemble code in "
|
||||||
"[ABSOLUTE] space");
|
"[ABSOLUTE] space");
|
||||||
|
|
||||||
@ -424,16 +423,16 @@ static void macho_output(int32_t secto, const void *data, uint64_t type,
|
|||||||
|
|
||||||
sbss = get_section_by_name("__DATA", "__bss");
|
sbss = get_section_by_name("__DATA", "__bss");
|
||||||
|
|
||||||
if (s == sbss && type != OUT_RESERVE) {
|
if (s == sbss && type != OUT_TYPE(OUT_RESERVE)) {
|
||||||
error(ERR_WARNING, "attempt to initialize memory in the"
|
error(ERR_WARNING, "attempt to initialize memory in the"
|
||||||
" BSS section: ignored");
|
" BSS section: ignored");
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OUT_REL2ADR:
|
case OUT_TYPE(OUT_REL2ADR):
|
||||||
realbytes = 2;
|
realbytes = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUT_REL4ADR:
|
case OUT_TYPE(OUT_REL4ADR):
|
||||||
realbytes = 4;
|
realbytes = 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -446,7 +445,7 @@ static void macho_output(int32_t secto, const void *data, uint64_t type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OUT_RESERVE:
|
case OUT_TYPE(OUT_RESERVE):
|
||||||
if (s != sbss) {
|
if (s != sbss) {
|
||||||
error(ERR_WARNING, "uninitialized space declared in"
|
error(ERR_WARNING, "uninitialized space declared in"
|
||||||
" %s section: zeroing",
|
" %s section: zeroing",
|
||||||
@ -458,14 +457,14 @@ static void macho_output(int32_t secto, const void *data, uint64_t type,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUT_RAWDATA:
|
case OUT_TYPE(OUT_RAWDATA):
|
||||||
if (section != NO_SEG)
|
if (section != NO_SEG)
|
||||||
error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
|
error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
|
||||||
|
|
||||||
sect_write(s, data, realbytes);
|
sect_write(s, data, realbytes);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUT_ADDRESS:
|
case OUT_TYPE(OUT_ADDRESS):
|
||||||
addr = *(int32_t *)data;
|
addr = *(int32_t *)data;
|
||||||
|
|
||||||
if (section != NO_SEG) {
|
if (section != NO_SEG) {
|
||||||
@ -486,7 +485,7 @@ static void macho_output(int32_t secto, const void *data, uint64_t type,
|
|||||||
sect_write(s, mydata, realbytes);
|
sect_write(s, mydata, realbytes);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUT_REL2ADR:
|
case OUT_TYPE(OUT_REL2ADR):
|
||||||
if (section == secto)
|
if (section == secto)
|
||||||
error(ERR_PANIC, "intra-section OUT_REL2ADR");
|
error(ERR_PANIC, "intra-section OUT_REL2ADR");
|
||||||
|
|
||||||
@ -501,7 +500,7 @@ static void macho_output(int32_t secto, const void *data, uint64_t type,
|
|||||||
sect_write(s, mydata, 2L);
|
sect_write(s, mydata, 2L);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUT_REL4ADR:
|
case OUT_TYPE(OUT_REL4ADR):
|
||||||
if (section == secto)
|
if (section == secto)
|
||||||
error(ERR_PANIC, "intra-section OUT_REL4ADR");
|
error(ERR_PANIC, "intra-section OUT_REL4ADR");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user