From: nasm-bot f. H. P. A. <hp...@zy...> - 2016-02-12 11:27:17
|
Commit-ID: b13df02490700899de69b062d0704e97d0798543 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=b13df02490700899de69b062d0704e97d0798543 Author: H. Peter Anvin <hp...@zy...> AuthorDate: Fri, 12 Feb 2016 03:23:25 -0800 Committer: H. Peter Anvin <hp...@zy...> CommitDate: Fri, 12 Feb 2016 03:23:25 -0800 outmac: allow section alignment to be declared more than once Allow section alignment to be declared more than once, with different values. The strictest alignment value via either a section or sectalign directive becomes the controlling parameter. Signed-off-by: H. Peter Anvin <hp...@zy...> --- output/outmac.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/output/outmac.c b/output/outmac.c index 1a1896d..9c6e935 100644 --- a/output/outmac.c +++ b/output/outmac.c @@ -707,14 +707,14 @@ static int32_t macho_section(char *name, int pass, int *bits) newAlignment = alignlog2_32(value); if (0 != *end) { - nasm_error(ERR_PANIC, + nasm_error(ERR_FATAL, "unknown or missing alignment value \"%s\" " "specified for section \"%s\"", currentAttribute + 6, name); return NO_SEG; } else if (0 > newAlignment) { - nasm_error(ERR_PANIC, + nasm_error(ERR_FATAL, "alignment of %d (for section \"%s\") is not " "a power of two", value, @@ -722,24 +722,12 @@ static int32_t macho_section(char *name, int pass, int *bits) return NO_SEG; } - if ((-1 != originalIndex) - && (s->align != newAlignment) - && (s->align != -1)) { - nasm_error(ERR_PANIC, - "section \"%s\" has already been specified " - "with alignment %d, conflicts with new " - "alignment of %d", - name, - (1 << s->align), - value); - return NO_SEG; - } - - s->align = newAlignment; + if (s->align < newAlignment) + s->align = newAlignment; } else if (!nasm_stricmp("data", currentAttribute)) { /* Do nothing; 'data' is implicit */ } else { - nasm_error(ERR_PANIC, + nasm_error(ERR_FATAL, "unknown section attribute %s for section %s", currentAttribute, name); @@ -752,7 +740,7 @@ static int32_t macho_section(char *name, int pass, int *bits) } } - nasm_error(ERR_PANIC, "invalid section name %s", name); + nasm_error(ERR_FATAL, "invalid section name %s", name); return NO_SEG; } @@ -845,6 +833,7 @@ static void macho_symdef(char *name, int32_t section, int64_t offset, static void macho_sectalign(int32_t seg, unsigned int value) { struct section *s; + int align; list_for_each(s, sects) { if (s->index == seg) @@ -854,9 +843,9 @@ static void macho_sectalign(int32_t seg, unsigned int value) if (!s || !is_power2(value)) return; - value = alignlog2_32(value); - if (s->align < (int)value) - s->align = value; + align = alignlog2_32(value); + if (s->align < align); + s->align = align; } static int32_t macho_segbase(int32_t section) |