summaryrefslogtreecommitdiff
path: root/libyasm
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2007-05-28 08:52:18 +0000
committerPeter Johnson <peter@tortall.net>2007-05-28 08:52:18 +0000
commitd2fe9a793c74406c36b698efab2fe5ba5931b4c2 (patch)
tree424c70bbf666f2929cf788b9fabbd96319acb184 /libyasm
parent3e5fed2ad1725c0608fad598e182e8852638392d (diff)
downloadyasm-d2fe9a793c74406c36b698efab2fe5ba5931b4c2.tar.gz
Fix #102: Permit non-standard macho section names.
Two forms are legal ({} are replaceables): SECTION {segname} {sectname} SECTION {sectname} segname={segname} Also, SECTION {sectname} where sectname is unrecognized is also legal, defaults segname to __TEXT, and generates a warning. Contributed by: bird-yasm@anduin.net svn path=/trunk/yasm/; revision=1852
Diffstat (limited to 'libyasm')
-rw-r--r--libyasm/valparam.c19
-rw-r--r--libyasm/valparam.h16
2 files changed, 35 insertions, 0 deletions
diff --git a/libyasm/valparam.c b/libyasm/valparam.c
index 84cf984d..752ab7e3 100644
--- a/libyasm/valparam.c
+++ b/libyasm/valparam.c
@@ -354,6 +354,25 @@ yasm_dir_helper_intn(void *obj, yasm_valparam *vp, unsigned long line,
}
int
+yasm_dir_helper_string(void *obj, yasm_valparam *vp, unsigned long line,
+ void *data, uintptr_t arg)
+{
+ /*@dependent@*/ /*@null@*/ const char *local;
+ char **s = (char **)data;
+
+ if (*s)
+ yasm_xfree(*s);
+ if (!(local = yasm_vp_string(vp))) {
+ yasm_error_set(YASM_ERROR_VALUE,
+ N_("argument to `%s' is not a string or identifier"),
+ vp->val);
+ return -1;
+ }
+ *s = yasm__xstrdup(local);
+ return 0;
+}
+
+int
yasm_dir_helper_valparam_warn(void *obj, yasm_valparam *vp,
unsigned long line, void *data)
{
diff --git a/libyasm/valparam.h b/libyasm/valparam.h
index 9a2a1303..4a64a66f 100644
--- a/libyasm/valparam.h
+++ b/libyasm/valparam.h
@@ -340,6 +340,22 @@ int yasm_dir_helper_flag_and(void *obj, yasm_valparam *vp, unsigned long line,
int yasm_dir_helper_intn(void *obj, yasm_valparam *vp, unsigned long line,
void *data, uintptr_t arg);
+/** Standard helper for yasm_dir_helper() that parses an string (or
+ * standalone identifier) parameter.
+ * The #yasm_dir_help structure that uses this function should have
+ * needsparam=1. The data parameter that is ultimately passed to this
+ * function (e.g. yasm_dir_helper() data parameter plus #yasm_dir_help.off)
+ * must point to a char * initialized to NULL.
+ * \param obj unused
+ * \param vp valparam
+ * \param line unused
+ * \param data pointer to char *
+ * \param arg unused
+ * \return -1 on error, 0 otherwise.
+ */
+int yasm_dir_helper_string(void *obj, yasm_valparam *vp, unsigned long line,
+ void *data, uintptr_t arg);
+
/** Standard catch-all callback fro yasm_dir_helper(). Generates standard
* warning for all valparams.
* \param obj unused