From e601d5d707eb7c9ffdcb67772de224d84a1b960c Mon Sep 17 00:00:00 2001 From: viktorxda <35473052+viktorxda@users.noreply.github.com> Date: Sat, 25 May 2024 00:39:05 +0200 Subject: [PATCH] Add mmap64 command --- src/Makefile | 2 +- src/compat.c | 9 +++++---- src/hal/support.c | 6 ++---- src/hal/support.h | 4 +++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Makefile b/src/Makefile index 70876b7..3ec3149 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,4 @@ SRC := $(shell find ./ -name '*.c') divinus: - $(CC) $(SRC) -I src -rdynamic -Wl,--wrap=mmap $(OPT) -o ../$@ \ No newline at end of file + $(CC) $(SRC) -I src -rdynamic $(OPT) -o ../$@ diff --git a/src/compat.c b/src/compat.c index 4b73294..c830bc3 100644 --- a/src/compat.c +++ b/src/compat.c @@ -16,9 +16,10 @@ float __expf_finite(float x) { return expf(x); } int __fgetc_unlocked(FILE *stream) { return fgetc(stream); } double __log_finite(double x) { return log(x); } -void* mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) { +void *mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) { + return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12); +} + +void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) { return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12); } -void* __wrap_mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) { - return mmap(start, len, prot, flags, fd, off); -} \ No newline at end of file diff --git a/src/hal/support.c b/src/hal/support.c index c50a2df..270ef9f 100644 --- a/src/hal/support.c +++ b/src/hal/support.c @@ -1,7 +1,5 @@ #include "support.h" -extern void* __real_mmap(); - void *isp_thread = NULL; void *venc_thread = NULL; @@ -34,7 +32,7 @@ bool hal_registry(unsigned int addr, unsigned int *data, hal_register_op op) { volatile char *mapped_area; if (offset != loaded_offset) { - mapped_area = __real_mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, offset); + mapped_area = mmap64(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, offset); if (mapped_area == MAP_FAILED) { fprintf(stderr, "hal_registry mmap error: %s (%d)\n", strerror(errno), errno); @@ -116,4 +114,4 @@ void hal_identify(void) { chnState = (hal_chnstate*)v4_state; isp_thread = v4_image_thread; venc_thread = v4_video_thread; -} \ No newline at end of file +} diff --git a/src/hal/support.h b/src/hal/support.h index a322b1b..8a1ecc8 100644 --- a/src/hal/support.h +++ b/src/hal/support.h @@ -33,4 +33,6 @@ extern void *i6f_encoder_thread(void); extern hal_chnstate i6f_state[I6F_VENC_CHN_NUM]; bool hal_registry(unsigned int addr, unsigned int *data, hal_register_op op); -void hal_identify(void); \ No newline at end of file +void hal_identify(void); + +void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off);