summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-02-12 03:23:25 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-02-12 03:23:25 -0800
commitb13df02490700899de69b062d0704e97d0798543 (patch)
tree50b1a83d32347ab7385b55776015cd875381e780
parent7dcd1a154921d8cce393e276aea643d3439bcef7 (diff)
downloadnasm-b13df02490700899de69b062d0704e97d0798543.tar.gz
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 <hpa@zytor.com>
-rw-r--r--output/outmac.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/output/outmac.c b/output/outmac.c
index 1a1896d8..9c6e935c 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)