diff --git a/src/libumockdev-preload.c b/src/libumockdev-preload.c
index 7e1ea6f..bed4774 100644
--- a/src/libumockdev-preload.c
+++ b/src/libumockdev-preload.c
@@ -22,12 +22,30 @@
* along with umockdev; If not, see .
*/
-/* override -D_FILE_OFFSET_BITS, it breaks us */
-#undef _FILE_OFFSET_BITS
-
/* for getting stat64 */
#define _GNU_SOURCE
+#include
+
+#ifdef __GLIBC__
+/* Remove gcc asm aliasing so that our interposed symbols work as expected */
+#include
+
+#include
+extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
+ size_t __buflen), ttyname_r);
+
+#ifdef __REDIRECT
+#undef __REDIRECT
+#endif
+#define __REDIRECT(name, proto, alias) name proto
+#ifdef __REDIRECT_NTH
+#undef __REDIRECT_NTH
+#endif
+#define __REDIRECT_NTH(name, proto, alias) name proto __THROW
+
+#endif /* __GLIBC__ */
+
#include
#include
#include
@@ -63,6 +81,14 @@
#include "utils.h"
#include "ioctl_tree.h"
+#ifdef __GLIBC__
+/* Fixup for making a mess with __REDIRECT above */
+#ifdef __USE_TIME_BITS64
+#define clock_gettime __clock_gettime64
+extern int clock_gettime(clockid_t clockid, struct timespec *tp);
+#endif
+#endif
+
/* fix missing O_TMPFILE on some systems */
#ifndef O_TMPFILE
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)