pahole: Adopt btf_encoder object instantiation from btf_encoder

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-06-08 14:55:43 -03:00
parent 0208952e8f
commit 5e1207754e
3 changed files with 15 additions and 19 deletions

View File

@ -668,8 +668,7 @@ void btf_encoder__delete(struct btf_encoder *encoder)
free(encoder);
}
int cu__encode_btf(struct cu *cu, struct btf *base_btf, int verbose, bool force,
bool skip_encoding_vars, const char *detached_btf_filename)
int cu__encode_btf(struct cu *cu, int verbose, bool force, bool skip_encoding_vars)
{
uint32_t type_id_off;
uint32_t core_id;
@ -681,14 +680,6 @@ int cu__encode_btf(struct cu *cu, struct btf *base_btf, int verbose, bool force,
btf_elf__verbose = verbose;
btf_elf__force = force;
if (!encoder) {
encoder = btf_encoder__new(cu, base_btf, skip_encoding_vars, verbose);
if (encoder == NULL) {
err = -1;
goto out;
}
}
type_id_off = btf__get_nr_types(encoder->btfe->btf);
if (!encoder->has_index_type) {
@ -875,11 +866,6 @@ int cu__encode_btf(struct cu *cu, struct btf *base_btf, int verbose, bool force,
break;
}
}
out:
if (err) {
btf_encoder__delete(encoder);
encoder = NULL;
}
return err;
}

View File

@ -57,7 +57,6 @@ void btf_encoder__delete(struct btf_encoder *encoder);
int btf_encoder__encode(struct btf_encoder *encoder, const char *detached_filename);
int cu__encode_btf(struct cu *cu, struct btf *base_btf, int verbose, bool force,
bool skip_encoding_vars, const char *detached_btf_filename);
int cu__encode_btf(struct cu *cu, int verbose, bool force, bool skip_encoding_vars);
#endif /* _BTF_ENCODER_H_ */

View File

@ -2465,8 +2465,19 @@ static enum load_steal_kind pahole_stealer(struct cu *cu,
goto filter_it;
if (btf_encode) {
if (cu__encode_btf(cu, conf_load->base_btf, global_verbose, btf_encode_force,
skip_encoding_btf_vars, detached_btf_filename)) {
/*
* FIXME:
*
* This should be really done at main(), but since in the current codebase only at this
* point we'll have cu->elf setup...
*/
if (!encoder) {
encoder = btf_encoder__new(cu, conf_load->base_btf, skip_encoding_btf_vars, global_verbose);
if (encoder == NULL)
return LSK__STOP_LOADING;
}
if (cu__encode_btf(cu, global_verbose, btf_encode_force, skip_encoding_btf_vars)) {
fprintf(stderr, "Encountered error while encoding BTF.\n");
exit(1);
}