summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-02-11 20:40:07 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-02-11 20:40:07 -0800
commit33814133bdc8db9fcbdc1be097f7b4a226d8e143 (patch)
treeb8aead6d25a7c37ec7025f9469a56884d4bdc71b
parentecc9e0ecd732c66918a880b8f225cc26b7cd83ba (diff)
downloadnasm-33814133bdc8db9fcbdc1be097f7b4a226d8e143.tar.gz
Replace global maxbits variable with field in struct ofmt
maxbits is strictly a property of the output format, so get rid of this ad hoc method of reporting. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--assemble.c9
-rw-r--r--nasm.c1
-rw-r--r--nasm.h5
-rw-r--r--output/outaout.c2
-rw-r--r--output/outas86.c1
-rw-r--r--output/outbin.c6
-rw-r--r--output/outcoff.c4
-rw-r--r--output/outdbg.c1
-rw-r--r--output/outelf32.c1
-rw-r--r--output/outelf64.c2
-rw-r--r--output/outelfx32.c2
-rw-r--r--output/outieee.c1
-rw-r--r--output/outmac32.c1
-rw-r--r--output/outmac64.c3
-rw-r--r--output/outobj.c1
-rw-r--r--output/outrdf2.c3
16 files changed, 26 insertions, 17 deletions
diff --git a/assemble.c b/assemble.c
index 1d8c3c10..05359445 100644
--- a/assemble.c
+++ b/assemble.c
@@ -319,8 +319,7 @@ static void out(int64_t offset, int32_t segto, const void *data,
static char *lnfname = NULL;
uint8_t p[8];
const int asize = abs((int)size); /* True address size */
- const int abits = asize << 3; /* Address size in bits */
- const int amax = maxbits >> 3; /* Maximum address size in bytes */
+ const int amax = outfmt->maxbits >> 3; /* Maximum address size in bytes */
if (type == OUT_ADDRESS && segment == NO_SEG && wrt == NO_SEG) {
/*
@@ -353,15 +352,15 @@ static void out(int64_t offset, int32_t segto, const void *data,
if (src_get(&lineno, &lnfname))
outfmt->current_dfmt->linenum(lnfname, lineno, segto);
- if (type == OUT_ADDRESS && abits > maxbits) {
+ if (type == OUT_ADDRESS && asize > amax) {
if (asize < 0) {
errfunc(ERR_NONFATAL,
"%d-bit signed relocation unsupported by output format %s\n",
- abits, outfmt->shortname);
+ asize << 3, outfmt->shortname);
} else {
errfunc(ERR_WARNING | ERR_WARN_ZEXTRELOC,
"%d-bit unsigned relocation zero-extended from %d bits\n",
- abits, maxbits);
+ asize << 4, outfmt->maxbits);
outfmt->output(segto, data, type, amax, segment, wrt);
size -= amax;
}
diff --git a/nasm.c b/nasm.c
index bb62d175..55c7a2a2 100644
--- a/nasm.c
+++ b/nasm.c
@@ -87,7 +87,6 @@ static void usage(void);
static int using_debug_info, opt_verbose_info;
bool tasm_compatible_mode = false;
int pass0, passn;
-int maxbits = 0;
int globalrel = 0;
int globalbnd = 0;
diff --git a/nasm.h b/nasm.h
index bd1f2908..f0cc3466 100644
--- a/nasm.h
+++ b/nasm.h
@@ -738,9 +738,11 @@ struct ofmt {
/*
* Output format flags.
*/
-#define OFMT_TEXT 1 /* Text file format */
+#define OFMT_TEXT 1 /* Text file format */
unsigned int flags;
+ int maxbits; /* Maximum segment bits supported */
+
/*
* this is a pointer to the first element of the debug information
*/
@@ -1181,7 +1183,6 @@ extern int optimizing;
extern int globalbits; /* 16, 32 or 64-bit mode */
extern int globalrel; /* default to relative addressing? */
extern int globalbnd; /* default to using bnd prefix? */
-extern int maxbits; /* max bits supported by output */
/*
* NASM version strings, defined in ver.c
diff --git a/output/outaout.c b/output/outaout.c
index 1b2b2191..360f549d 100644
--- a/output/outaout.c
+++ b/output/outaout.c
@@ -913,6 +913,7 @@ struct ofmt of_aout = {
"Linux a.out object files",
"aout",
0,
+ 32,
null_debug_arr,
&null_debug_form,
aout_stdmac,
@@ -936,6 +937,7 @@ struct ofmt of_aoutb = {
"NetBSD/FreeBSD a.out object files",
"aoutb",
0,
+ 32,
null_debug_arr,
&null_debug_form,
aout_stdmac,
diff --git a/output/outas86.c b/output/outas86.c
index 892362b6..43108c4e 100644
--- a/output/outas86.c
+++ b/output/outas86.c
@@ -633,6 +633,7 @@ struct ofmt of_as86 = {
"Linux as86 (bin86 version 0.3) object files",
"as86",
0,
+ 32,
null_debug_arr,
&null_debug_form,
as86_stdmac,
diff --git a/output/outbin.c b/output/outbin.c
index c64daaaf..71c7bcd4 100644
--- a/output/outbin.c
+++ b/output/outbin.c
@@ -1431,7 +1431,6 @@ static void srec_init(void)
static void binfmt_init(void)
{
- maxbits = 64; /* Support 64-bit Segments */
relocs = NULL;
reloctail = &relocs;
origin_defined = 0;
@@ -1660,6 +1659,7 @@ struct ofmt of_bin = {
"flat-form binary files (e.g. DOS .COM, .SYS)",
"bin",
0,
+ 64,
null_debug_arr,
&null_debug_form,
bin_stdmac,
@@ -1679,6 +1679,7 @@ struct ofmt of_ith = {
"Intel hex",
"ith",
OFMT_TEXT,
+ 64,
null_debug_arr,
&null_debug_form,
bin_stdmac,
@@ -1697,7 +1698,8 @@ struct ofmt of_ith = {
struct ofmt of_srec = {
"Motorola S-records",
"srec",
- 0,
+ OFMT_TEXT,
+ 64,
null_debug_arr,
&null_debug_form,
bin_stdmac,
diff --git a/output/outcoff.c b/output/outcoff.c
index 73ba13e3..a712f953 100644
--- a/output/outcoff.c
+++ b/output/outcoff.c
@@ -196,7 +196,6 @@ static void coff_win32_init(void)
static void coff_win64_init(void)
{
- maxbits = 64;
win32 = false;
win64 = true;
coff_gen_init();
@@ -1173,6 +1172,7 @@ struct ofmt of_coff = {
"COFF (i386) object files (e.g. DJGPP for DOS)",
"coff",
0,
+ 32,
null_debug_arr,
&null_debug_form,
coff_stdmac,
@@ -1200,6 +1200,7 @@ struct ofmt of_win32 = {
"Microsoft Win32 (i386) object files",
"win32",
0,
+ 32,
win32_debug_arr,
&df_cv8,
coff_stdmac,
@@ -1225,6 +1226,7 @@ struct ofmt of_win64 = {
"Microsoft Win64 (x86-64) object files",
"win64",
0,
+ 64,
win64_debug_arr,
&df_cv8,
coff_stdmac,
diff --git a/output/outdbg.c b/output/outdbg.c
index 155dbd17..034a6152 100644
--- a/output/outdbg.c
+++ b/output/outdbg.c
@@ -264,6 +264,7 @@ struct ofmt of_dbg = {
"Trace of all info passed to output stage",
"dbg",
OFMT_TEXT,
+ 64,
debug_debug_arr,
&debug_debug_form,
NULL,
diff --git a/output/outelf32.c b/output/outelf32.c
index 7ac78050..e4971ed4 100644
--- a/output/outelf32.c
+++ b/output/outelf32.c
@@ -1366,6 +1366,7 @@ struct ofmt of_elf32 = {
"ELF32 (i386) object files (e.g. Linux)",
"elf32",
0,
+ 32,
elf32_debugs_arr,
&df_stabs,
elf_stdmac,
diff --git a/output/outelf64.c b/output/outelf64.c
index 3c3e921a..f2a192a3 100644
--- a/output/outelf64.c
+++ b/output/outelf64.c
@@ -191,7 +191,6 @@ static int32_t elf_gottpoff_sect;
static void elf_init(void)
{
- maxbits = 64;
sects = NULL;
nsects = sectlen = 0;
syms = saa_init((int32_t)sizeof(struct elf_symbol));
@@ -1457,6 +1456,7 @@ struct ofmt of_elf64 = {
"ELF64 (x86_64) object files (e.g. Linux)",
"elf64",
0,
+ 64,
elf64_debugs_arr,
&df_stabs,
elf_stdmac,
diff --git a/output/outelfx32.c b/output/outelfx32.c
index 33972b41..c217c7be 100644
--- a/output/outelfx32.c
+++ b/output/outelfx32.c
@@ -190,7 +190,6 @@ static int32_t elf_gottpoff_sect;
static void elf_init(void)
{
- maxbits = 64;
sects = NULL;
nsects = sectlen = 0;
syms = saa_init((int32_t)sizeof(struct elf_symbol));
@@ -1416,6 +1415,7 @@ struct ofmt of_elfx32 = {
"ELFX32 (x86_64) object files (e.g. Linux)",
"elfx32",
0,
+ 64,
elfx32_debugs_arr,
&df_stabs,
elf_stdmac,
diff --git a/output/outieee.c b/output/outieee.c
index d42a6fd8..42f0fb66 100644
--- a/output/outieee.c
+++ b/output/outieee.c
@@ -1517,6 +1517,7 @@ struct ofmt of_ieee = {
"IEEE-695 (LADsoft variant) object file format",
"ieee",
OFMT_TEXT,
+ 32,
ladsoft_debug_arr,
&ladsoft_debug_form,
NULL,
diff --git a/output/outmac32.c b/output/outmac32.c
index 873ed7e1..8014b7c0 100644
--- a/output/outmac32.c
+++ b/output/outmac32.c
@@ -1303,6 +1303,7 @@ struct ofmt of_macho32 = {
"NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (i386) object files",
"macho32",
0,
+ 32,
null_debug_arr,
&null_debug_form,
macho_stdmac,
diff --git a/output/outmac64.c b/output/outmac64.c
index 5c8a0dc6..a12a1671 100644
--- a/output/outmac64.c
+++ b/output/outmac64.c
@@ -332,8 +332,6 @@ static void macho_init(void)
{
char zero = 0;
- maxbits = 64;
-
sects = NULL;
sectstail = &sects;
@@ -1495,6 +1493,7 @@ struct ofmt of_macho64 = {
"NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (x86_64) object files",
"macho64",
0,
+ 64,
null_debug_arr,
&null_debug_form,
macho_stdmac,
diff --git a/output/outobj.c b/output/outobj.c
index c9f40094..ff03664c 100644
--- a/output/outobj.c
+++ b/output/outobj.c
@@ -2627,6 +2627,7 @@ struct ofmt of_obj = {
"MS-DOS 16-bit/32-bit OMF object files",
"obj",
0,
+ 32,
borland_debug_arr,
&borland_debug_form,
obj_stdmac,
diff --git a/output/outrdf2.c b/output/outrdf2.c
index 884cdf44..4dcae83c 100644
--- a/output/outrdf2.c
+++ b/output/outrdf2.c
@@ -114,8 +114,6 @@ static void rdf2_init(void)
{
int segtext, segdata, segbss;
- maxbits = 64;
-
/* set up the initial segments */
segments[0].segname = ".text";
segments[0].segnumber = 0;
@@ -781,6 +779,7 @@ struct ofmt of_rdf2 = {
"Relocatable Dynamic Object File Format v2.0",
"rdf",
0,
+ 64,
null_debug_arr,
&null_debug_form,
rdf2_stdmac,