@@ -122,6 +122,64 @@ pseudo_reinit_libpseudo(void) {
_libpseudo_init();
}
+#if defined(__loongarch_lp64)
+#define LOAD_REAL_SYMBOL(name, symbol) \
+ pseudo_real_##name = dlsym(RTLD_NEXT, symbol); \
+ real_##name = pseudo_##name
+
+static int (*pseudo_real___fxstat)(int fd, struct stat *buf) = NULL;
+static int (*pseudo_real___fxstat64)(int fd, struct stat64 *buf) = NULL;
+static int (*pseudo_real___fxstatat)(int dirfd, const char *path, struct stat *buf, int flags) = NULL;
+static int (*pseudo_real___fxstatat64)(int dirfd, const char *path, struct stat64 *buf, int flags) = NULL;
+static int (*pseudo_real___lxstat)(const char *path, struct stat *buf) = NULL;
+static int (*pseudo_real___lxstat64)(const char *path, struct stat64 *buf) = NULL;
+static int (*pseudo_real___xmknod)(const char *path, mode_t mode, dev_t *dev) = NULL;
+static int (*pseudo_real___xmknodat)(int dirfd, const char *path, mode_t mode, dev_t *dev) = NULL;
+static int (*pseudo_real___xstat)(const char *path, struct stat *buf) = NULL;
+static int (*pseudo_real___xstat64)(const char *path, struct stat64 *buf) = NULL;
+
+static int pseudo___fxstat(int ver __attribute__((unused)), int fd, struct stat *buf)
+{
+ return pseudo_real___fxstat(fd, buf);
+}
+static int pseudo___fxstat64(int ver __attribute__((unused)), int fd, struct stat64 *buf)
+{
+ return pseudo_real___fxstat64(fd, buf);
+}
+static int pseudo___fxstatat(int ver __attribute__((unused)), int dirfd, const char *path, struct stat *buf, int flags)
+{
+ return pseudo_real___fxstatat(dirfd, path, buf, flags);
+}
+static int pseudo___fxstatat64(int ver __attribute__((unused)), int dirfd, const char *path, struct stat64 *buf, int flags)
+{
+ return pseudo_real___fxstatat64(dirfd, path, buf, flags);
+}
+static int pseudo___lxstat(int ver __attribute__((unused)), const char *path, struct stat *buf)
+{
+ return pseudo_real___lxstat(path, buf);
+}
+static int pseudo___lxstat64(int ver __attribute__((unused)), const char *path, struct stat64 *buf)
+{
+ return pseudo_real___lxstat64(path, buf);
+}
+static int pseudo___xmknod(int ver __attribute__((unused)), const char *path, mode_t mode, dev_t *dev)
+{
+ return pseudo_real___xmknod(path, mode, dev);
+}
+static int pseudo___xmknodat(int ver __attribute__((unused)), int dirfd, const char *path, mode_t mode, dev_t *dev)
+{
+ return pseudo_real___xmknodat(dirfd, path, mode, dev);
+}
+static int pseudo___xstat(int ver __attribute__((unused)), const char *path, struct stat *buf)
+{
+ return pseudo_real___xstat(path, buf);
+}
+static int pseudo___xstat64(int ver __attribute__((unused)), const char *path, struct stat64 *buf)
+{
+ return pseudo_real___xstat64(path, buf);
+}
+#endif
+
static void
pseudo_init_one_wrapper(pseudo_function *func) {
int (*f)(void) = (int (*)(void)) NULL;
@@ -185,6 +243,18 @@ pseudo_init_wrappers(void) {
pseudo_real_fork = dlsym(RTLD_NEXT, "fork");
pseudo_real_execv = dlsym(RTLD_NEXT, "execv");
+#if defined(__loongarch_lp64)
+ LOAD_REAL_SYMBOL(__fxstat, "fstat");
+ LOAD_REAL_SYMBOL(__fxstat64, "fstat64");
+ LOAD_REAL_SYMBOL(__fxstatat, "fstatat");
+ LOAD_REAL_SYMBOL(__fxstatat64, "fstatat64");
+ LOAD_REAL_SYMBOL(__lxstat, "lstat");
+ LOAD_REAL_SYMBOL(__lxstat64, "lstat64");
+ LOAD_REAL_SYMBOL(__xmknod, "mknod");
+ LOAD_REAL_SYMBOL(__xmknodat, "mknodat");
+ LOAD_REAL_SYMBOL(__xstat, "stat");
+ LOAD_REAL_SYMBOL(__xstat64, "stat64");
+#endif
/* Once the wrappers are setup, we can now use open... so
* setup the logfile, if necessary...
*/
Since these symbols do not exist in LoongArch's libc.so, they need to be remapped, and the first "ver" function parameter does not exist in the mapped function. __fxstat __fxstat64 __fxstatat __fxstatat64 __lxstat __lxstat64 __xmknod __xmknodat __xstat __xstat64 Signed-off-by: Xiaotian Wu <wuxiaotian@loongson.cn> --- pseudo_wrappers.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)