diff mbox series

[RFC,v2,bpf-next,4/9] libbpf: Allow to resolve binary path in current directory

Message ID 20230228093206.821563-5-jolsa@kernel.org (mailing list archive)
State RFC
Delegated to: BPF
Headers show
Series mm/bpf/perf: Store build id in inode object | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain }}
bpf/vmtest-bpf-next-VM_Test-2 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-3 fail Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 fail Logs for build for aarch64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-5 fail Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-6 fail Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 fail Logs for build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-8 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-9 success Logs for set-matrix
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 3 maintainers not CCed: kpsingh@kernel.org song@kernel.org martin.lau@linux.dev
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiri Olsa Feb. 28, 2023, 9:32 a.m. UTC
Try to resolve uprobe/usdt binary path also in current directory,
it's used in the test code in following changes.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/bpf/libbpf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrii Nakryiko March 8, 2023, 1:19 a.m. UTC | #1
On Tue, Feb 28, 2023 at 1:33 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> Try to resolve uprobe/usdt binary path also in current directory,
> it's used in the test code in following changes.

nope, that's not what shell is doing, so let's not invent new rules
here. If some tests need something like that, utilize LD_LIBRARY_PATH
or even better just specify './library.so'

>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/lib/bpf/libbpf.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 05c4db355f28..f72115e8b7f9 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -10727,17 +10727,19 @@ static const char *arch_specific_lib_paths(void)
>  /* Get full path to program/shared library. */
>  static int resolve_full_path(const char *file, char *result, size_t result_sz)
>  {
> -       const char *search_paths[3] = {};
> +       const char *search_paths[4] = {};
>         int i, perm;
>
>         if (str_has_sfx(file, ".so") || strstr(file, ".so.")) {
>                 search_paths[0] = getenv("LD_LIBRARY_PATH");
>                 search_paths[1] = "/usr/lib64:/usr/lib";
>                 search_paths[2] = arch_specific_lib_paths();
> +               search_paths[3] = ".";
>                 perm = R_OK;
>         } else {
>                 search_paths[0] = getenv("PATH");
>                 search_paths[1] = "/usr/bin:/usr/sbin";
> +               search_paths[2] = ".";
>                 perm = R_OK | X_OK;
>         }
>
> --
> 2.39.2
>
Jiri Olsa March 8, 2023, 1:48 p.m. UTC | #2
On Tue, Mar 07, 2023 at 05:19:00PM -0800, Andrii Nakryiko wrote:
> On Tue, Feb 28, 2023 at 1:33 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Try to resolve uprobe/usdt binary path also in current directory,
> > it's used in the test code in following changes.
> 
> nope, that's not what shell is doing, so let's not invent new rules
> here. If some tests need something like that, utilize LD_LIBRARY_PATH
> or even better just specify './library.so'

ok, that fixed that:

SEC("uprobe/./liburandom_read.so:urandlib_read_without_sema")

thanks,
jirka

> 
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/lib/bpf/libbpf.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 05c4db355f28..f72115e8b7f9 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -10727,17 +10727,19 @@ static const char *arch_specific_lib_paths(void)
> >  /* Get full path to program/shared library. */
> >  static int resolve_full_path(const char *file, char *result, size_t result_sz)
> >  {
> > -       const char *search_paths[3] = {};
> > +       const char *search_paths[4] = {};
> >         int i, perm;
> >
> >         if (str_has_sfx(file, ".so") || strstr(file, ".so.")) {
> >                 search_paths[0] = getenv("LD_LIBRARY_PATH");
> >                 search_paths[1] = "/usr/lib64:/usr/lib";
> >                 search_paths[2] = arch_specific_lib_paths();
> > +               search_paths[3] = ".";
> >                 perm = R_OK;
> >         } else {
> >                 search_paths[0] = getenv("PATH");
> >                 search_paths[1] = "/usr/bin:/usr/sbin";
> > +               search_paths[2] = ".";
> >                 perm = R_OK | X_OK;
> >         }
> >
> > --
> > 2.39.2
> >
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 05c4db355f28..f72115e8b7f9 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -10727,17 +10727,19 @@  static const char *arch_specific_lib_paths(void)
 /* Get full path to program/shared library. */
 static int resolve_full_path(const char *file, char *result, size_t result_sz)
 {
-	const char *search_paths[3] = {};
+	const char *search_paths[4] = {};
 	int i, perm;
 
 	if (str_has_sfx(file, ".so") || strstr(file, ".so.")) {
 		search_paths[0] = getenv("LD_LIBRARY_PATH");
 		search_paths[1] = "/usr/lib64:/usr/lib";
 		search_paths[2] = arch_specific_lib_paths();
+		search_paths[3] = ".";
 		perm = R_OK;
 	} else {
 		search_paths[0] = getenv("PATH");
 		search_paths[1] = "/usr/bin:/usr/sbin";
+		search_paths[2] = ".";
 		perm = R_OK | X_OK;
 	}