dst_sec
Elf_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info;
if (!(dst_sec->sh_flags & SHF_EXECINSTR))
Elf_Shdr *dst_sec = sechdrs + sechdrs[i].sh_info;
if (!(dst_sec->sh_flags & SHF_EXECINSTR))
static int init_sec(struct bpf_linker *linker, struct dst_sec *dst_sec, struct src_sec *src_sec)
dst_sec->sec_sz = 0;
dst_sec->sec_idx = 0;
dst_sec->ephemeral = src_sec->ephemeral;
dst_sec->scn = scn;
dst_sec->shdr = shdr;
dst_sec->data = data;
dst_sec->sec_idx = elf_ndxscn(scn);
static struct dst_sec *find_dst_sec_by_name(struct bpf_linker *linker, const char *sec_name)
struct dst_sec *sec;
static bool secs_match(struct dst_sec *dst, struct src_sec *src)
static bool sec_content_is_same(struct dst_sec *dst_sec, struct src_sec *src_sec)
if (dst_sec->sec_sz != src_sec->shdr->sh_size)
if (memcmp(dst_sec->raw_data, src_sec->data->d_buf, dst_sec->sec_sz) != 0)
static bool is_exec_sec(struct dst_sec *sec)
static int extend_sec(struct bpf_linker *linker, struct dst_sec *dst, struct src_sec *src)
struct dst_sec *dst_sec;
dst_sec = find_dst_sec_by_name(linker, src_sec->sec_name);
if (!dst_sec) {
dst_sec = add_dst_sec(linker, src_sec->sec_name);
if (!dst_sec)
err = init_sec(linker, dst_sec, src_sec);
if (!secs_match(dst_sec, src_sec)) {
if (!sec_content_is_same(dst_sec, src_sec)) {
src_sec->dst_id = dst_sec->id;
src_sec->dst_id = dst_sec->id;
err = extend_sec(linker, dst_sec, src_sec);
struct dst_sec *symtab = &linker->secs[linker->symtab_sec_idx];
struct dst_sec *secs;
struct dst_sec *dst_sec = NULL;
dst_sec = &linker->secs[src_sec->dst_id];
if (sym_type == STT_SECTION && dst_sec->sec_sym_idx) {
obj->sym_map[src_sym_idx] = dst_sec->sec_sym_idx;
dst_sec = &linker->secs[src_sec->dst_id];
struct dst_sec *sec = &linker->secs[i];
dst_sym->st_shndx = dst_sec->sec_idx;
glob_sym->sec_id = dst_sec->id;
dst_sym->st_shndx = dst_sec ? dst_sec->sec_idx : sym->st_shndx;
if (sym_type == STT_SECTION && dst_sec) {
dst_sec->sec_sym_idx = dst_sym_idx;
glob_sym->sec_id = dst_sec ? dst_sec->id : 0;
struct dst_sec *dst_sec, *dst_linked_sec;
dst_sec = find_dst_sec_by_name(linker, src_sec->sec_name);
if (!dst_sec) {
dst_sec = add_dst_sec(linker, src_sec->sec_name);
if (!dst_sec)
err = init_sec(linker, dst_sec, src_sec);
} else if (!secs_match(dst_sec, src_sec)) {
dst_sec->shdr->sh_link = linker->symtab_sec_idx;
dst_sec->shdr->sh_info = dst_linked_sec->sec_idx;
src_sec->dst_id = dst_sec->id;
err = extend_sec(linker, dst_sec, src_sec);
dst_rel = dst_sec->raw_data + src_sec->dst_off;
struct dst_sec *dst_sec;
dst_sec = &linker->secs[src_sec->dst_id];
dst_sec->has_btf = true;
void *sec_vars = dst_sec->sec_vars;
if (glob_sym->sec_id != dst_sec->id) {
name, glob_sym->sec_id, dst_sec->id);
dst_var = &dst_sec->sec_vars[glob_sym->var_idx];
dst_sec->sec_var_cnt + 1,
sizeof(*dst_sec->sec_vars));
dst_sec->sec_vars = sec_vars;
dst_sec->sec_var_cnt++;
dst_var = &dst_sec->sec_vars[dst_sec->sec_var_cnt - 1];
glob_sym->var_idx = dst_sec->sec_var_cnt - 1;
struct dst_sec *dst_sec;
dst_sec = &linker->secs[src_sec->dst_id];
if (dst_sec->func_info.rec_sz == 0)
dst_sec->func_info.rec_sz = rec_sz;
if (dst_sec->func_info.rec_sz != rec_sz) {
dst_rec = add_btf_ext_rec(&dst_sec->func_info, src_rec);
dst_sec = &linker->secs[src_sec->dst_id];
if (dst_sec->line_info.rec_sz == 0)
dst_sec->line_info.rec_sz = rec_sz;
if (dst_sec->line_info.rec_sz != rec_sz) {
dst_rec = add_btf_ext_rec(&dst_sec->line_info, src_rec);
dst_sec = &linker->secs[src_sec->dst_id];
if (dst_sec->core_relo_info.rec_sz == 0)
dst_sec->core_relo_info.rec_sz = rec_sz;
if (dst_sec->core_relo_info.rec_sz != rec_sz) {
dst_rec = add_btf_ext_rec(&dst_sec->core_relo_info, src_rec);
struct dst_sec *sec;
struct dst_sec *sec = &linker->secs[i];
struct dst_sec *sec = &linker->secs[i];
struct dst_sec *sec = &linker->secs[i];
struct dst_sec *sec = &linker->secs[i];
struct dst_sec *sec = &linker->secs[i];
static struct dst_sec *add_dst_sec(struct bpf_linker *linker, const char *sec_name)
struct dst_sec *secs = linker->secs, *sec;
struct dst_sec *symtab = &linker->secs[linker->symtab_sec_idx];
struct dst_sec *sec;