committing ELF crimes (part 1)
make a dynamic binary that works under both glibc and musl (given you invoke ld.so directly and create a fake musl libc pointing to glibc)
This commit is contained in:
parent
a38a6219c2
commit
fb05155915
3
Makefile
3
Makefile
|
@ -30,7 +30,8 @@ clean-in-container:
|
|||
|
||||
# main build stuff
|
||||
$(APP_NAME): main_bc.c app.o
|
||||
$(CC) -o $@ -pipe -O3 -DAPP_NAME='"$(APP_NAME)"' -static $^ -lracket3m -lrktio -lucontext -lffi
|
||||
# $(CC) -o $@ -pipe -O3 -DAPP_NAME='"$(APP_NAME)"' -static $^ -lracket3m -lrktio -lucontext -lffi
|
||||
$(CC) -o $@ -pipe -O3 -DAPP_NAME='"$(APP_NAME)"' $^ /usr/lib/libracket3m.a /usr/lib/librktio.a /usr/lib/libffi.a /lib/libucontext.a
|
||||
|
||||
# this is faster than --c-mods by a lot
|
||||
# it's less portable but like, we're containerized already so it'll work
|
||||
|
|
19
main_bc.c
19
main_bc.c
|
@ -3,6 +3,25 @@
|
|||
#include <racket/scheme.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// patchups for musl vs glibc stuff
|
||||
#include <sys/stat.h>
|
||||
int stat(const char *restrict path, struct stat *restrict buf) {
|
||||
return __xstat(1, path, buf);
|
||||
}
|
||||
int fstat(int fildes, struct stat *buf) {
|
||||
return __fxstat(1, fildes, buf);
|
||||
}
|
||||
int lstat(const char *restrict path, struct stat *restrict buf) {
|
||||
return __lxstat(1, path, buf);
|
||||
}
|
||||
|
||||
extern void* __dso_handle;
|
||||
|
||||
int atexit(void (*function)(void)) {
|
||||
return __cxa_atexit(function, NULL, __dso_handle);
|
||||
}
|
||||
|
||||
extern const char _binary_app_zo_start;
|
||||
extern const char _binary_app_zo_end;
|
||||
|
|
8
run.rkt
8
run.rkt
|
@ -17,3 +17,11 @@
|
|||
(displayln "back")
|
||||
|
||||
; (error "meow meow")
|
||||
|
||||
(module gui-test racket/gui
|
||||
(provide run-test)
|
||||
(define (run-test)
|
||||
(message-box "hello" "hello world")))
|
||||
|
||||
(require (submod "." gui-test))
|
||||
(run-test)
|
||||
|
|
|
@ -13,3 +13,4 @@ rm -Rf src/foreign/libffi
|
|||
make -j $(nproc) CPUS=$(nproc)
|
||||
make install
|
||||
raco pkg install --deps search-auto cext-lib
|
||||
raco pkg install --deps search-auto gui-lib
|
||||
|
|
Loading…
Reference in New Issue