- size_t disasm_size = binary.disasm_string ? strlen(binary.disasm_string) : 0;
- size_t llvm_ir_size = binary.llvm_ir_string ? strlen(binary.llvm_ir_string) : 0;
- size_t alloc_size = sizeof(struct radv_shader_binary_legacy) + binary.code_size +
- disasm_size + llvm_ir_size + 2;
- struct radv_shader_binary_legacy *lbin = calloc(1, alloc_size);
- memcpy(lbin->data, binary.code, binary.code_size);
- if (binary.llvm_ir_string)
- memcpy(lbin->data + binary.code_size, binary.llvm_ir_string, llvm_ir_size + 1);
- if (binary.disasm_string)
- memcpy(lbin->data + binary.code_size + llvm_ir_size + 1, binary.disasm_string, disasm_size + 1);
-
- lbin->base.type = RADV_BINARY_TYPE_LEGACY;
- lbin->base.stage = stage;
- lbin->base.total_size = alloc_size;
- lbin->config = config;
- lbin->code_size = binary.code_size;
- lbin->llvm_ir_size = llvm_ir_size;
- lbin->disasm_size = disasm_size;
- *rbinary = &lbin->base;
-
- free(binary.code);
- free(binary.config);
- free(binary.rodata);
- free(binary.global_symbol_offsets);
- free(binary.relocs);
- free(binary.disasm_string);
- free(binary.llvm_ir_string);
+ size_t llvm_ir_size = llvm_ir_string ? strlen(llvm_ir_string) : 0;
+ size_t alloc_size = sizeof(struct radv_shader_binary_rtld) + elf_size + llvm_ir_size + 1;
+ struct radv_shader_binary_rtld *rbin = calloc(1, alloc_size);
+ memcpy(rbin->data, elf_buffer, elf_size);
+ if (llvm_ir_string)
+ memcpy(rbin->data + elf_size, llvm_ir_string, llvm_ir_size + 1);
+
+ rbin->base.type = RADV_BINARY_TYPE_RTLD;
+ rbin->base.stage = stage;
+ rbin->base.total_size = alloc_size;
+ rbin->elf_size = elf_size;
+ rbin->llvm_ir_size = llvm_ir_size;
+ *rbinary = &rbin->base;
+
+ free(llvm_ir_string);
+ free(elf_buffer);