summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2010-04-22 16:37:56 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2010-04-22 19:06:29 +0400
commit630f221b01f50232d41fc66ceade9b41b4cd1452 (patch)
tree053abfae01b1da7d8974ae1035f3bd54b4eb9c52
parent279d8f146a2ab657a018b4e31041b05e83e50958 (diff)
downloadnasm-630f221b01f50232d41fc66ceade9b41b4cd1452.tar.gz
nasm-630f221b01f50232d41fc66ceade9b41b4cd1452.tar.bz2
nasm-630f221b01f50232d41fc66ceade9b41b4cd1452.zip
bin: Implement sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--output/outbin.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/output/outbin.c b/output/outbin.c
index 260d99d..030ec79 100644
--- a/output/outbin.c
+++ b/output/outbin.c
@@ -999,6 +999,27 @@ static int bin_read_attribute(char **line, int *attribute,
return 1;
}
+static void bin_sectalign(int32_t seg, unsigned int value)
+{
+ struct Section *s = find_section_by_index(seg);
+
+ if (!s || !is_power2(value))
+ return;
+
+ /*
+ * Extended bin format non-default alignment
+ * is forbidden
+ */
+ if (!format_mode && (!strcmp(s->name, ".text")))
+ return;
+
+ if (value > s->align)
+ s->align = value;
+
+ if (!(s->flags & ALIGN_DEFINED))
+ s->flags |= ALIGN_DEFINED;
+}
+
static void bin_assign_attributes(struct Section *sec, char *astring)
{
int attribute, check;
@@ -1672,7 +1693,7 @@ struct ofmt of_bin = {
bin_out,
bin_deflabel,
bin_secname,
- null_sectalign,
+ bin_sectalign,
bin_segbase,
bin_directive,
bin_filename,
@@ -1691,7 +1712,7 @@ struct ofmt of_ith = {
bin_out,
bin_deflabel,
bin_secname,
- null_sectalign,
+ bin_sectalign,
bin_segbase,
bin_directive,
ith_filename,
@@ -1710,7 +1731,7 @@ struct ofmt of_srec = {
bin_out,
bin_deflabel,
bin_secname,
- null_sectalign,
+ bin_sectalign,
bin_segbase,
bin_directive,
srec_filename,