summaryrefslogtreecommitdiff
path: root/libyasm
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2010-03-28 19:28:54 +0000
committerPeter Johnson <peter@tortall.net>2010-03-28 19:28:54 +0000
commit323153d55a9e88184a5feea6644b61d13fa0d0ec (patch)
treef3dae69de2cbe003b6f01e7597e0f8083274e222 /libyasm
parente56ece9a7d2f05233460b528fa5d04f46a30b370 (diff)
downloadyasm-323153d55a9e88184a5feea6644b61d13fa0d0ec.tar.gz
Instead of initializing unknown sections en-masse during objfmt_output(),
add new objfmt interface function init_new_section() to initialize as we go. This fixes several issues, primarily with debug formats that create sections. Reported by: Brian Gladman svn path=/trunk/yasm/; revision=2310
Diffstat (limited to 'libyasm')
-rw-r--r--libyasm/objfmt.h15
-rw-r--r--libyasm/section.c3
2 files changed, 18 insertions, 0 deletions
diff --git a/libyasm/objfmt.h b/libyasm/objfmt.h
index d30e75e2..6abba74d 100644
--- a/libyasm/objfmt.h
+++ b/libyasm/objfmt.h
@@ -108,6 +108,11 @@ struct yasm_objfmt_module {
*/
yasm_section * (*add_default_section) (yasm_object *object);
+ /** Module-level implementation of yasm_objfmt_init_new_section().
+ * Call yasm_objfmt_init_new_section() instead of calling this function.
+ */
+ void (*init_new_section) (yasm_section *section, unsigned long line);
+
/** Module-level implementation of yasm_objfmt_section_switch().
* Call yasm_objfmt_section_switch() instead of calling this function.
*/
@@ -156,6 +161,13 @@ void yasm_objfmt_destroy(/*@only@*/ yasm_objfmt *objfmt);
*/
yasm_section *yasm_objfmt_add_default_section(yasm_object *object);
+/** Initialize the object-format specific portion of a section. Called
+ * by yasm_object_get_general(); in general should not be directly called.
+ * \param section section
+ * \param line virtual line (from yasm_linemap)
+ */
+void yasm_objfmt_init_new_section(yasm_object *object, unsigned long line);
+
/** Switch object file sections. The first val of the valparams should
* be the section name. Calls yasm_object_get_general() to actually get
* the section.
@@ -196,6 +208,9 @@ yasm_section *yasm_objfmt_add_default_section(yasm_object *object);
#define yasm_objfmt_add_default_section(object) \
((yasm_objfmt_base *)((object)->objfmt))->module->add_default_section \
(object)
+#define yasm_objfmt_init_new_section(section, line) \
+ ((yasm_objfmt_base *)((object)->objfmt))->module->init_new_section \
+ (section, line)
#define yasm_objfmt_get_special_sym(object, name, parser) \
((yasm_objfmt_base *)((object)->objfmt))->module->get_special_sym \
(object, name, parser)
diff --git a/libyasm/section.c b/libyasm/section.c
index 3271e391..bb796308 100644
--- a/libyasm/section.c
+++ b/libyasm/section.c
@@ -346,6 +346,9 @@ yasm_object_get_general(yasm_object *object, const char *name,
s->res_only = res_only;
s->def = 0;
+ /* Initialize object format specific data */
+ yasm_objfmt_init_new_section(s, line);
+
*isnew = 1;
return s;
}