[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YCbzLrtukxH3r4Hf@krava>
Date: Fri, 12 Feb 2021 22:29:18 +0100
From: Jiri Olsa <jolsa@...hat.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Nathan Chancellor <nathan@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
Veronika Kabatova <vkabatov@...hat.com>,
Jiri Olsa <jolsa@...nel.org>
Subject: Re: FAILED unresolved symbol vfs_truncate on arm64 with LLVM
On Fri, Feb 12, 2021 at 11:22:41AM -0800, Andrii Nakryiko wrote:
SNIP
> > +static int is_ftrace_func(struct elf_function *func, __u64 *addrs,
> > + __u64 count, bool kmod)
> > +{
> > + /*
> > + * For vmlinux image both addrs[x] and functions[x]::addr
> > + * values are final address and are comparable.
> > + *
> > + * For kernel module addrs[x] is final address, but
> > + * functions[x]::addr is relative address within section
> > + * and needs to be relocated by adding sh_addr.
> > + */
> > + __u64 start = kmod ? func->addr + func->sh_addr : func->addr;
> > + __u64 addr, end = func->addr + func->size;
> > +
> > + /*
> > + * The invariant here is addr[r] that is the smallest address
> > + * that is >= than function start addr. Except the corner case
> > + * where there is no such r, but for that we have a final check
> > + * in the return.
> > + */
> > + size_t l = 0, r = count - 1, m;
> > +
> > + /* make sure we don't use invalid r */
> > + if (count == 0)
> > + return false;
> > +
> > + while (l < r) {
> > + m = l + (r - l) / 2;
> > + addr = addrs[m];
> > +
> > + if (addr >= start) {
> > + /* we satisfy invariant, so tighten r */
> > + r = m;
> > + } else {
> > + /* m is not good enough as l, maybe m + 1 will be */
> > + l = m + 1;
> > + }
> > + }
> > +
> > + return start <= addrs[r] && addrs[r] < end;
> > +}
> > +
> > static int setup_functions(struct btf_elf *btfe, struct funcs_layout *fl)
> > {
> > __u64 *addrs, count, i;
> > @@ -267,7 +321,7 @@ static int setup_functions(struct btf_elf *btfe, struct funcs_layout *fl)
> > }
> >
> > qsort(addrs, count, sizeof(addrs[0]), addrs_cmp);
> > - qsort(functions, functions_cnt, sizeof(functions[0]), functions_cmp);
> > + qsort(functions, functions_cnt, sizeof(functions[0]), functions_cmp_addr);
>
> All looks good except this. We don't rely on functions being sorted in
> ascending start addr order, do we? If not, just drop this, no need to
> slow down the process.
right, it's not needed when we use st_size for function size
thanks,
jirka
Powered by blists - more mailing lists