From: nasm-bot f. H. P. A. <hp...@zy...> - 2016-02-12 04:42:18
|
Commit-ID: 33814133bdc8db9fcbdc1be097f7b4a226d8e143 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=33814133bdc8db9fcbdc1be097f7b4a226d8e143 Author: H. Peter Anvin <hp...@zy...> AuthorDate: Thu, 11 Feb 2016 20:40:07 -0800 Committer: H. Peter Anvin <hp...@zy...> CommitDate: Thu, 11 Feb 2016 20:40:07 -0800 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 <hp...@zy...> --- assemble.c | 9 ++++----- nasm.c | 1 - nasm.h | 5 +++-- output/outaout.c | 2 ++ output/outas86.c | 1 + output/outbin.c | 6 ++++-- output/outcoff.c | 4 +++- output/outdbg.c | 1 + output/outelf32.c | 1 + output/outelf64.c | 2 +- output/outelfx32.c | 2 +- output/outieee.c | 1 + output/outmac32.c | 1 + output/outmac64.c | 3 +-- output/outobj.c | 1 + output/outrdf2.c | 3 +-- 16 files changed, 26 insertions(+), 17 deletions(-) diff --git a/assemble.c b/assemble.c index 1d8c3c1..0535944 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 bb62d17..55c7a2a 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 bd1f290..f0cc346 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 1b2b219..360f549 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 892362b..43108c4 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 c64daaa..71c7bcd 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 73ba13e..a712f95 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 155dbd1..034a615 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 7ac7805..e4971ed 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 3c3e921..f2a192a 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 33972b4..c217c7b 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 d42a6fd..42f0fb6 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 873ed7e..8014b7c 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 5c8a0dc..a12a167 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 = §s; @@ -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 c9f4009..ff03664 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 884cdf4..4dcae83 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, |