Commit-ID: 615ef1a6f848d33cf90f70c77e7934fbd56fcd42
Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=615ef1a6f848d33cf90f70c77e7934fbd56fcd42
Author: H. Peter Anvin <hp...@li...>
AuthorDate: Tue, 16 Feb 2016 11:42:13 -0800
Committer: H. Peter Anvin <hp...@li...>
CommitDate: Tue, 16 Feb 2016 11:42:13 -0800
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 <hp...@li...>
---
output/outmacho.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/output/outmacho.c b/output/outmacho.c
index 60b6f0c..f8122f0 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;
|