mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-02-23 17:29:23 +08:00
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>
This commit is contained in:
parent
a7bc15dd0a
commit
338656c1de
4
nasm.c
4
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 */
|
||||
|
2
nasm.h
2
nasm.h
@ -917,7 +917,7 @@ struct ofmt_alias {
|
||||
struct ofmt *ofmt;
|
||||
};
|
||||
|
||||
extern struct ofmt *ofmt;
|
||||
extern const struct ofmt *ofmt;
|
||||
extern FILE *ofile;
|
||||
|
||||
/*
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user