summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2016-02-16 11:42:13 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2016-02-16 11:42:13 -0800
commit615ef1a6f848d33cf90f70c77e7934fbd56fcd42 (patch)
treecd259fb9a566ef1e5bf883ab2b02992302022978
parente1eb7b88803014a67f0c10478bb4a11d15ffb5a5 (diff)
downloadnasm-615ef1a6f848d33cf90f70c77e7934fbd56fcd42.tar.gz
outmacho: Only test for MAX_SECT at the point sections are laid out
Exceeding MAX_SECT is not a warning, it is a fatal error. However, there is no point to test for it until we already process all the sections. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--output/outmacho.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/output/outmacho.c b/output/outmacho.c
index 60b6f0c9..f8122f05 100644
--- a/output/outmacho.c
+++ b/output/outmacho.c
@@ -317,14 +317,10 @@ static uint8_t get_section_fileindex_by_index(const int32_t index)
struct section *s;
uint8_t i = 1;
- for (s = sects; s != NULL && i < MAX_SECT; s = s->next, ++i)
+ for (s = sects; s != NULL; s = s->next, ++i)
if (index == s->index)
return i;
- if (i == MAX_SECT)
- nasm_error(ERR_WARNING,
- "too many sections (>255) - clipped by fileindex");
-
return NO_SECT;
}
@@ -990,6 +986,11 @@ static void macho_calculate_sizes (void)
head_sizeofcmds += MACHO_SYMCMD_SIZE;
}
+ if (seg_nsects > MAX_SECT) {
+ nasm_error(ERR_FATAL, "MachO output is limited to %d sections\n",
+ MAX_SECT);
+ }
+
/* Create a table of sections by file index to avoid linear search */
sectstab = nasm_malloc((seg_nsects + 1) * sizeof(*sectstab));
sectstab[0] = NULL;