From 630f221b01f50232d41fc66ceade9b41b4cd1452 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 22 Apr 2010 16:37:56 +0400 Subject: bin: Implement sectalign handler Signed-off-by: Cyrill Gorcunov --- output/outbin.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'output') 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, -- cgit v1.2.3