Skip to content

Commit 91aaed3

Browse files
committed
libbpf: Fix output .symtab byte-order during linking
JIRA: https://issues.redhat.com/browse/RHEL-85485 commit f896b4a Author: Tony Ambardar <tony.ambardar@gmail.com> Date: Mon Sep 16 01:37:42 2024 -0700 libbpf: Fix output .symtab byte-order during linking 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: faf6ed3 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/87868bfeccf3f51aec61260073f8778e9077050a.1726475448.git.tony.ambardar@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Viktor Malik <vmalik@redhat.com>
1 parent 2f38d36 commit 91aaed3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/lib/bpf/linker.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ static int init_output_elf(struct bpf_linker *linker, const char *file)
396396
pr_warn_elf("failed to create SYMTAB data");
397397
return -EINVAL;
398398
}
399+
/* Ensure libelf translates byte-order of symbol records */
400+
sec->data->d_type = ELF_T_SYM;
399401

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

0 commit comments

Comments
 (0)