Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ CRT_LIBS = $(addprefix lib/,$(notdir $(CRT_OBJS)))
STATIC_LIBS = lib/libc.a
SHARED_LIBS = lib/libc.so
TOOL_LIBS = lib/musl-gcc.specs
ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS)
#ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS)
ALL_LIBS = $(STATIC_LIBS)
ALL_TOOLS = obj/musl-gcc

WRAPCC_GCC = gcc
Expand Down
2 changes: 2 additions & 0 deletions src/internal/libc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ extern hidden size_t __hwcap;
extern hidden size_t __sysinfo;
#ifdef __OCCLUM
extern hidden size_t __occlum_entry;
weak extern hidden size_t __occlum_syscall_linux_abi(void) {};
void init_occlum_syscall(void);
// A program that is compiled with Occlum's fork of musl libc can run
// on either Occlum or Linux. We can detect whether the OS that is hosting
// the program by checking whether __occlum_entry is non-zero.
Expand Down
4 changes: 4 additions & 0 deletions src/internal/occlum/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ long __syscall_on_x86_64(int num, long a, long b, long c, long d, long e, long f
long __syscall(int num, long a, long b, long c, long d, long e, long f) {
return __syscall_on_x86_64(num, a, b, c, d, e, f);
}

void init_occlum_syscall(void) {
__occlum_entry = (size_t)__occlum_syscall_linux_abi;
}
4 changes: 2 additions & 2 deletions src/malloc/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static void trim(struct chunk *self, size_t n)
__bin_chunk(split);
}

void *malloc(size_t n)
weak void *malloc(size_t n)
{
struct chunk *c;
int i, j;
Expand Down Expand Up @@ -520,7 +520,7 @@ static void unmap_chunk(struct chunk *self)
__munmap(base, len);
}

void free(void *p)
weak void free(void *p)
{
if (!p) return;

Expand Down
2 changes: 1 addition & 1 deletion src/misc/uname.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <sys/utsname.h>
#include "syscall.h"

int uname(struct utsname *uts)
weak int uname(struct utsname *uts)
{
return syscall(SYS_uname, uts);
}
2 changes: 1 addition & 1 deletion src/stdio/printf.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>

int printf(const char *restrict fmt, ...)
weak int printf(const char *restrict fmt, ...)
{
int ret;
va_list ap;
Expand Down