summaryrefslogtreecommitdiff
path: root/asm/pragma.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2018-06-01 18:02:54 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2018-06-01 18:06:25 -0700
commit98578071b9d71ecaa2344dd9c185237c1765041e (patch)
tree74dfdf8b0f587364f34ae804dc7ce0cd7d81ba7e /asm/pragma.c
parent8413e8167a21a922bbf99660165bb091e71bf1c0 (diff)
downloadnasm-98578071b9d71ecaa2344dd9c185237c1765041e.tar.gz
Cleanup of label renaming infrastructure, add subsection support
In order to support Mach-O better, add support for subsections, as used by Mach-O "subsections_via_symbols". We also want to add infrastructure to support this by downcalling to the backend to indicate if a new subsection is needed. Currently this supports a maximum of 2^14 subsections per section for Mach-O; this can be addressed by adding a level of indirection (or cleaning up the handling of sections so we have an actual data structure.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'asm/pragma.c')
-rw-r--r--asm/pragma.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/asm/pragma.c b/asm/pragma.c
index cbe0cc7b..e7dba760 100644
--- a/asm/pragma.c
+++ b/asm/pragma.c
@@ -49,6 +49,8 @@
#include "assemble.h"
#include "error.h"
+static enum directive_result asm_pragma(const struct pragma *pragma);
+
/*
* Handle [pragma] directives. [pragma] is generally produced by
* the %pragma preprocessor directive, which simply passes on any
@@ -83,7 +85,7 @@
*/
static struct pragma_facility global_pragmas[] =
{
- { "asm", NULL },
+ { "asm", asm_pragma },
{ "list", NULL },
{ "file", NULL },
{ "input", NULL },
@@ -202,7 +204,7 @@ void process_pragma(char *str)
else
pragma.opcode = directive_find(pragma.opname);
- pragma.tail = nasm_skip_spaces(p);
+ pragma.tail = nasm_trim_spaces(p);
/* Look for a global pragma namespace */
if (search_pragma_list(global_pragmas, NULL, &pragma))
@@ -227,3 +229,28 @@ void process_pragma(char *str)
* already defined for future compatibility.
*/
}
+
+/*
+ * Pragmas for the assembler proper
+ */
+static enum directive_result asm_pragma(const struct pragma *pragma)
+{
+ switch (pragma->opcode) {
+ case D_PREFIX:
+ case D_GPREFIX:
+ set_label_mangle(LM_GPREFIX, pragma->tail);
+ return DIRR_OK;
+ case D_SUFFIX:
+ case D_GSUFFIX:
+ set_label_mangle(LM_GSUFFIX, pragma->tail);
+ return DIRR_OK;
+ case D_LPREFIX:
+ set_label_mangle(LM_LPREFIX, pragma->tail);
+ return DIRR_OK;
+ case D_LSUFFIX:
+ set_label_mangle(LM_LSUFFIX, pragma->tail);
+ return DIRR_OK;
+ default:
+ return DIRR_UNKNOWN;
+ }
+}