summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-03-07 21:46:04 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-03-07 22:00:01 -0800
commitfc0ff223b203c5e90cdf59707edb5ad965bc4b18 (patch)
tree70785813066ea0a98acd6d6f08854e329a6cf232
parent172b840aa35d7018509036a3a7d3c467b331f73c (diff)
downloadnasm-fc0ff223b203c5e90cdf59707edb5ad965bc4b18.tar.gz
labels: emit the same label name to the output and debug backends!!
When a local label was seen, the debug backend would not receive the full label name! In order to both simplify the code and avoid this kind of discrepancy again, make both the output and debug format calls from a common static function. However, none of the current debug format backends want to see NASM special symbols (that start with .. but not ..@) so filter those from the debug backend. Finally, fix an incorrect comment in nasm.h: the debug format is called *after* the output format. Signed-off-by: H. Peter Anvin <hpa@zytor.com> Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
-rw-r--r--labels.c52
-rw-r--r--nasm.h2
-rw-r--r--test/cv8struc.asm6
3 files changed, 36 insertions, 24 deletions
diff --git a/labels.c b/labels.c
index 94c2ae6f..d7cdb8c3 100644
--- a/labels.c
+++ b/labels.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2014 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2016 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -127,6 +127,22 @@ char lprefix[PREFIX_MAX] = { 0 };
char lpostfix[PREFIX_MAX] = { 0 };
/*
+ * Emit a symdef to the output and the debug format backends.
+ */
+static void out_symdef(char *name, int32_t segment, int64_t offset,
+ int is_global, char *special)
+{
+ ofmt->symdef(name, segment, offset, is_global, special);
+
+ /*
+ * NASM special symbols are not passed to the debug format; none
+ * of the current backends want to see them.
+ */
+ if (!(name[0] == '.' && name[1] == '.' && name[2] != '@'))
+ dfmt->debug_deflabel(name, segment, offset, is_global, special);
+}
+
+/*
* Internal routine: finds the `union label' corresponding to the
* given label name. Creates a new one, if it isn't found, and if
* `create' is true.
@@ -260,17 +276,13 @@ void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
snprintf(xsymbol, slen, "%s%s%s", lprefix, lptr->defn.label,
lpostfix);
- ofmt->symdef(xsymbol, segment, offset, exi,
- special ? special : lptr->defn.special);
- dfmt->debug_deflabel(xsymbol, segment, offset, exi,
- special ? special : lptr->defn.special);
-/** nasm_free(xsymbol); ! outobj.c stores the pointer; ouch!!! **/
+ out_symdef(xsymbol, segment, offset, exi,
+ special ? special : lptr->defn.special);
+ /** nasm_free(xsymbol); ! outobj.c stores the pointer; ouch!!! **/
} else {
if ((lptr->defn.is_global & (GLOBAL_BIT | EXTERN_BIT)) != EXTERN_BIT) {
- ofmt->symdef(lptr->defn.label, segment, offset, exi,
- special ? special : lptr->defn.special);
- dfmt->debug_deflabel(label, segment, offset, exi,
- special ? special : lptr->defn.special);
+ out_symdef(lptr->defn.label, segment, offset, exi,
+ special ? special : lptr->defn.special);
}
}
} /* if (pass0 == 1) */
@@ -325,17 +337,13 @@ void define_label(char *label, int32_t segment, int64_t offset, char *special,
snprintf(xsymbol, slen, "%s%s%s", lprefix, lptr->defn.label,
lpostfix);
- ofmt->symdef(xsymbol, segment, offset, exi,
- special ? special : lptr->defn.special);
- dfmt->debug_deflabel(xsymbol, segment, offset, exi,
- special ? special : lptr->defn.special);
-/** nasm_free(xsymbol); ! outobj.c stores the pointer; ouch!!! **/
+ out_symdef(xsymbol, segment, offset, exi,
+ special ? special : lptr->defn.special);
+ /** nasm_free(xsymbol); ! outobj.c stores the pointer; ouch!!! **/
} else {
if ((lptr->defn.is_global & (GLOBAL_BIT | EXTERN_BIT)) != EXTERN_BIT) {
- ofmt->symdef(lptr->defn.label, segment, offset, exi,
- special ? special : lptr->defn.special);
- dfmt->debug_deflabel(label, segment, offset, exi,
- special ? special : lptr->defn.special);
+ out_symdef(lptr->defn.label, segment, offset, exi,
+ special ? special : lptr->defn.special);
}
}
} /* if (pass0 == 1) */
@@ -369,10 +377,8 @@ void define_common(char *label, int32_t segment, int32_t size, char *special)
if (pass0 == 0)
return;
- ofmt->symdef(lptr->defn.label, segment, size, 2,
- special ? special : lptr->defn.special);
- dfmt->debug_deflabel(lptr->defn.label, segment, size, 2,
- special ? special : lptr->defn.special);
+ out_symdef(lptr->defn.label, segment, size, 2,
+ special ? special : lptr->defn.special);
}
void declare_as_global(char *label, char *special)
diff --git a/nasm.h b/nasm.h
index ea715c52..16d4ae81 100644
--- a/nasm.h
+++ b/nasm.h
@@ -887,7 +887,7 @@ struct dfmt {
/*
* debug_deflabel - called whenever a label is defined. Parameters
* are the same as to 'symdef()' in the output format. This function
- * would be called before the output format version.
+ * is called after the output format version.
*/
void (*debug_deflabel)(char *name, int32_t segment, int64_t offset,
diff --git a/test/cv8struc.asm b/test/cv8struc.asm
index 83fce799..eac6d8bb 100644
--- a/test/cv8struc.asm
+++ b/test/cv8struc.asm
@@ -6,3 +6,9 @@ a_struc:
istruc A_STRUC
at A_STRUC._a, dw 1
iend
+
+ section .data
+foo:
+ dd 0x11111111
+.bar:
+ dd 0x22222222