From ac22f77d420d755b57d06b7ba588ac1d819a6f2c Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 23 Sep 2001 19:22:04 +0000 Subject: [PATCH] Get initial bits setting from object format. Change the initial section name from a function to a constant string. Make mode_bits uniformily an unsigned char instead of an int. svn path=/trunk/yasm/; revision=210 --- frontends/yasm/yasm.c | 3 +++ libyasm/linemgr.c | 2 +- libyasm/linemgr.h | 2 +- libyasm/objfmt.h | 9 ++++++--- libyasm/section.c | 2 +- modules/objfmts/dbg/dbg-objfmt.c | 10 ++-------- modules/objfmts/dbg/objfmt.c | 10 ++-------- src/globals.c | 2 +- src/globals.h | 2 +- src/linemgr.c | 2 +- src/linemgr.h | 2 +- src/main.c | 3 +++ src/objfmt.h | 9 ++++++--- src/objfmts/dbg/dbg-objfmt.c | 10 ++-------- src/objfmts/dbg/objfmt.c | 10 ++-------- src/section.c | 2 +- 16 files changed, 34 insertions(+), 46 deletions(-) diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 0b55dbbe..e05475ae 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -59,6 +59,9 @@ main(int argc, char *argv[]) filename = strdup(""); } + /* Get initial BITS setting from object format */ + mode_bits = dbg_objfmt.default_mode_bits; + nasm_parser.do_parse(&nasm_parser, &dbg_objfmt, in); if (filename) diff --git a/libyasm/linemgr.c b/libyasm/linemgr.c index 424c3e89..b86c1c11 100644 --- a/libyasm/linemgr.c +++ b/libyasm/linemgr.c @@ -31,4 +31,4 @@ RCSID("$IdPath$"); char *filename = (char *)NULL; unsigned int line_number = 1; -unsigned int mode_bits = 32; +unsigned char mode_bits = 0; diff --git a/libyasm/linemgr.h b/libyasm/linemgr.h index fbf4eb63..a836dfd9 100644 --- a/libyasm/linemgr.h +++ b/libyasm/linemgr.h @@ -24,7 +24,7 @@ extern char *filename; extern unsigned int line_number; -extern unsigned int mode_bits; +extern unsigned char mode_bits; extern struct symrec_s *locallabel_base; #endif diff --git a/libyasm/objfmt.h b/libyasm/objfmt.h index 813fc94a..1b085063 100644 --- a/libyasm/objfmt.h +++ b/libyasm/objfmt.h @@ -30,6 +30,12 @@ typedef struct objfmt_s { /* keyword used to select format on the command line */ char *keyword; + /* default (starting) section name */ + const char *default_section_name; + + /* default (starting) BITS setting */ + const unsigned char default_mode_bits; + /* NULL-terminated list of debugging formats that are valid to use with * this object format. */ @@ -40,9 +46,6 @@ typedef struct objfmt_s { */ /* struct debugfmt_s *default_df;*/ - /* Get the default (starting) section name. */ - const char *(*get_default_section_name) (void); - /* Is the specified section name valid? * Return is a boolean value. */ diff --git a/libyasm/section.c b/libyasm/section.c index ad760bbd..fafa443a 100644 --- a/libyasm/section.c +++ b/libyasm/section.c @@ -66,7 +66,7 @@ sections_initialize(sectionhead *headp, objfmt *of) /* Initialize default section */ s->type = SECTION_GENERAL; - s->name = strdup(of->get_default_section_name()); + s->name = strdup(of->default_section_name); bytecodes_initialize(&s->bc); return s; diff --git a/modules/objfmts/dbg/dbg-objfmt.c b/modules/objfmts/dbg/dbg-objfmt.c index 7b027855..9c9b983b 100644 --- a/modules/objfmts/dbg/dbg-objfmt.c +++ b/modules/objfmts/dbg/dbg-objfmt.c @@ -31,13 +31,6 @@ RCSID("$IdPath$"); -static const char * -dbg_objfmt_get_default_section_name(void) -{ - fprintf(stderr, "-dbg_objfmt_get_default_section_name()\n"); - return ".text"; -} - static int dbg_objfmt_is_valid_section(const char *name) { @@ -49,6 +42,7 @@ dbg_objfmt_is_valid_section(const char *name) objfmt dbg_objfmt = { "Trace of all info passed to object format module", "dbg", - dbg_objfmt_get_default_section_name, + ".text", + 32, dbg_objfmt_is_valid_section }; diff --git a/modules/objfmts/dbg/objfmt.c b/modules/objfmts/dbg/objfmt.c index 7b027855..9c9b983b 100644 --- a/modules/objfmts/dbg/objfmt.c +++ b/modules/objfmts/dbg/objfmt.c @@ -31,13 +31,6 @@ RCSID("$IdPath$"); -static const char * -dbg_objfmt_get_default_section_name(void) -{ - fprintf(stderr, "-dbg_objfmt_get_default_section_name()\n"); - return ".text"; -} - static int dbg_objfmt_is_valid_section(const char *name) { @@ -49,6 +42,7 @@ dbg_objfmt_is_valid_section(const char *name) objfmt dbg_objfmt = { "Trace of all info passed to object format module", "dbg", - dbg_objfmt_get_default_section_name, + ".text", + 32, dbg_objfmt_is_valid_section }; diff --git a/src/globals.c b/src/globals.c index 424c3e89..b86c1c11 100644 --- a/src/globals.c +++ b/src/globals.c @@ -31,4 +31,4 @@ RCSID("$IdPath$"); char *filename = (char *)NULL; unsigned int line_number = 1; -unsigned int mode_bits = 32; +unsigned char mode_bits = 0; diff --git a/src/globals.h b/src/globals.h index fbf4eb63..a836dfd9 100644 --- a/src/globals.h +++ b/src/globals.h @@ -24,7 +24,7 @@ extern char *filename; extern unsigned int line_number; -extern unsigned int mode_bits; +extern unsigned char mode_bits; extern struct symrec_s *locallabel_base; #endif diff --git a/src/linemgr.c b/src/linemgr.c index 424c3e89..b86c1c11 100644 --- a/src/linemgr.c +++ b/src/linemgr.c @@ -31,4 +31,4 @@ RCSID("$IdPath$"); char *filename = (char *)NULL; unsigned int line_number = 1; -unsigned int mode_bits = 32; +unsigned char mode_bits = 0; diff --git a/src/linemgr.h b/src/linemgr.h index fbf4eb63..a836dfd9 100644 --- a/src/linemgr.h +++ b/src/linemgr.h @@ -24,7 +24,7 @@ extern char *filename; extern unsigned int line_number; -extern unsigned int mode_bits; +extern unsigned char mode_bits; extern struct symrec_s *locallabel_base; #endif diff --git a/src/main.c b/src/main.c index 0b55dbbe..e05475ae 100644 --- a/src/main.c +++ b/src/main.c @@ -59,6 +59,9 @@ main(int argc, char *argv[]) filename = strdup(""); } + /* Get initial BITS setting from object format */ + mode_bits = dbg_objfmt.default_mode_bits; + nasm_parser.do_parse(&nasm_parser, &dbg_objfmt, in); if (filename) diff --git a/src/objfmt.h b/src/objfmt.h index 813fc94a..1b085063 100644 --- a/src/objfmt.h +++ b/src/objfmt.h @@ -30,6 +30,12 @@ typedef struct objfmt_s { /* keyword used to select format on the command line */ char *keyword; + /* default (starting) section name */ + const char *default_section_name; + + /* default (starting) BITS setting */ + const unsigned char default_mode_bits; + /* NULL-terminated list of debugging formats that are valid to use with * this object format. */ @@ -40,9 +46,6 @@ typedef struct objfmt_s { */ /* struct debugfmt_s *default_df;*/ - /* Get the default (starting) section name. */ - const char *(*get_default_section_name) (void); - /* Is the specified section name valid? * Return is a boolean value. */ diff --git a/src/objfmts/dbg/dbg-objfmt.c b/src/objfmts/dbg/dbg-objfmt.c index 7b027855..9c9b983b 100644 --- a/src/objfmts/dbg/dbg-objfmt.c +++ b/src/objfmts/dbg/dbg-objfmt.c @@ -31,13 +31,6 @@ RCSID("$IdPath$"); -static const char * -dbg_objfmt_get_default_section_name(void) -{ - fprintf(stderr, "-dbg_objfmt_get_default_section_name()\n"); - return ".text"; -} - static int dbg_objfmt_is_valid_section(const char *name) { @@ -49,6 +42,7 @@ dbg_objfmt_is_valid_section(const char *name) objfmt dbg_objfmt = { "Trace of all info passed to object format module", "dbg", - dbg_objfmt_get_default_section_name, + ".text", + 32, dbg_objfmt_is_valid_section }; diff --git a/src/objfmts/dbg/objfmt.c b/src/objfmts/dbg/objfmt.c index 7b027855..9c9b983b 100644 --- a/src/objfmts/dbg/objfmt.c +++ b/src/objfmts/dbg/objfmt.c @@ -31,13 +31,6 @@ RCSID("$IdPath$"); -static const char * -dbg_objfmt_get_default_section_name(void) -{ - fprintf(stderr, "-dbg_objfmt_get_default_section_name()\n"); - return ".text"; -} - static int dbg_objfmt_is_valid_section(const char *name) { @@ -49,6 +42,7 @@ dbg_objfmt_is_valid_section(const char *name) objfmt dbg_objfmt = { "Trace of all info passed to object format module", "dbg", - dbg_objfmt_get_default_section_name, + ".text", + 32, dbg_objfmt_is_valid_section }; diff --git a/src/section.c b/src/section.c index ad760bbd..fafa443a 100644 --- a/src/section.c +++ b/src/section.c @@ -66,7 +66,7 @@ sections_initialize(sectionhead *headp, objfmt *of) /* Initialize default section */ s->type = SECTION_GENERAL; - s->name = strdup(of->get_default_section_name()); + s->name = strdup(of->default_section_name); bytecodes_initialize(&s->bc); return s; -- 2.40.0