mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-02-17 17:19:35 +08:00
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>
This commit is contained in:
parent
172b840aa3
commit
fc0ff223b2
52
labels.c
52
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.
|
||||
*
|
||||
@ -126,6 +126,22 @@ static bool initialized = false;
|
||||
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
|
||||
@ -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)
|
||||
|
2
nasm.h
2
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,
|
||||
|
@ -6,3 +6,9 @@ a_struc:
|
||||
istruc A_STRUC
|
||||
at A_STRUC._a, dw 1
|
||||
iend
|
||||
|
||||
section .data
|
||||
foo:
|
||||
dd 0x11111111
|
||||
.bar:
|
||||
dd 0x22222222
|
||||
|
Loading…
Reference in New Issue
Block a user