Re: [PATCH v2 dwarves 3/5] btf_encoder: collect elf_functions in pre_cus__load_module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2024-10-09 at 23:35 +0000, Ihor Solodrai wrote:

[...]

> diff --git a/btf_encoder.c b/btf_encoder.c

[...]

> +static struct elf_functions *elf_functions__new(Elf *elf)
> +{

I think this function should be renamed to elf_functions_list_init()
and it should return int.

[...]

> @@ -2071,6 +2139,13 @@ int btf_encoder__encode(struct btf_encoder *encoder)
>  #endif
>  		err = btf_encoder__write_elf(encoder, encoder->btf, BTF_ELF_SEC);
>  	}
> +
> +	// TODO: after moving encoders to shared elf_functions,
> +	// replace elf_functions__get(encoder->functions.elf) here
> +	// with encoder->functions
> +	// The pointer to shared elf_functions will be set in btf_encoder__new

Nit: the TODO comment is not necessary here, as described change is
     done later in the patch.

> +	elf_functions__delete(elf_functions__get(encoder->functions.elf));
> +
>  	return err;
>  }
>  
> @@ -2369,6 +2444,7 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam
>  			goto out;
>  		}
>  		encoder->functions.symtab = encoder->symtab;
> +		encoder->functions.elf = cu->elf;

This line is removed in a subsequent patches, is it needed because of
the __delete call in the hunk above? Note, that if you want to account
for situation when multiple ELFs are processed the cu->elf might
change, so that __delete call would only delete elf_functions for the
last processed cu->elf.

I think that elf_functions should be deleted in main() at the same
level where btf_encoder__add_saved_funcs() is called.

>  
>  		/* index the ELF sections for later lookup */
>  

[...]






[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux