diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2020-12-09 17:08:45 +0100 | 
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2020-12-09 17:08:45 +0100 | 
| commit | 2b3c99ee6389d33aff91d9e7a55465d7d1332bbd (patch) | |
| tree | 9e1e5d839d80c95854007c958f2c367290bf1090 /tools/lib/bpf/libbpf.c | |
| parent | 97d62caa32d6d79dadae3f8d19af5c92ea9a589a (diff) | |
| parent | 31784cff7ee073b34d6eddabb95e3be2880a425c (diff) | |
Merge branch 'locking/rwsem'
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 23 | 
1 files changed, 13 insertions, 10 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 313034117070..28baee7ba1ca 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -560,8 +560,6 @@ bpf_object__init_prog(struct bpf_object *obj, struct bpf_program *prog,  		      const char *name, size_t sec_idx, const char *sec_name,  		      size_t sec_off, void *insn_data, size_t insn_data_sz)  { -	int i; -  	if (insn_data_sz == 0 || insn_data_sz % BPF_INSN_SZ || sec_off % BPF_INSN_SZ) {  		pr_warn("sec '%s': corrupted program '%s', offset %zu, size %zu\n",  			sec_name, name, sec_off, insn_data_sz); @@ -600,13 +598,6 @@ bpf_object__init_prog(struct bpf_object *obj, struct bpf_program *prog,  		goto errout;  	memcpy(prog->insns, insn_data, insn_data_sz); -	for (i = 0; i < prog->insns_cnt; i++) { -		if (insn_is_subprog_call(&prog->insns[i])) { -			obj->has_subcalls = true; -			break; -		} -	} -  	return 0;  errout:  	pr_warn("sec '%s': failed to allocate memory for prog '%s'\n", sec_name, name); @@ -3280,7 +3271,19 @@ bpf_object__find_program_by_title(const struct bpf_object *obj,  static bool prog_is_subprog(const struct bpf_object *obj,  			    const struct bpf_program *prog)  { -	return prog->sec_idx == obj->efile.text_shndx && obj->has_subcalls; +	/* For legacy reasons, libbpf supports an entry-point BPF programs +	 * without SEC() attribute, i.e., those in the .text section. But if +	 * there are 2 or more such programs in the .text section, they all +	 * must be subprograms called from entry-point BPF programs in +	 * designated SEC()'tions, otherwise there is no way to distinguish +	 * which of those programs should be loaded vs which are a subprogram. +	 * Similarly, if there is a function/program in .text and at least one +	 * other BPF program with custom SEC() attribute, then we just assume +	 * .text programs are subprograms (even if they are not called from +	 * other programs), because libbpf never explicitly supported mixing +	 * SEC()-designated BPF programs and .text entry-point BPF programs. +	 */ +	return prog->sec_idx == obj->efile.text_shndx && obj->nr_programs > 1;  }  struct bpf_program *  | 
