mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-07 17:46:58 +08:00
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>
This commit is contained in:
parent
e1eb7b8880
commit
615ef1a6f8
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user