* ABI compat report: or, how to get a Debian ksh93 binary running
@ 2015-07-01 14:21 Isaac Dunham
0 siblings, 0 replies; only message in thread
From: Isaac Dunham @ 2015-07-01 14:21 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1485 bytes --]
Hello,
For some reason I decided to try getting a ksh93 binary running
(once again); this time, it seems to work right.
Steps:
- fetch ksh_93u+20120801-1_i386.deb; list of mirrors:
https://packages.debian.org/jessie/i386/ksh/download
- get musl source from git, create new branch
- apply the patch to add *_chk
Message-Id: <1434509291-28997-1-git-send-email-josiahw@gmail.com>
http://www.openwall.com/lists/musl/2015/06/17/1
- apply the attached patch to fix a few build errors and add __strcpy_chk()
(I'm aware that there are still some possible issues with correctness);
configure and compile musl.
- build the attached library, which provides:
semi-working substitutes for glibc's [jy][n01]l() functions
(I just cast long double to double, which will result in degraded
range and accuracy compared to the full implementations for 12-
and 16-byte long doubles in glibc. Other sizes of long double
get a stub error function in glibc.)
stub function pointer variables __memalign_hook, __malloc_hook,
__realloc_hook, and __free_hook; these are unused.
a few math symbols corresonding to isfinite() and isinf():
{__,}{finitel,isinfl}, __isinf, __isnan, isnanl
scalbl(), a nonstandard extension of scalb() which is obsolete.
- extract bin/ksh93 from the deb
- test with your new libc:
LD_PRELOAD=../compat-libc/compat.so lib/libc.so ./ksh93
- Once you've tested, you can replace "libm.so.6" with "compat.so"
to make it stick.
Thanks,
Isaac Dunham
[-- Attachment #2: 0001-src-compat-_chk.c-fix-build-add-__strcpy_chk.patch --]
[-- Type: text/plain, Size: 3232 bytes --]
From 3a9fdda5680fed183f0b33a9412fb88e0cb8f6a8 Mon Sep 17 00:00:00 2001
From: Isaac Dunham <ibid.ag@gmail.com>
Date: Tue, 30 Jun 2015 21:06:20 -0700
Subject: [PATCH] src/compat/*_chk.c: fix build, add __strcpy_chk()
---
src/compat/longjmp_chk.c | 4 ++--
src/compat/posix_chk.c | 7 +------
src/compat/realpath_chk.c | 2 +-
src/compat/string_chk.c | 6 ++++++
src/compat/ttyname_r_chk.c | 1 +
src/compat/wchar_chk.c | 2 +-
6 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/compat/longjmp_chk.c b/src/compat/longjmp_chk.c
index e814ecc..576a1b5 100644
--- a/src/compat/longjmp_chk.c
+++ b/src/compat/longjmp_chk.c
@@ -1,7 +1,7 @@
#include <setjmp.h>
#include <signal.h>
-_Noreturn void __longjmp_chk(sigjmp_buf buf, int ret)
+_Noreturn void __longjmp_chk(jmp_buf buf, int ret)
{
- longjmp((jmp_buf)buf, ret);
+ longjmp(buf, ret);
}
diff --git a/src/compat/posix_chk.c b/src/compat/posix_chk.c
index 7e39754..2b9a845 100644
--- a/src/compat/posix_chk.c
+++ b/src/compat/posix_chk.c
@@ -1,3 +1,4 @@
+#include <sys/select.h>
#include <poll.h>
#include <sys/socket.h>
#include <unistd.h>
@@ -93,12 +94,6 @@ long __fdelt_chk(long d)
return d / (8 * sizeof(d));
}
-int __ttyname_r_chk(int fd, char *name, size_t size, size_t namelen)
-{
- if (size > namelen) a_crash();
- return ttyname_r(fd, name, size);
-}
-
char *__stpcpy_chk(char *d, const char *s, size_t dlen)
{
size_t slen = strnlen(s, dlen) + 1;
diff --git a/src/compat/realpath_chk.c b/src/compat/realpath_chk.c
index cc0089e..c2ac9f8 100644
--- a/src/compat/realpath_chk.c
+++ b/src/compat/realpath_chk.c
@@ -1,6 +1,6 @@
#include <stdlib.h>
#include <limits.h>
-#include "atomics.h"
+#include "atomic.h"
char *__realpath_chk(const char *filename, char *resolved, size_t resolved_len)
{
diff --git a/src/compat/string_chk.c b/src/compat/string_chk.c
index ba77c9c..8a17c48 100644
--- a/src/compat/string_chk.c
+++ b/src/compat/string_chk.c
@@ -40,6 +40,12 @@ char *__strncat_chk(char *restrict dest, const char *restrict src, size_t n, siz
return strncat(dest, src, n);
}
+char *__strcpy_chk(char *restrict dest, const char *restrict src, size_t destlen)
+{
+ if ( strlen(src) >= destlen) a_crash();
+ return strcpy(dest, src);
+}
+
char *__strncpy_chk(char *restrict dest, const char *restrict src, size_t n, size_t destlen)
{
if (n > destlen) a_crash();
diff --git a/src/compat/ttyname_r_chk.c b/src/compat/ttyname_r_chk.c
index 50e70e5..cbede51 100644
--- a/src/compat/ttyname_r_chk.c
+++ b/src/compat/ttyname_r_chk.c
@@ -1,4 +1,5 @@
#include <unistd.h>
+#include "atomic.h"
int __ttyname_r_chk(int fd, char *name, size_t size, size_t namelen)
{
diff --git a/src/compat/wchar_chk.c b/src/compat/wchar_chk.c
index 66e35b1..fd5b075 100644
--- a/src/compat/wchar_chk.c
+++ b/src/compat/wchar_chk.c
@@ -5,7 +5,7 @@
size_t __mbsnrtowcs_chk(wchar_t *restrict wcs, const char **restrict src, size_t n, size_t wn, mbstate_t *restrict st, size_t wcslen)
{
if (wn > wcslen) a_crash();
- return msbnrtowcs(wcs, src, n, wn, st);
+ return mbsnrtowcs(wcs, src, n, wn, st);
}
size_t __mbsrtowcs_chk(wchar_t *restrict ws, const char **restrict src, size_t wn, mbstate_t *restrict st, size_t wslen)
--
2.4.5
[-- Attachment #3: compat-libc.tgz --]
[-- Type: application/octet-stream, Size: 1980 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-01 14:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01 14:21 ABI compat report: or, how to get a Debian ksh93 binary running Isaac Dunham
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).