summaryrefslogtreecommitdiff
path: root/nasm.c
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 /nasm.c
parentf2536e10a02bb8813cce5883862309d5b6b0162f (diff)
downloadnasm-c1936da94269bf0a909310f2ec57aea818eabb70.tar.gz
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 'nasm.c')
-rw-r--r--nasm.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/nasm.c b/nasm.c
index c0a105b0..36be46e4 100644
--- a/nasm.c
+++ b/nasm.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2010 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.
*
@@ -98,6 +98,7 @@ 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 dfmt *dfmt;
static FILE *error_file; /* Where to write error messages */
@@ -268,8 +269,13 @@ static void define_macros_late(void)
{
char temp[128];
+ /*
+ * In case if output format is defined by alias
+ * we have to put shortname of the alias itself here
+ * otherwise ABI backward compatibility gets broken.
+ */
snprintf(temp, sizeof(temp), "__OUTPUT_FORMAT__=%s",
- ofmt->shortname);
+ ofmt_alias ? ofmt_alias->shortname : ofmt->shortname);
pp_pre_define(temp);
}
@@ -652,7 +658,7 @@ static bool process_arg(char *p, char *q)
break;
case 'f': /* output format */
- ofmt = ofmt_find(param);
+ ofmt = ofmt_find(param, &ofmt_alias);
if (!ofmt) {
nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
"unrecognised output format `%s' - "