pragma.c: make the generic "output" and "debug" pragma namespaces work

"output" and "debug" are supposed to redirect to the current output
and debug formats. Fix it so it actually does.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2018-05-30 14:42:06 -07:00
parent 7310d0bd5b
commit b7136487bd
2 changed files with 52 additions and 2 deletions

View File

@ -83,13 +83,15 @@
*/
static struct pragma_facility global_pragmas[] =
{
{ "preproc", NULL }, /* This shouldn't happen... */
{ "asm", NULL },
{ "list", NULL },
{ "file", NULL },
{ "input", NULL },
/* None of these should actually happen... */
{ "preproc", NULL }, /* This shouldn't happen... */
{ "output", NULL },
{ "debug", NULL },
{ "debug", NULL },
{ "ignore", NULL },
{ NULL, NULL }
};
@ -185,6 +187,15 @@ void process_pragma(char *str)
if (!nasm_stricmp(pragma.facility_name, "ignore"))
return;
/*
* The "output" and "debug" facilities are aliases for the
* current output and debug formats, respectively.
*/
if (!nasm_stricmp(pragma.facility_name, "output"))
pragma.facility_name = ofmt->shortname;
if (!nasm_stricmp(pragma.facility_name, "debug"))
pragma.facility_name = dfmt->shortname;
pragma.opname = nasm_get_word(p, &p);
if (!pragma.opname)
pragma.opcode = D_none;

39
test/subsection.asm Normal file
View File

@ -0,0 +1,39 @@
;
; subsection.asm
;
; Test of Mach-O subsection_by_symbol
;
%pragma output subsections_via_symbols
bits 32
global foo, bar, quux
%define baz Lbaz
foo:
jmp foo
jmp bar
jmp baz
jmp quux
bar:
jmp foo
jmp bar
jmp baz
jmp quux
baz:
jmp foo
jmp bar
jmp baz
jmp quux
quux:
jmp foo
jmp bar
jmp baz
jmp quux