Fix segmentation fault if a NOBITS section is specified for output

This commit is contained in:
Mario Hüttel 2023-01-04 15:07:01 +01:00
parent e09a07b3d3
commit 2fca25d4c0
1 changed files with 5 additions and 0 deletions

View File

@ -534,6 +534,11 @@ int elf_patch_write_crcs_to_section(elfpatch_handle_t *ep, const char *section,
/* Get data object of section */
output_sec_data = elf_getdata(output_section->scn, NULL);
sec_bytes = (uint8_t *)output_sec_data->d_buf;
if (!sec_bytes) {
print_err("Output section '%s' does not contain loadable data. It has to be allocated in the ELF file\n",
section);
goto ret_err;
}
/* Check the start and end magics */
if (check_start_magic) {