}
sscanf(&lpszLine[bytes_read], "%2" SCNx32 , &checksum);
- bytes_read += 2;
if ((uint8_t)checksum != (uint8_t)(~cal_checksum + 1))
{
if ((field32(elf, elf->segments[i].p_type) == PT_LOAD) && (field32(elf, elf->segments[i].p_filesz) != 0))
image->num_sections++;
+ assert(image->num_sections > 0);
+
/**
* some ELF linkers produce binaries with *all* the program header
* p_paddr fields zero (there can be however one loadable segment
LOG_ERROR("cannot read ELF segment content, read failed");
return retval;
}
- buffer += read_size;
size -= read_size;
- offset += read_size;
*size_read += read_size;
/* need more data ? */
if (!size)
/* account for checksum, will always be 0xFF */
sscanf(&lpszLine[bytes_read], "%2" SCNx32 , &checksum);
cal_checksum += (uint8_t)checksum;
- bytes_read += 2;
if (cal_checksum != 0xFF)
{
{
LOG_DEBUG("read past end of section: 0x%8.8" PRIx32 " + 0x%8.8" PRIx32 " > 0x%8.8" PRIx32 "",
offset, size, image->sections[section].size);
- return ERROR_INVALID_ARGUMENTS;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
if (image->type == IMAGE_BINARY)
/* only one section in a plain binary */
if (section != 0)
- return ERROR_INVALID_ARGUMENTS;
+ return ERROR_COMMAND_SYNTAX_ERROR;
/* seek to offset */
if ((retval = fileio_seek(&image_binary->fileio, offset)) != ERROR_OK)
/* only image builder supports adding sections */
if (image->type != IMAGE_BUILDER)
- return ERROR_INVALID_ARGUMENTS;
+ return ERROR_COMMAND_SYNTAX_ERROR;
/* see if there's a previous section */
if (image->num_sections)