On Fri, 2024-08-30 at 00:29 -0700, Tony Ambardar wrote:
> Object linking output data uses the default ELF_T_BYTE type for '.symtab'
> section data, which disables any libelf-based translation. Explicitly set
> the ELF_T_SYM type for output to restore libelf's byte-order conversion,
> noting that input '.symtab' data is already correctly translated.
> 
> Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs")
> Signed-off-by: Tony Ambardar <tony.ambar...@gmail.com>
> ---
>  tools/lib/bpf/linker.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c
> index 9cd3d4109788..7489306cd6f7 100644
> --- a/tools/lib/bpf/linker.c
> +++ b/tools/lib/bpf/linker.c
> @@ -396,6 +396,8 @@ static int init_output_elf(struct bpf_linker *linker, 
> const char *file)
>               pr_warn_elf("failed to create SYMTAB data");
>               return -EINVAL;
>       }
> +     /* Ensure libelf translates byte-order of symbol records */
> +     sec->data->d_type = ELF_T_SYM;

I tried grepping through libelf to find out how this affects things,
and identified that it is primarily used by 
elfutils/libelf/gelf_xlatetof.c:gelf_xlatetof(),
which is an interface function and we don't seem to use it.
It is also used by dwfl_* functions while applying relocations,
but we don't use that either.

Could you please elaborate a bit on effects of this change?

>  
>       str_off = strset__add_str(linker->strtab_strs, sec->sec_name);
>       if (str_off < 0)


Reply via email to