From 67eb8c6c04a1b6c6fb85cf9cd6d7bdde489c4d5d Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Tue, 11 Sep 2018 22:16:41 -0500 Subject: cxx_thread: Add __cxa_thread_atexit_impl Signed-off-by: Samuel Holland --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 06af84f..74c25f6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ LIBGCOMPAT_INCLUDE = \ libgcompat/alias.h LIBGCOMPAT_SRC = \ + libgcompat/cxx_thread.c \ libgcompat/dlfcn.c \ libgcompat/error.c \ libgcompat/execinfo.c \ -- cgit v1.2.3-70-g09d2 From fc611beda52e6063bf0510a84313d70eb033a672 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Tue, 11 Sep 2018 22:19:45 -0500 Subject: ctype: Add __ctype_b Signed-off-by: Samuel Holland --- CHANGELOG.rst | 6 ++++++ Makefile | 1 + libgcompat/ctype.c | 1 + 3 files changed, 8 insertions(+) create mode 100644 libgcompat/ctype.c (limited to 'Makefile') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2902cb3..f86ecdc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,12 @@ Build system * Allow building against libucontext. +ctype +----- + +* Add __ctype_b. + + cxx_thread ---------- diff --git a/Makefile b/Makefile index 74c25f6..272bfd9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ LIBGCOMPAT_INCLUDE = \ libgcompat/alias.h LIBGCOMPAT_SRC = \ + libgcompat/ctype.c \ libgcompat/cxx_thread.c \ libgcompat/dlfcn.c \ libgcompat/error.c \ diff --git a/libgcompat/ctype.c b/libgcompat/ctype.c new file mode 100644 index 0000000..1ae9877 --- /dev/null +++ b/libgcompat/ctype.c @@ -0,0 +1 @@ +const unsigned short int *__ctype_b; -- cgit v1.2.3-70-g09d2 From e9224395eba97e86d8d411f016972b2d70cd6ff3 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Tue, 11 Sep 2018 22:28:24 -0500 Subject: realpath: Intercept realpath(/proc/self/exe) Reuse the machinery from readlink Signed-off-by: Samuel Holland --- CHANGELOG.rst | 5 +++-- Makefile | 1 + libgcompat/realpath.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 libgcompat/realpath.c (limited to 'Makefile') diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2a4b1d3..188d75c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -35,9 +35,10 @@ math * Add most __*_finite functions, courtesy of Elizabeth Myers. -readlink --------- +readlink/realpath +----------------- +* Intercept realpath as well as readlink. * Report ENOSYS on dlsym failure. diff --git a/Makefile b/Makefile index 272bfd9..934422f 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ LIBGCOMPAT_SRC = \ libgcompat/pthread.c \ libgcompat/pwd.c \ libgcompat/readlink.c \ + libgcompat/realpath.c \ libgcompat/resolv.c \ libgcompat/resource.c \ libgcompat/setjmp.c \ diff --git a/libgcompat/realpath.c b/libgcompat/realpath.c new file mode 100644 index 0000000..ab68cc4 --- /dev/null +++ b/libgcompat/realpath.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef LINKER +#error LINKER must be defined +#endif + +static char *(*real_realpath)(const char *restrict, char *restrict); + +char *realpath(const char *restrict path, char *restrict resolved) +{ + if (real_realpath == NULL) { + real_realpath = dlsym(RTLD_NEXT, "realpath"); + if (real_realpath == NULL) { + errno = ENOSYS; + return NULL; + } + } + + if (!strcmp(path, "/proc/self/exe")) { + char *fixed = resolved; + + if (fixed == NULL) { + fixed = malloc(PATH_MAX); + if (fixed == NULL) { + errno = ENOMEM; + return NULL; + } + } + + /* If passed in, the buffer is at least PATH_MAX per POSIX. */ + ssize_t written = readlink(path, fixed, PATH_MAX - 1); + if (written == -1) { + /* Free the buffer iff we allocated it. */ + if (fixed != resolved) + free(fixed); + return NULL; + } + fixed[written] = '\0'; + + return fixed; + } + + return real_realpath(path, resolved); +} -- cgit v1.2.3-70-g09d2