summaryrefslogtreecommitdiff
path: root/output
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2010-04-09 15:12:13 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2010-04-10 00:11:00 +0400
commit6837749d85139b37ca0f15cfe293ba078591d117 (patch)
tree487dfb82530ae7c581acc214e7008a85f9324dcb /output
parentf134cc63da27106365a3e735c9c375ed0326a2a0 (diff)
downloadnasm-6837749d85139b37ca0f15cfe293ba078591d117.tar.gz
ofmt: Introduce output format aliases
This allow us to keep compatibility layer without needing the separated struct ofmt for this and elf_init_hack routine. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'output')
-rw-r--r--output/outelf32.c24
-rw-r--r--output/outform.c25
-rw-r--r--output/outform.h42
-rw-r--r--output/outmacho32.c20
4 files changed, 54 insertions, 57 deletions
diff --git a/output/outelf32.c b/output/outelf32.c
index 4a99ec97..bd175cea 100644
--- a/output/outelf32.c
+++ b/output/outelf32.c
@@ -122,7 +122,6 @@ static uint8_t elf_osabi = 0; /* Default OSABI = 0 (System V or Linux) */
static uint8_t elf_abiver = 0; /* Current ABI version */
extern struct ofmt of_elf32;
-extern struct ofmt of_elf;
static struct ELF_SECTDATA {
void *data;
@@ -266,12 +265,6 @@ static void elf_init(void)
def_seg = seg_alloc();
}
-static void elf_init_hack(void)
-{
- of_elf32.current_dfmt = of_elf.current_dfmt; /* Sync debugging format */
- elf_init();
-}
-
static void elf_cleanup(int debuginfo)
{
struct Reloc *r;
@@ -1414,23 +1407,6 @@ struct ofmt of_elf32 = {
elf_cleanup
};
-struct ofmt of_elf = {
- "ELF (short name for ELF32) ",
- "elf",
- 0,
- elf32_debugs_arr,
- &df_stabs,
- elf_stdmac,
- elf_init_hack,
- elf_set_info,
- elf_out,
- elf_deflabel,
- elf_section_names,
- elf_segbase,
- elf_directive,
- elf_filename,
- elf_cleanup
-};
/* again, the stabs debugging stuff (code) */
static void stabs32_linenum(const char *filename, int32_t linenumber,
diff --git a/output/outform.c b/output/outform.c
index fa30986e..f5b6739f 100644
--- a/output/outform.c
+++ b/output/outform.c
@@ -48,18 +48,28 @@
#include "output/outform.h"
struct ofmt *ofmt_find(char *name)
-{ /* find driver */
+{
struct ofmt **ofp, *of;
+ unsigned int i;
+ /* primary targets first */
for (ofp = drivers; (of = *ofp); ofp++) {
if (!nasm_stricmp(name, of->shortname))
return of;
}
+
+ /* lets walk thru aliases then */
+ for (i = 0; i < elements(ofmt_aliases); i++) {
+ if (ofmt_aliases[i].shortname &&
+ !nasm_stricmp(name, ofmt_aliases[i].shortname))
+ return ofmt_aliases[i].ofmt;
+ }
+
return NULL;
}
struct dfmt *dfmt_find(struct ofmt *ofmt, char *name)
-{ /* find driver */
+{
struct dfmt **dfp, *df;
for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) {
@@ -72,12 +82,23 @@ struct dfmt *dfmt_find(struct ofmt *ofmt, char *name)
void ofmt_list(struct ofmt *deffmt, FILE * fp)
{
struct ofmt **ofp, *of;
+ unsigned int i;
+ /* primary targets first */
for (ofp = drivers; (of = *ofp); ofp++) {
fprintf(fp, " %c %-10s%s\n",
of == deffmt ? '*' : ' ',
of->shortname, of->fullname);
}
+
+ /* lets walk through aliases then */
+ for (i = 0; i < elements(ofmt_aliases); i++) {
+ if (!ofmt_aliases[i].shortname)
+ continue;
+ fprintf(fp, " %-10s%s\n",
+ ofmt_aliases[i].shortname,
+ ofmt_aliases[i].fullname);
+ }
}
void dfmt_list(struct ofmt *ofmt, FILE *fp)
diff --git a/output/outform.h b/output/outform.h
index 318e716c..44c4c0a9 100644
--- a/output/outform.h
+++ b/output/outform.h
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1996-2009 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
@@ -14,7 +14,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
@@ -153,7 +153,7 @@
#define OF_BIN
#endif
#ifndef OF_COFF
-#define OF_COFF /* COFF is used by DJGPP */
+#define OF_COFF /* COFF is used by DJGPP */
#endif
#ifndef OF_WIN32
#define OF_WIN32
@@ -260,7 +260,6 @@ extern struct ofmt of_aout;
extern struct ofmt of_aoutb;
extern struct ofmt of_coff;
extern struct ofmt of_elf32;
-extern struct ofmt of_elf;
extern struct ofmt of_elf64;
extern struct ofmt of_as86;
extern struct ofmt of_obj;
@@ -269,14 +268,15 @@ extern struct ofmt of_win64;
extern struct ofmt of_rdf2;
extern struct ofmt of_ieee;
extern struct ofmt of_macho32;
-extern struct ofmt of_macho;
extern struct ofmt of_macho64;
extern struct ofmt of_dbg;
#ifdef BUILD_DRIVERS_ARRAY /* only if included from outform.c */
-/* pull in the externs for the different formats, then make the *drivers
- * array based on the above defines */
+/*
+ * pull in the externs for the different formats, then make the
+ * drivers array based on the above defines
+ */
static struct ofmt *drivers[] = {
#ifdef OF_BIN
@@ -295,7 +295,6 @@ static struct ofmt *drivers[] = {
#endif
#ifdef OF_ELF32
&of_elf32,
- &of_elf,
#endif
#ifdef OF_ELF64
&of_elf64,
@@ -320,7 +319,6 @@ static struct ofmt *drivers[] = {
#endif
#ifdef OF_MACHO32
&of_macho32,
- &of_macho,
#endif
#ifdef OF_MACHO64
&of_macho64,
@@ -332,7 +330,29 @@ static struct ofmt *drivers[] = {
NULL
};
-#endif /* BUILD_DRIVERS_ARRAY */
+static struct ofmt_alias {
+ const char *shortname;
+ const char *fullname;
+ struct ofmt *ofmt;
+} ofmt_aliases[] = {
+#ifdef OF_ELF32
+ {
+ "elf",
+ "ELF (short name for ELF32)",
+ &of_elf32,
+ },
+#endif
+#ifdef OF_MACHO32
+ {
+ "macho",
+ "MACHO (short name for MACHO32)",
+ &of_macho32,
+ },
+#endif
+ { NULL, NULL, NULL }
+};
+
+#endif /* BUILD_DRIVERS_ARRAY */
struct ofmt *ofmt_find(char *);
struct dfmt *dfmt_find(struct ofmt *, char *);
@@ -341,4 +361,4 @@ void dfmt_list(struct ofmt *ofmt, FILE * fp);
struct ofmt *ofmt_register(efunc error);
extern struct dfmt null_debug_form;
-#endif /* NASM_OUTFORM_H */
+#endif /* NASM_OUTFORM_H */
diff --git a/output/outmacho32.c b/output/outmacho32.c
index 51c22318..ee08e024 100644
--- a/output/outmacho32.c
+++ b/output/outmacho32.c
@@ -208,8 +208,6 @@ static struct RAA *extsyms;
static struct SAA *strs;
static uint32_t strslen;
-extern struct ofmt of_macho;
-
/* Global file information. This should be cleaned up into either
a structure or as function arguments. */
uint32_t head_ncmds = 0;
@@ -1325,24 +1323,6 @@ struct ofmt of_macho32 = {
macho_cleanup
};
-struct ofmt of_macho = {
- "MACHO (short name for MACHO32)",
- "macho",
- 0,
- null_debug_arr,
- &null_debug_form,
- macho_stdmac,
- macho_init,
- null_setinfo,
- macho_output,
- macho_symdef,
- macho_section,
- macho_segbase,
- null_directive,
- macho_filename,
- macho_cleanup
-};
-
#endif
/*