summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2016-02-17 20:59:22 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2016-02-17 20:59:22 -0800
commit338656c1de8cace12c55c87ce40a7d909f18c2e9 (patch)
tree4f3619d97719b826ec83f4f37fdec5beade972cc
parenta7bc15dd0aa963ab56a98ee04bc08ce6d9e3baea (diff)
downloadnasm-338656c1de8cace12c55c87ce40a7d909f18c2e9.tar.gz
output: make all instances of struct ofmt readonly
With current_dfmt gone, we can make all instances of struct ofmt const (read-only). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--nasm.c4
-rw-r--r--nasm.h2
-rw-r--r--output/outaout.c6
-rw-r--r--output/outas86.c2
-rw-r--r--output/outbin.c8
-rw-r--r--output/outcoff.c6
-rw-r--r--output/outdbg.c4
-rw-r--r--output/outelf32.c4
-rw-r--r--output/outelf64.c4
-rw-r--r--output/outelfx32.c4
-rw-r--r--output/outform.c12
-rw-r--r--output/outform.h48
-rw-r--r--output/outieee.c4
-rw-r--r--output/outlib.h1
-rw-r--r--output/outmacho.c6
-rw-r--r--output/outobj.c4
-rw-r--r--output/outrdf2.c2
17 files changed, 60 insertions, 61 deletions
diff --git a/nasm.c b/nasm.c
index bab5c610..3c2fada2 100644
--- a/nasm.c
+++ b/nasm.c
@@ -99,8 +99,8 @@ static char listname[FILENAME_MAX];
static char errname[FILENAME_MAX];
static int globallineno; /* for forward-reference tracking */
/* static int pass = 0; */
-struct ofmt *ofmt = &OF_DEFAULT;
-struct ofmt_alias *ofmt_alias = NULL;
+const struct ofmt *ofmt = &OF_DEFAULT;
+const struct ofmt_alias *ofmt_alias = NULL;
const struct dfmt *dfmt;
static FILE *error_file; /* Where to write error messages */
diff --git a/nasm.h b/nasm.h
index 2e7a4532..80917a14 100644
--- a/nasm.h
+++ b/nasm.h
@@ -917,7 +917,7 @@ struct ofmt_alias {
struct ofmt *ofmt;
};
-extern struct ofmt *ofmt;
+extern const struct ofmt *ofmt;
extern FILE *ofile;
/*
diff --git a/output/outaout.c b/output/outaout.c
index 1ff22a54..5a125408 100644
--- a/output/outaout.c
+++ b/output/outaout.c
@@ -188,7 +188,7 @@ static void aout_init(void)
#ifdef OF_AOUTB
-extern struct ofmt of_aoutb;
+extern const struct ofmt of_aoutb;
static void aoutb_init(void)
{
@@ -908,7 +908,7 @@ extern macros_t aout_stdmac[];
#ifdef OF_AOUT
-struct ofmt of_aout = {
+const struct ofmt of_aout = {
"Linux a.out object files",
"aout",
0,
@@ -932,7 +932,7 @@ struct ofmt of_aout = {
#ifdef OF_AOUTB
-struct ofmt of_aoutb = {
+const struct ofmt of_aoutb = {
"NetBSD/FreeBSD a.out object files",
"aoutb",
0,
diff --git a/output/outas86.c b/output/outas86.c
index 43108c4e..ac3628f7 100644
--- a/output/outas86.c
+++ b/output/outas86.c
@@ -629,7 +629,7 @@ static void as86_filename(char *inname, char *outname)
extern macros_t as86_stdmac[];
-struct ofmt of_as86 = {
+const struct ofmt of_as86 = {
"Linux as86 (bin86 version 0.3) object files",
"as86",
0,
diff --git a/output/outbin.c b/output/outbin.c
index 4d669af0..5f993467 100644
--- a/output/outbin.c
+++ b/output/outbin.c
@@ -1405,7 +1405,7 @@ static int bin_set_info(enum geninfo type, char **val)
return 0;
}
-struct ofmt of_bin, of_ith, of_srec;
+const struct ofmt of_bin, of_ith, of_srec;
static void binfmt_init(void);
static void do_output_bin(void);
static void do_output_ith(void);
@@ -1655,7 +1655,7 @@ static void do_output_srec(void)
}
-struct ofmt of_bin = {
+const struct ofmt of_bin = {
"flat-form binary files (e.g. DOS .COM, .SYS)",
"bin",
0,
@@ -1675,7 +1675,7 @@ struct ofmt of_bin = {
bin_cleanup
};
-struct ofmt of_ith = {
+const struct ofmt of_ith = {
"Intel hex",
"ith",
OFMT_TEXT,
@@ -1695,7 +1695,7 @@ struct ofmt of_ith = {
bin_cleanup
};
-struct ofmt of_srec = {
+const struct ofmt of_srec = {
"Motorola S-records",
"srec",
OFMT_TEXT,
diff --git a/output/outcoff.c b/output/outcoff.c
index bd971d1c..e208c93a 100644
--- a/output/outcoff.c
+++ b/output/outcoff.c
@@ -1168,7 +1168,7 @@ static int coff_set_info(enum geninfo type, char **val)
#ifdef OF_COFF
-struct ofmt of_coff = {
+const struct ofmt of_coff = {
"COFF (i386) object files (e.g. DJGPP for DOS)",
"coff",
0,
@@ -1196,7 +1196,7 @@ extern struct dfmt df_cv8;
struct dfmt *win32_debug_arr[2] = { &df_cv8, NULL };
-struct ofmt of_win32 = {
+const struct ofmt of_win32 = {
"Microsoft Win32 (i386) object files",
"win32",
0,
@@ -1222,7 +1222,7 @@ struct ofmt of_win32 = {
struct dfmt *win64_debug_arr[2] = { &df_cv8, NULL };
-struct ofmt of_win64 = {
+const struct ofmt of_win64 = {
"Microsoft Win64 (x86-64) object files",
"win64",
0,
diff --git a/output/outdbg.c b/output/outdbg.c
index 83860abd..b954f146 100644
--- a/output/outdbg.c
+++ b/output/outdbg.c
@@ -56,7 +56,7 @@ struct Section {
char *name;
} *dbgsect;
-struct ofmt of_dbg;
+const struct ofmt of_dbg;
static void dbg_init(void)
{
dbgsect = NULL;
@@ -260,7 +260,7 @@ static struct dfmt *debug_debug_arr[3] = {
NULL
};
-struct ofmt of_dbg = {
+const struct ofmt of_dbg = {
"Trace of all info passed to output stage",
"dbg",
OFMT_TEXT,
diff --git a/output/outelf32.c b/output/outelf32.c
index 5a9f847c..bc8be226 100644
--- a/output/outelf32.c
+++ b/output/outelf32.c
@@ -82,7 +82,7 @@ static struct elf_symbol *fwds;
static char elf_module[FILENAME_MAX];
-extern struct ofmt of_elf32;
+extern const struct ofmt of_elf32;
static struct ELF_SECTDATA {
void *data;
@@ -1360,7 +1360,7 @@ static struct dfmt df_stabs = {
struct dfmt *elf32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL };
-struct ofmt of_elf32 = {
+const struct ofmt of_elf32 = {
"ELF32 (i386) object files (e.g. Linux)",
"elf32",
0,
diff --git a/output/outelf64.c b/output/outelf64.c
index ec001560..829c6ff0 100644
--- a/output/outelf64.c
+++ b/output/outelf64.c
@@ -82,7 +82,7 @@ static struct elf_symbol *fwds;
static char elf_module[FILENAME_MAX];
-extern struct ofmt of_elf64;
+extern const struct ofmt of_elf64;
static struct ELF_SECTDATA {
void *data;
@@ -1451,7 +1451,7 @@ static struct dfmt df_stabs = {
struct dfmt *elf64_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL };
-struct ofmt of_elf64 = {
+const struct ofmt of_elf64 = {
"ELF64 (x86_64) object files (e.g. Linux)",
"elf64",
0,
diff --git a/output/outelfx32.c b/output/outelfx32.c
index fcd97d35..0d5edf21 100644
--- a/output/outelfx32.c
+++ b/output/outelfx32.c
@@ -82,7 +82,7 @@ static struct elf_symbol *fwds;
static char elf_module[FILENAME_MAX];
-extern struct ofmt of_elfx32;
+extern const struct ofmt of_elfx32;
static struct ELF_SECTDATA {
void *data;
@@ -1410,7 +1410,7 @@ static struct dfmt df_stabs = {
struct dfmt *elfx32_debugs_arr[3] = { &df_dwarf, &df_stabs, NULL };
-struct ofmt of_elfx32 = {
+const struct ofmt of_elfx32 = {
"ELFX32 (x86_64) object files (e.g. Linux)",
"elfx32",
0,
diff --git a/output/outform.c b/output/outform.c
index 3d70e2a9..77983c00 100644
--- a/output/outform.c
+++ b/output/outform.c
@@ -47,9 +47,9 @@
#define BUILD_DRIVERS_ARRAY
#include "output/outform.h"
-struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias)
+const struct ofmt *ofmt_find(char *name, const struct ofmt_alias **ofmt_alias)
{
- struct ofmt **ofp, *of;
+ const struct ofmt **ofp, *of;
unsigned int i;
*ofmt_alias = NULL;
@@ -72,7 +72,7 @@ struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias)
return NULL;
}
-struct dfmt *dfmt_find(struct ofmt *ofmt, char *name)
+struct dfmt *dfmt_find(const struct ofmt *ofmt, char *name)
{
struct dfmt **dfp, *df;
@@ -83,9 +83,9 @@ struct dfmt *dfmt_find(struct ofmt *ofmt, char *name)
return NULL;
}
-void ofmt_list(struct ofmt *deffmt, FILE * fp)
+void ofmt_list(const struct ofmt *deffmt, FILE * fp)
{
- struct ofmt **ofp, *of;
+ const struct ofmt **ofp, *of;
unsigned int i;
/* primary targets first */
@@ -105,7 +105,7 @@ void ofmt_list(struct ofmt *deffmt, FILE * fp)
}
}
-void dfmt_list(struct ofmt *ofmt, FILE *fp)
+void dfmt_list(const struct ofmt *ofmt, FILE *fp)
{
struct dfmt **dfp, *df;
diff --git a/output/outform.h b/output/outform.h
index f52a112a..f01588d0 100644
--- a/output/outform.h
+++ b/output/outform.h
@@ -262,24 +262,24 @@
#define OF_DEFAULT of_bin
#endif
-extern struct ofmt of_bin;
-extern struct ofmt of_ith;
-extern struct ofmt of_srec;
-extern struct ofmt of_aout;
-extern struct ofmt of_aoutb;
-extern struct ofmt of_coff;
-extern struct ofmt of_elf32;
-extern struct ofmt of_elfx32;
-extern struct ofmt of_elf64;
-extern struct ofmt of_as86;
-extern struct ofmt of_obj;
-extern struct ofmt of_win32;
-extern struct ofmt of_win64;
-extern struct ofmt of_rdf2;
-extern struct ofmt of_ieee;
-extern struct ofmt of_macho32;
-extern struct ofmt of_macho64;
-extern struct ofmt of_dbg;
+extern const struct ofmt of_bin;
+extern const struct ofmt of_ith;
+extern const struct ofmt of_srec;
+extern const struct ofmt of_aout;
+extern const struct ofmt of_aoutb;
+extern const struct ofmt of_coff;
+extern const struct ofmt of_elf32;
+extern const struct ofmt of_elfx32;
+extern const struct ofmt of_elf64;
+extern const struct ofmt of_as86;
+extern const struct ofmt of_obj;
+extern const struct ofmt of_win32;
+extern const struct ofmt of_win64;
+extern const struct ofmt of_rdf2;
+extern const struct ofmt of_ieee;
+extern const struct ofmt of_macho32;
+extern const struct ofmt of_macho64;
+extern const struct ofmt of_dbg;
#ifdef BUILD_DRIVERS_ARRAY /* only if included from outform.c */
@@ -288,7 +288,7 @@ extern struct ofmt of_dbg;
* drivers array based on the above defines
*/
-static struct ofmt *drivers[] = {
+static const struct ofmt *drivers[] = {
#ifdef OF_BIN
&of_bin,
&of_ith,
@@ -343,7 +343,7 @@ static struct ofmt *drivers[] = {
NULL
};
-static struct ofmt_alias ofmt_aliases[] = {
+static const struct ofmt_alias ofmt_aliases[] = {
#ifdef OF_ELF32
{
"elf",
@@ -370,10 +370,10 @@ static struct ofmt_alias ofmt_aliases[] = {
#endif /* BUILD_DRIVERS_ARRAY */
-struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias);
-struct dfmt *dfmt_find(struct ofmt *, char *);
-void ofmt_list(struct ofmt *, FILE *);
-void dfmt_list(struct ofmt *ofmt, FILE * fp);
+const struct ofmt *ofmt_find(char *name, const struct ofmt_alias **ofmt_alias);
+struct dfmt *dfmt_find(const struct ofmt *, char *);
+void ofmt_list(const struct ofmt *, FILE *);
+void dfmt_list(const struct ofmt *ofmt, FILE * fp);
extern struct dfmt null_debug_form;
#endif /* NASM_OUTFORM_H */
diff --git a/output/outieee.c b/output/outieee.c
index 2fcbddb1..727d04ef 100644
--- a/output/outieee.c
+++ b/output/outieee.c
@@ -184,7 +184,7 @@ struct ieeeFixupp {
static int32_t ieee_entry_seg, ieee_entry_ofs;
static int checksum;
-extern struct ofmt of_ieee;
+extern const struct ofmt of_ieee;
static void ieee_data_new(struct ieeeSection *);
static void ieee_write_fixup(int32_t, int32_t, struct ieeeSection *,
@@ -1513,7 +1513,7 @@ static struct dfmt *ladsoft_debug_arr[3] = {
&null_debug_form,
NULL
};
-struct ofmt of_ieee = {
+const struct ofmt of_ieee = {
"IEEE-695 (LADsoft variant) object file format",
"ieee",
OFMT_TEXT,
diff --git a/output/outlib.h b/output/outlib.h
index 29c27a09..1acf11d2 100644
--- a/output/outlib.h
+++ b/output/outlib.h
@@ -44,7 +44,6 @@ int null_directive(enum directives directive, char *value, int pass);
void null_sectalign(int32_t seg, unsigned int value);
/* Do-nothing versions of all the debug routines */
-struct ofmt;
void null_debug_init(void);
void null_debug_linenum(const char *filename, int32_t linenumber,
int32_t segto);
diff --git a/output/outmacho.c b/output/outmacho.c
index 98a440d3..4f8c65a3 100644
--- a/output/outmacho.c
+++ b/output/outmacho.c
@@ -276,7 +276,7 @@ static struct RAA *extsyms;
static struct SAA *strs;
static uint32_t strslen;
-extern struct ofmt of_macho64;
+extern const struct ofmt of_macho64;
/* Global file information. This should be cleaned up into either
a structure or as function arguments. */
@@ -1595,7 +1595,7 @@ static void macho32_init(void)
macho_gotpcrel_sect = NO_SEG;
}
-struct ofmt of_macho32 = {
+const struct ofmt of_macho32 = {
"NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (i386) object files",
"macho32",
0,
@@ -1642,7 +1642,7 @@ static void macho64_init(void)
define_label("..gotpcrel", macho_gotpcrel_sect, 0L, NULL, false, false);
}
-struct ofmt of_macho64 = {
+const struct ofmt of_macho64 = {
"NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (x86_64) object files",
"macho64",
0,
diff --git a/output/outobj.c b/output/outobj.c
index 9a9ff1cb..3cb0610f 100644
--- a/output/outobj.c
+++ b/output/outobj.c
@@ -624,7 +624,7 @@ static struct ExpDef {
static int32_t obj_entry_seg, obj_entry_ofs;
-struct ofmt of_obj;
+const struct ofmt of_obj;
/* The current segment */
static struct Segment *current_seg;
@@ -2623,7 +2623,7 @@ static struct dfmt *borland_debug_arr[3] = {
NULL
};
-struct ofmt of_obj = {
+const struct ofmt of_obj = {
"MS-DOS 16-bit/32-bit OMF object files",
"obj",
0,
diff --git a/output/outrdf2.c b/output/outrdf2.c
index 4dcae83c..235d7139 100644
--- a/output/outrdf2.c
+++ b/output/outrdf2.c
@@ -775,7 +775,7 @@ static int rdf2_set_info(enum geninfo type, char **val)
return 0;
}
-struct ofmt of_rdf2 = {
+const struct ofmt of_rdf2 = {
"Relocatable Dynamic Object File Format v2.0",
"rdf",
0,