Skip to content

Commit

Permalink
Create dynam config, remove paths special to static case
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-u committed Nov 9, 2022
1 parent 1199bf3 commit 9640e5b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,16 @@ all: $(ALL_LIBS)

# TODO: Extend this to build each layer, but for now just lump all together.

# This is the dynamic shared object
libSym.so:
mkdir -p dynam_build/
gcc -D CONFIG_X86_64 -Wall -Wextra -shared -fPIC -I ./include $(ALL_SRC) -o dynam_build/$@
gcc -D CONFIG_DYNAMIC -D CONFIG_X86_64 -Wall -Wextra -shared -fPIC -I ./include $(ALL_SRC) -o dynam_build/$@
$(call boldprint, 'Built libSym.so')

debug:
mkdir -p dynam_build/
gcc -D CONFIG_X86_64 -fPIC -shared -I ./include src/L2/sym_lib_page_fault.c -o dynam_build/libSym.so

dynam_L0:
mkdir -p dynam_build/L0/
gcc -g -D DYNAM -D CONFIG_X86_64 -Wall -Wextra -fPIC -c src/L0/sym_lib.c -o dynam_build/L0/sym_lib.o -I include
gcc -shared -fPIC -o dynam_build/L0/libelevate.so dynam_build/L0/sym_lib.o

# NOTE: Inf and libsym are the same :)
$(LIB_SYM): $(LIB_LINF)
cp $(LIB_LINF) $@
Expand Down
19 changes: 0 additions & 19 deletions src/L0/sym_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ __thread int is_sticky = 0;
#include "../../arch/x86_64/L0/sym_lib.h"
#endif

#ifdef DYNAM
void __attribute__ ((constructor)) initLibrary(void) {
//
// Function that is called when the library is loaded
//

// Let's touch stack pages before elevating to try to avoid starvation.
sym_elevate();
}

void __attribute__ ((destructor)) cleanUpLibrary(void) {
//
// Function that is called when the library is »closed«.
//
sym_lower();
}
#endif


static long sym_do_syscall(int work){
if(!is_sticky){
return syscall(NR_ELEVATE_SYSCALL, work);
Expand Down
8 changes: 8 additions & 0 deletions src/L0/sym_lib_hacks.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
#include <stdio.h>
#include "L0/sym_lib_hacks.h"

#ifdef CONFIG_X86_64
// TODO turn this into a header?
#include "../arch/x86_64/L0/sym_lib_hacks.h"
#endif

#ifndef CONFIG_DYNAMIC
extern char __executable_start;
extern char __etext;
#endif

extern void sym_touch_every_page_text(){
#ifndef CONFIG_DYNAMIC
unsigned char *p;
p = (unsigned char *) &__executable_start;

unsigned char VARIABLE_IS_NOT_USED c;
for(; p < (unsigned char *)&__etext; p+= (1<<12))
c = *p;
#else
// TODO: use this tool to remove unintended use of this fn in the dynam case.
// fprintf(stderr, "sym_touch_every_page_text() not implemented for dynamic\n");
#endif
}

extern void sym_touch_stack(){
Expand Down

0 comments on commit 9640e5b

Please sign in to comment.