summaryrefslogtreecommitdiff
path: root/output
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2011-04-06 18:32:15 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2011-04-06 18:32:15 +0400
commitc1936da94269bf0a909310f2ec57aea818eabb70 (patch)
tree71e296b3188a39e565b1c5f5b8be42c67be6cf96 /output
parentf2536e10a02bb8813cce5883862309d5b6b0162f (diff)
downloadnasm-c1936da94269bf0a909310f2ec57aea818eabb70.tar.gz
nasm-c1936da94269bf0a909310f2ec57aea818eabb70.tar.bz2
nasm-c1936da94269bf0a909310f2ec57aea818eabb70.zip
ofmt: Alias shortname must be used for __OUTPUT_FORMAT__ macro
__OUTPUT_FORMAT__ must consist of shortname of output format or its alias, otherwise userspace ABI gets broken. For example source code still can refer to __OUTPUT_FORMAT__=elf, instead of __OUTPUT_FORMAT__=elf32. BR3246990 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'output')
-rw-r--r--output/outform.c10
-rw-r--r--output/outform.h10
2 files changed, 10 insertions, 10 deletions
diff --git a/output/outform.c b/output/outform.c
index e386343..0c8ae53 100644
--- a/output/outform.c
+++ b/output/outform.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2009 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2011 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -47,11 +47,13 @@
#define BUILD_DRIVERS_ARRAY
#include "output/outform.h"
-struct ofmt *ofmt_find(char *name)
+struct ofmt *ofmt_find(char *name, struct ofmt_alias **ofmt_alias)
{
struct ofmt **ofp, *of;
unsigned int i;
+ *ofmt_alias = NULL;
+
/* primary targets first */
for (ofp = drivers; (of = *ofp); ofp++) {
if (!nasm_stricmp(name, of->shortname))
@@ -61,8 +63,10 @@ struct ofmt *ofmt_find(char *name)
/* lets walk thru aliases then */
for (i = 0; i < ARRAY_SIZE(ofmt_aliases); i++) {
if (ofmt_aliases[i].shortname &&
- !nasm_stricmp(name, ofmt_aliases[i].shortname))
+ !nasm_stricmp(name, ofmt_aliases[i].shortname)) {
+ *ofmt_alias = &ofmt_aliases[i];
return ofmt_aliases[i].ofmt;
+ }
}
return NULL;
diff --git a/output/outform.h b/output/outform.h
index e703d99..4b809b7 100644
--- a/output/outform.h
+++ b/output/outform.h
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2009 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2011 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -330,11 +330,7 @@ static struct ofmt *drivers[] = {
NULL
};
-static struct ofmt_alias {
- const char *shortname;
- const char *fullname;
- struct ofmt *ofmt;
-} ofmt_aliases[] = {
+static struct ofmt_alias ofmt_aliases[] = {
#ifdef OF_ELF32
{
"elf",
@@ -361,7 +357,7 @@ static struct ofmt_alias {
#endif /* BUILD_DRIVERS_ARRAY */
-struct ofmt *ofmt_find(char *);
+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);