}
}
-void ac_elf_read(const char *elf_data, unsigned elf_size,
+bool ac_elf_read(const char *elf_data, unsigned elf_size,
struct ac_shader_binary *binary)
{
char *elf_buffer;
Elf_Data *symbols = NULL, *relocs = NULL;
size_t section_str_index;
unsigned symbol_sh_link = 0;
+ bool success = true;
/* One of the libelf implementations
* (http://www.mr511.de/software/english.htm) requires calling
GElf_Shdr section_header;
if (gelf_getshdr(section, §ion_header) != §ion_header) {
fprintf(stderr, "Failed to read ELF section header\n");
- return;
+ success = false;
+ break;
}
name = elf_strptr(elf, section_str_index, section_header.sh_name);
if (!strcmp(name, ".text")) {
} else if (!strcmp(name, ".AMDGPU.config")) {
section_data = elf_getdata(section, section_data);
binary->config_size = section_data->d_size;
+ if (!binary->config_size) {
+ fprintf(stderr, ".AMDGPU.config is empty!\n");
+ success = false;
+ break;
+ }
binary->config = MALLOC(binary->config_size * sizeof(unsigned char));
memcpy(binary->config, section_data->d_buf, binary->config_size);
} else if (!strcmp(name, ".AMDGPU.disasm")) {
binary->global_symbol_count = 1;
binary->config_size_per_symbol = binary->config_size;
}
+ return success;
}
const unsigned char *ac_shader_binary_config_start(
* Parse the elf binary stored in \p elf_data and create a
* ac_shader_binary object.
*/
-void ac_elf_read(const char *elf_data, unsigned elf_size,
+bool ac_elf_read(const char *elf_data, unsigned elf_size,
struct ac_shader_binary *binary);
/**
buffer_size = LLVMGetBufferSize(out_buffer);
buffer_data = LLVMGetBufferStart(out_buffer);
- ac_elf_read(buffer_data, buffer_size, binary);
+ if (!ac_elf_read(buffer_data, buffer_size, binary)) {
+ fprintf(stderr, "radeonsi: cannot read an ELF shader binary\n");
+ diag.retval = 1;
+ }
/* Clean up */
LLVMDisposeMemoryBuffer(out_buffer);