aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2010-04-25 22:00:15 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2010-04-25 22:00:15 +0400
commita20b668add234cb388e1802e217ef48257fa9e12 (patch)
treeae662d4d8331e2f0f66cd2064b901f8e5391119a
parent573d25fe92fac7209c0695c5904dc5b067cf902e (diff)
downloadnasm-test-a20b668add234cb388e1802e217ef48257fa9e12.tar.gz
nasm-test-a20b668add234cb388e1802e217ef48257fa9e12.tar.xz
nasm-test-a20b668add234cb388e1802e217ef48257fa9e12.zip
obj: Implement sectalign helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--output/outobj.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/output/outobj.c b/output/outobj.c
index 053ca4fb..2453c9fb 100644
--- a/output/outobj.c
+++ b/output/outobj.c
@@ -1777,6 +1777,49 @@ static int obj_directive(enum directives directive, char *value, int pass)
}
}
+static void obj_sectalign(int32_t seg, unsigned int value)
+{
+ struct Segment *s;
+
+ list_for_each(s, seghead) {
+ if (s->index == seg)
+ break;
+ }
+
+ /*
+ * it should not be too big value
+ * and applied on non-absolute sections
+ */
+ if (!s || !is_power2(value) ||
+ value > 4096 || s->align >= SEG_ABS)
+ return;
+
+ /*
+ * FIXME: No code duplication please
+ * consider making helper for this
+ * mapping since section handler has
+ * to do the same
+ */
+ switch (value) {
+ case 8:
+ value = 16;
+ break;
+ case 32:
+ case 64:
+ case 128:
+ value = 256;
+ break;
+ case 512:
+ case 1024:
+ case 2048:
+ value = 4096;
+ break;
+ }
+
+ if (s->align < (int)value)
+ s->align = value;
+}
+
static int32_t obj_segbase(int32_t segment)
{
struct Segment *seg;
@@ -2559,7 +2602,7 @@ struct ofmt of_obj = {
obj_out,
obj_deflabel,
obj_segment,
- null_sectalign,
+ obj_sectalign,
obj_segbase,
obj_directive,
obj_filename,