Commit a18f7214 authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by Andrii Nakryiko

libbpf: Rename RELO_EXTERN_VAR/FUNC.

RELO_EXTERN_VAR/FUNC names are not correct anymore. RELO_EXTERN_VAR represent
ksym symbol in ld_imm64 insn. It can point to kernel variable or kfunc.
Rename RELO_EXTERN_VAR->RELO_EXTERN_LD64 and RELO_EXTERN_FUNC->RELO_EXTERN_CALL
to match what they actually represent.
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: default avatarDavid Vernet <void@manifault.com>
Link: https://lore.kernel.org/bpf/20230321203854.3035-2-alexei.starovoitov@gmail.com
parent 9a321fd3
...@@ -315,8 +315,8 @@ enum reloc_type { ...@@ -315,8 +315,8 @@ enum reloc_type {
RELO_LD64, RELO_LD64,
RELO_CALL, RELO_CALL,
RELO_DATA, RELO_DATA,
RELO_EXTERN_VAR, RELO_EXTERN_LD64,
RELO_EXTERN_FUNC, RELO_EXTERN_CALL,
RELO_SUBPROG_ADDR, RELO_SUBPROG_ADDR,
RELO_CORE, RELO_CORE,
}; };
...@@ -4009,9 +4009,9 @@ static int bpf_program__record_reloc(struct bpf_program *prog, ...@@ -4009,9 +4009,9 @@ static int bpf_program__record_reloc(struct bpf_program *prog,
pr_debug("prog '%s': found extern #%d '%s' (sym %d) for insn #%u\n", pr_debug("prog '%s': found extern #%d '%s' (sym %d) for insn #%u\n",
prog->name, i, ext->name, ext->sym_idx, insn_idx); prog->name, i, ext->name, ext->sym_idx, insn_idx);
if (insn->code == (BPF_JMP | BPF_CALL)) if (insn->code == (BPF_JMP | BPF_CALL))
reloc_desc->type = RELO_EXTERN_FUNC; reloc_desc->type = RELO_EXTERN_CALL;
else else
reloc_desc->type = RELO_EXTERN_VAR; reloc_desc->type = RELO_EXTERN_LD64;
reloc_desc->insn_idx = insn_idx; reloc_desc->insn_idx = insn_idx;
reloc_desc->sym_off = i; /* sym_off stores extern index */ reloc_desc->sym_off = i; /* sym_off stores extern index */
return 0; return 0;
...@@ -5855,7 +5855,7 @@ bpf_object__relocate_data(struct bpf_object *obj, struct bpf_program *prog) ...@@ -5855,7 +5855,7 @@ bpf_object__relocate_data(struct bpf_object *obj, struct bpf_program *prog)
relo->map_idx, map); relo->map_idx, map);
} }
break; break;
case RELO_EXTERN_VAR: case RELO_EXTERN_LD64:
ext = &obj->externs[relo->sym_off]; ext = &obj->externs[relo->sym_off];
if (ext->type == EXT_KCFG) { if (ext->type == EXT_KCFG) {
if (obj->gen_loader) { if (obj->gen_loader) {
...@@ -5877,7 +5877,7 @@ bpf_object__relocate_data(struct bpf_object *obj, struct bpf_program *prog) ...@@ -5877,7 +5877,7 @@ bpf_object__relocate_data(struct bpf_object *obj, struct bpf_program *prog)
} }
} }
break; break;
case RELO_EXTERN_FUNC: case RELO_EXTERN_CALL:
ext = &obj->externs[relo->sym_off]; ext = &obj->externs[relo->sym_off];
insn[0].src_reg = BPF_PSEUDO_KFUNC_CALL; insn[0].src_reg = BPF_PSEUDO_KFUNC_CALL;
if (ext->is_set) { if (ext->is_set) {
...@@ -6115,7 +6115,7 @@ bpf_object__reloc_code(struct bpf_object *obj, struct bpf_program *main_prog, ...@@ -6115,7 +6115,7 @@ bpf_object__reloc_code(struct bpf_object *obj, struct bpf_program *main_prog,
continue; continue;
relo = find_prog_insn_relo(prog, insn_idx); relo = find_prog_insn_relo(prog, insn_idx);
if (relo && relo->type == RELO_EXTERN_FUNC) if (relo && relo->type == RELO_EXTERN_CALL)
/* kfunc relocations will be handled later /* kfunc relocations will be handled later
* in bpf_object__relocate_data() * in bpf_object__relocate_data()
*/ */
...@@ -7072,14 +7072,14 @@ static int bpf_program_record_relos(struct bpf_program *prog) ...@@ -7072,14 +7072,14 @@ static int bpf_program_record_relos(struct bpf_program *prog)
struct extern_desc *ext = &obj->externs[relo->sym_off]; struct extern_desc *ext = &obj->externs[relo->sym_off];
switch (relo->type) { switch (relo->type) {
case RELO_EXTERN_VAR: case RELO_EXTERN_LD64:
if (ext->type != EXT_KSYM) if (ext->type != EXT_KSYM)
continue; continue;
bpf_gen__record_extern(obj->gen_loader, ext->name, bpf_gen__record_extern(obj->gen_loader, ext->name,
ext->is_weak, !ext->ksym.type_id, ext->is_weak, !ext->ksym.type_id,
BTF_KIND_VAR, relo->insn_idx); BTF_KIND_VAR, relo->insn_idx);
break; break;
case RELO_EXTERN_FUNC: case RELO_EXTERN_CALL:
bpf_gen__record_extern(obj->gen_loader, ext->name, bpf_gen__record_extern(obj->gen_loader, ext->name,
ext->is_weak, false, BTF_KIND_FUNC, ext->is_weak, false, BTF_KIND_FUNC,
relo->insn_idx); relo->insn_idx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment