summaryrefslogtreecommitdiff
path: root/libgcompat
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2021-03-31 20:30:11 -0500
committerA. Wilcox <awilcox@wilcox-tech.com>2022-10-06 03:25:42 +0000
commitf727ab78cac3cd5af6a8c33be47a7360ff8a1d8b (patch)
tree8bb94579424dcbade53cebf3627a345d2c8b0cb4 /libgcompat
parent244110e63612999d2dfe649581fce8a359c470a9 (diff)
downloadgcompat-f727ab78cac3cd5af6a8c33be47a7360ff8a1d8b.tar.gz
gcompat-f727ab78cac3cd5af6a8c33be47a7360ff8a1d8b.tar.bz2
gcompat-f727ab78cac3cd5af6a8c33be47a7360ff8a1d8b.tar.xz
gcompat-f727ab78cac3cd5af6a8c33be47a7360ff8a1d8b.zip
locale: also override __newlocale/__duplocale
libstdc++ calls these directly
Diffstat (limited to 'libgcompat')
-rw-r--r--libgcompat/locale.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/libgcompat/locale.c b/libgcompat/locale.c
index 46dadf7..9c4ee28 100644
--- a/libgcompat/locale.c
+++ b/libgcompat/locale.c
@@ -1,12 +1,11 @@
+#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
+#include "alias.h" /* alias */
#include "internal.h"
-void *__newlocale(int, const char *, void *);
-void *__duplocale(void *);
-
struct glibc_locale {
/* hopefully nobody pokes at this */
void *__locales[13];
@@ -18,11 +17,13 @@ struct glibc_locale {
char *__names[13];
};
+typedef locale_t (*newlocale_t)(int mask, const char *name, locale_t base);
+
const unsigned short **__ctype_b_loc(void);
const int32_t **__ctype_tolower_loc(void);
const int32_t **__ctype_toupper_loc(void);
-struct glibc_locale *newlocale(int mask, const char *name, locale_t base) {
+struct glibc_locale *__newlocale(int mask, const char *name, locale_t base) {
struct glibc_locale *ret = (void*)base;
if(ret == NULL) {
ret = calloc(1, sizeof(struct glibc_locale));
@@ -31,7 +32,8 @@ struct glibc_locale *newlocale(int mask, const char *name, locale_t base) {
}
/* relies on sizeof(*locale_t) <= sizeof(ret.__locales) */
- __newlocale(mask, name, ret);
+ newlocale_t real_newlocale = (newlocale_t)dlsym(RTLD_NEXT, "__newlocale");
+ real_newlocale(mask, name, (void*)ret);
ret->__ctype_b = *__ctype_b_loc();
ret->__ctype_tolower = *__ctype_tolower_loc();
@@ -43,9 +45,13 @@ struct glibc_locale *newlocale(int mask, const char *name, locale_t base) {
return ret;
}
-void *duplocale(struct glibc_locale *loc) {
+alias(__newlocale, newlocale);
+
+void *__duplocale(struct glibc_locale *loc) {
struct glibc_locale *ret = malloc(sizeof *ret);
if(!ret) return NULL;
*ret = *loc;
return ret;
}
+
+alias(__duplocale, duplocale);