@@ -64,6 +64,7 @@ struct btf_encoder {
struct btf *btf;
struct cu *cu;
struct gobuffer percpu_secinfo;
+ const char *source_filename;
const char *filename;
struct elf_symtab *symtab;
uint32_t type_id_off;
@@ -1648,6 +1649,7 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam
if (encoder) {
encoder->raw_output = detached_filename != NULL;
+ encoder->source_filename = strdup(cu->filename);
encoder->filename = strdup(encoder->raw_output ? detached_filename : cu->filename);
if (encoder->filename == NULL)
goto out_delete;
@@ -1730,6 +1732,7 @@ void btf_encoder__delete(struct btf_encoder *encoder)
btf_encoders__delete(encoder);
__gobuffer__delete(&encoder->percpu_secinfo);
zfree(&encoder->filename);
+ zfree(&encoder->source_filename);
btf__free(encoder->btf);
encoder->btf = NULL;
elf_symtab__delete(encoder->symtab);
During detached BTF encoding, the input file is not necessarily the same as the output file. So save them separately. This matters when we need to look at the input file again, such as for kfunc tagging. Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> --- btf_encoder.c | 3 +++ 1 file changed, 3 insertions(+)