45 lines
1.4 KiB
Diff
45 lines
1.4 KiB
Diff
From 6b4851b7dafc9015f673d59c692fadd7912e7ad2 Mon Sep 17 00:00:00 2001
|
|
From: Bastien Nocera <hadess@hadess.net>
|
|
Date: Thu, 22 Oct 2020 17:16:03 +0200
|
|
Subject: [PATCH] preload: Better debug for functions missing from libc
|
|
|
|
If finding one of the symbols for a function fails, whichever function
|
|
it is, we'd get this error message:
|
|
python3: src/libumockdev-preload.c:81: get_libc_func: Assertion `fp' failed.
|
|
|
|
Update the code to throw an error on stderr before failing.
|
|
---
|
|
src/libumockdev-preload.c | 10 +++++++---
|
|
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/libumockdev-preload.c b/src/libumockdev-preload.c
|
|
index 1011fac..9328dc1 100644
|
|
--- a/src/libumockdev-preload.c
|
|
+++ b/src/libumockdev-preload.c
|
|
@@ -78,15 +78,19 @@ get_libc_func(const char *f)
|
|
nextlib = dlopen("libc.so.6", RTLD_LAZY);
|
|
|
|
fp = dlsym(nextlib, f);
|
|
- assert(fp);
|
|
|
|
return fp;
|
|
}
|
|
|
|
#define libc_func(name, rettype, ...) \
|
|
static rettype (*_ ## name) (__VA_ARGS__) = NULL; \
|
|
- if (_ ## name == NULL) \
|
|
- _ ## name = get_libc_func(#name);
|
|
+ if (_ ## name == NULL) { \
|
|
+ _ ## name = get_libc_func(#name); \
|
|
+ if (_ ## name == NULL) { \
|
|
+ fprintf(stderr, "umockdev: could not get libc function "#name"\n"); \
|
|
+ abort(); \
|
|
+ } \
|
|
+ }
|
|
|
|
/* return rdev of a file descriptor */
|
|
static dev_t
|
|
--
|
|
2.28.0
|
|
|