diff --git a/.buildbot.sh b/.buildbot.sh index 8496b80..3c3e123 100644 --- a/.buildbot.sh +++ b/.buildbot.sh @@ -15,14 +15,17 @@ ${CLANG_FORMAT_BIN} --dry-run -Werror ${CLANG_FORMAT_SOURCES[*]} # Update submodules git submodule update --init -# Apply lua patch +# Apply `lua` patch lua_dir="$src_dir/third-party/lua" patch -d $lua_dir -i ../lua.patch -# Apply toml patch +# Apply `toml` patch toml_dir="$src_dir/third-party/tomlc99" patch -d $toml_dir -i ../tomlc99.patch +# Link `tommyds` Makefile appropriately +ln -s $(pwd)/third-party/tommyds-makefile $(pwd)/third-party/tommyds/tommyds/Makefile + # Prepare python virtual env export PATH=$PATH:$HOME/.local/bin pip3 install --break-system-packages fabric diff --git a/.gitmodules b/.gitmodules index b3e7552..68dcdf5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "third-party/tomlc99"] path = third-party/tomlc99 url = https://github.com/cktan/tomlc99 +[submodule "third-party/tommyds"] + path = third-party/tommyds + url = https://github.com/amadvance/tommyds.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 71f6278..84deef2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,13 +48,34 @@ add_custom_target( toml DEPENDS ${TOML_LIB_PATH} ) -add_library(tomllib SHARED IMPORTED) +add_library(tomllib STATIC IMPORTED) add_dependencies(tomllib toml) set_target_properties(tomllib PROPERTIES IMPORTED_LOCATION ${TOML_LIB_PATH} ) +# Build tommyds +set(TOMMYDS_DIR ${CMAKE_SOURCE_DIR}/third-party/tommyds/tommyds) +set(TOMMYDS_LIB ${CMAKE_SOURCE_DIR}/third-party/tommyds/tommyds/libtommyds.a) + +add_custom_command( + OUTPUT ${TOMMYDS_LIB} + COMMAND make + WORKING_DIRECTORY ${TOMMYDS_DIR} +) + +add_custom_target( + tommyds + DEPENDS ${TOMMYDS_LIB} +) +add_library(tommydslib STATIC IMPORTED) +add_dependencies(tommydslib tommyds) +set_target_properties(tommydslib + PROPERTIES + IMPORTED_LOCATION ${TOMMYDS_LIB} +) + # Build sources add_subdirectory(${SRC_DIR}) diff --git a/include/compartment.h b/include/compartment.h index 1a2827d..15db912 100644 --- a/include/compartment.h +++ b/include/compartment.h @@ -17,7 +17,8 @@ #include #include -#include "symbols.h" +// TODO consider re-organizing +#include "symbols_comp.h" #include "cheriintrin.h" diff --git a/include/symbols.h b/include/symbols.h index 76cb532..cd03789 100644 --- a/include/symbols.h +++ b/include/symbols.h @@ -4,71 +4,15 @@ #include #include #include +#include #include #include -struct simple_lds_list -{ - struct LibDependencySymbol **data; - size_t data_count; -}; +#include "tommy.h" -struct simple_cs_list -{ - struct CompSymbol **data; - size_t data_count; -}; +#define HASHTABLE_MAX_SZ 1024 +#define hashtable_hash(x) tommy_hash_u64(0, x, strlen(x)) -typedef struct simple_lds_list lib_symbol_list; -typedef struct LibDependencySymbol lib_symbol; - -typedef struct simple_cs_list comp_symbol_list; -typedef struct CompSymbol comp_symbol; - -/* Struct representing a symbol entry of a dependency library - */ -struct LibDependencySymbol -{ - char *sym_name; - void *sym_offset; - unsigned short sym_type; - unsigned short sym_bind; - uint16_t sym_shndx; -}; - -/* Struct representing a wrapper around a LibDependencySymbol, in order to - * facilitate compartment-level searching - */ -struct CompSymbol -{ - struct LibDependencySymbol *sym_ref; - size_t sym_lib_idx; -}; - -comp_symbol_list * -comp_syms_init(); -void -comp_syms_clean(comp_symbol_list *); -void -comp_syms_clean_deep(comp_symbol_list *); -void -comp_syms_insert(comp_symbol *, comp_symbol_list *); -comp_symbol * -comp_syms_search(const char *, const comp_symbol_list *); -comp_symbol_list * -comp_syms_find_all(const char *, const comp_symbol_list *); - -lib_symbol_list * -lib_syms_init(); -void -lib_syms_clean(lib_symbol_list *); -void -lib_syms_clean_deep(lib_symbol_list *); -void -lib_syms_insert(lib_symbol *, lib_symbol_list *); -lib_symbol * -lib_syms_search(const char *, const lib_symbol_list *); -lib_symbol_list * -lib_syms_find_all(const char *, const lib_symbol_list *); +#define MAX_FIND_ALL_COUNT 1024 #endif // _CHERICOMP_SYMBOLS_H diff --git a/include/symbols_comp.h b/include/symbols_comp.h new file mode 100644 index 0000000..12d91f8 --- /dev/null +++ b/include/symbols_comp.h @@ -0,0 +1,36 @@ +#ifndef _CHERICOMP_SYMBOLS_COMP_H +#define _CHERICOMP_SYMBOLS_COMP_H + +#include "symbols.h" +#include "symbols_lib.h" + +typedef tommy_hashtable comp_symbol_list; +typedef struct CompSymbol comp_symbol; + +/* Struct representing a wrapper around a LibDependencySymbol, in order to + * facilitate compartment-level searching + */ +struct CompSymbol +{ + struct LibDependencySymbol *sym_ref; + size_t sym_lib_idx; + tommy_node node; +}; + +comp_symbol_list * +comp_syms_init(); +void +comp_syms_clean(comp_symbol_list *); +void +comp_syms_clean_deep(comp_symbol_list *); +void +comp_syms_insert(comp_symbol *, comp_symbol_list *); +comp_symbol * +comp_syms_search(const char *, comp_symbol_list *); +comp_symbol ** +comp_syms_find_all(const char *, comp_symbol_list *); + +void +update_comp_syms(comp_symbol_list *, lib_symbol_list *, const size_t); + +#endif // _CHERICOMP_SYMBOLS_COMP_H diff --git a/include/symbols_lib.h b/include/symbols_lib.h new file mode 100644 index 0000000..d868f19 --- /dev/null +++ b/include/symbols_lib.h @@ -0,0 +1,36 @@ +#ifndef _CHERICOMP_SYMBOLS_LIB_H +#define _CHERICOMP_SYMBOLS_LIB_H + +#include "symbols.h" + +typedef tommy_hashtable lib_symbol_list; +typedef struct LibDependencySymbol lib_symbol; + +/* Struct representing a symbol entry of a dependency library + */ +struct LibDependencySymbol +{ + char *sym_name; + void *sym_offset; + unsigned short sym_type; + unsigned short sym_bind; + uint16_t sym_shndx; + tommy_node node; +}; + +lib_symbol_list * +lib_syms_init(); +void +lib_syms_clean(lib_symbol_list *); +void +lib_syms_clean_deep(lib_symbol_list *); +void +lib_syms_insert(lib_symbol *, lib_symbol_list *); +lib_symbol * +lib_syms_search(const char *, lib_symbol_list *); +lib_symbol ** +lib_syms_find_all(const char *, lib_symbol_list *); +void +lib_syms_print(lib_symbol_list *); + +#endif // _CHERICOMP_SYMBOLS_LIB_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 19156e2..00547e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,8 +7,8 @@ add_library(chcomp STATIC symbols_lib.c transition.S ) -target_include_directories(chcomp PRIVATE ${INCLUDE_DIR} ${TOML_INCLUDE_DIR}) -target_link_libraries(chcomp PRIVATE tomllib) +target_include_directories(chcomp PRIVATE ${INCLUDE_DIR} ${TOML_INCLUDE_DIR} ${TOMMYDS_DIR}) +target_link_libraries(chcomp PRIVATE tomllib tommydslib) add_library(computils SHARED comp_utils.c) diff --git a/src/compartment.c b/src/compartment.c index be882ff..ee4ab0a 100644 --- a/src/compartment.c +++ b/src/compartment.c @@ -23,8 +23,6 @@ parse_lib_rela(Elf64_Shdr *, Elf64_Ehdr *, int, struct LibDependency *); static void parse_lib_dynamic_deps(Elf64_Shdr *, Elf64_Ehdr *, int, struct LibDependency *); static void -update_comp_syms(struct Compartment *, const lib_symbol_list *, const size_t); -static void map_comp_entry_points(struct Compartment *); static void resolve_rela_syms(struct Compartment *); @@ -438,7 +436,7 @@ parse_lib_file(char *lib_name, struct Compartment *new_comp) lib_fd = open(lib_path, O_RDONLY); if (lib_fd == -1) { - errx(1, "Error opening compartment file %s!\n", lib_name); + errx(1, "Error opening compartment file %s!", lib_name); } } @@ -449,7 +447,7 @@ parse_lib_file(char *lib_name, struct Compartment *new_comp) { errx(1, "Error parsing `%s` - only supporting ELFs of type DYN (shared " - "object files)!\n", + "object files)!", lib_path); } @@ -565,7 +563,8 @@ parse_lib_file(char *lib_name, struct Compartment *new_comp) new_comp->libs = realloc( new_comp->libs, new_comp->libs_count * sizeof(struct LibDependency *)); new_comp->libs[new_comp->libs_count - 1] = new_lib; - update_comp_syms(new_comp, new_lib->lib_syms, new_comp->libs_count - 1); + update_comp_syms( + new_comp->comp_syms, new_lib->lib_syms, new_comp->libs_count - 1); free(shstrtab); @@ -888,25 +887,6 @@ parse_lib_dynamic_deps(Elf64_Shdr *dynamic_shdr, Elf64_Ehdr *lib_ehdr, free(dyn_entries); } -static void -update_comp_syms(struct Compartment *comp, const lib_symbol_list *lib_dep_syms, - const size_t lib_idx) -{ - comp_symbol *new_cs; - for (size_t i = 0; i < lib_dep_syms->data_count; ++i) - { - // We do not want to record non-local symbols - if (lib_dep_syms->data[i]->sym_shndx == 0) - { - continue; - } - new_cs = malloc(sizeof(comp_symbol)); - new_cs->sym_ref = lib_dep_syms->data[i]; - new_cs->sym_lib_idx = lib_idx; - comp_syms_insert(new_cs, comp->comp_syms); - } -} - static void map_comp_entry_points(struct Compartment *new_comp) { @@ -916,22 +896,23 @@ map_comp_entry_points(struct Compartment *new_comp) // TODO is the main loaded library always the 0th indexed one? const size_t lib_idx = 0; const char *ep_name = new_comp->cc->entry_points[i].name; - lib_symbol_list *candidates + lib_symbol **candidates = lib_syms_find_all(ep_name, new_comp->libs[lib_idx]->lib_syms); size_t j = 0; - for (; j < candidates->data_count; ++j) + while (candidates) { - if (check_lib_dep_sym(candidates->data[j], STT_FUNC)) + if (check_lib_dep_sym(*candidates, STT_FUNC)) { break; } + *candidates += sizeof(lib_symbol *); } - if (j == candidates->data_count) + if (!candidates) { errx(1, "Did not find entry point %s!\n", ep_name); } new_comp->cc->entry_points[i].comp_addr - = eval_lib_sym_offset(new_comp, lib_idx, candidates->data[j]); + = eval_lib_sym_offset(new_comp, lib_idx, *candidates); free(candidates); } } @@ -942,13 +923,14 @@ resolve_rela_syms(struct Compartment *new_comp) // Find all symbols for eager relocation mapping size_t prev_tls_secs_size = 0; struct LibRelaMapping *curr_rela_map; - comp_symbol_list *candidate_syms; + comp_symbol **candidate_syms; comp_symbol *chosen_sym; for (size_t i = 0; i < new_comp->libs_count; ++i) { for (size_t j = 0; j < new_comp->libs[i]->rela_maps_count; ++j) { curr_rela_map = &new_comp->libs[i]->rela_maps[j]; + chosen_sym = NULL; // This is a TLS variable that exists in the current library; we // just allocate the space for it @@ -984,7 +966,7 @@ resolve_rela_syms(struct Compartment *new_comp) candidate_syms = comp_syms_find_all( curr_rela_map->rela_name, new_comp->comp_syms); - if (candidate_syms->data_count == 0) + if (*candidate_syms == NULL) { if (curr_rela_map->rela_sym_bind == STB_WEAK) { @@ -1012,43 +994,42 @@ resolve_rela_syms(struct Compartment *new_comp) curr_rela_map->rela_name, curr_rela_map->rela_sym_type, j, new_comp->libs[i]->lib_name, i); } - // TODO caching // Prioritise looking for weak symbols in libraries outside the // source library, even if they are defined if (curr_rela_map->rela_sym_bind == STB_WEAK) { - int fallback_sym_id = -1; - size_t k = 0; - for (; k < candidate_syms->data_count; ++k) + comp_symbol *fallback_sym = NULL; + while (*candidate_syms) { - if (!check_lib_dep_sym(candidate_syms->data[k]->sym_ref, + if (check_lib_dep_sym((*candidate_syms)->sym_ref, curr_rela_map->rela_sym_type)) { - continue; - } - if (candidate_syms->data[k]->sym_lib_idx != i) - { - chosen_sym = candidate_syms->data[k]; - break; - } - else - { - fallback_sym_id = k; + if ((*candidate_syms)->sym_lib_idx != i) + { + chosen_sym = *candidate_syms; + break; + } + else if (!fallback_sym) + { + fallback_sym = *candidate_syms; + } } + candidate_syms += 1; } - if (k == candidate_syms->data_count) + if (!chosen_sym) { - assert(fallback_sym_id != -1); - chosen_sym = candidate_syms->data[fallback_sym_id]; + assert(fallback_sym); + chosen_sym = fallback_sym; } } else { + // Choose the first candidate // TODO is there a better choice? - chosen_sym = candidate_syms->data[0]; + chosen_sym = *candidate_syms; } - comp_syms_clean(candidate_syms); + free(candidate_syms); if (curr_rela_map->rela_sym_type == STT_TLS) { diff --git a/src/symbols_comp.c b/src/symbols_comp.c index d5e7fc4..f34f3f7 100644 --- a/src/symbols_comp.c +++ b/src/symbols_comp.c @@ -1,4 +1,40 @@ -#include "symbols.h" +#include "symbols_comp.h" + +/******************************************************************************* + * Forward static declarations + ******************************************************************************/ + +static void +comp_syms_clean_one_entry(void *); +static int +comp_syms_compare(const void *, const void *); +static void +comp_syms_print_one(void *); + +/******************************************************************************* + * Helper functions + ******************************************************************************/ + +static void +comp_syms_clean_one_entry(void *sym) +{ + free(sym); +} + +static int +comp_syms_compare(const void *arg, const void *item) +{ + return strcmp( + (const char *) arg, ((const comp_symbol *) item)->sym_ref->sym_name); +} + +static void +comp_syms_print_one(void *sym) +{ + comp_symbol *comp_sym = (comp_symbol *) sym; + printf("COMP SYM ADDR %p - NAME %s - LIBSYM ADDR %p\n", sym, + comp_sym->sym_ref->sym_name, (void *) comp_sym->sym_ref); +} /******************************************************************************* * Main functions @@ -8,65 +44,95 @@ comp_symbol_list * comp_syms_init() { comp_symbol_list *new_list = malloc(sizeof(comp_symbol_list)); - new_list->data_count = 0; - new_list->data = NULL; + tommy_hashtable_init(new_list, HASHTABLE_MAX_SZ); return new_list; } void comp_syms_clean(comp_symbol_list *list) { - free(list->data); + tommy_hashtable_done(list); free(list); } void comp_syms_clean_deep(comp_symbol_list *list) { - for (size_t i = 0; i < list->data_count; ++i) - { - free(list->data[i]); - } + tommy_hashtable_foreach(list, comp_syms_clean_one_entry); comp_syms_clean(list); } void comp_syms_insert(comp_symbol *to_insert, comp_symbol_list *list) { - size_t curr_count = list->data_count; - list->data = realloc(list->data, (curr_count + 1) * sizeof(comp_symbol *)); - if (list->data == NULL) - { - err(1, "Error inserting symbol %s in comp_list!", - to_insert->sym_ref->sym_name); - } - list->data[curr_count] = to_insert; - list->data_count += 1; + tommy_hashtable_insert(list, &to_insert->node, to_insert, + hashtable_hash(to_insert->sym_ref->sym_name)); } comp_symbol * -comp_syms_search(const char *to_find, const comp_symbol_list *list) +comp_syms_search(const char *to_find, comp_symbol_list *list) { - for (size_t i = 0; i < list->data_count; ++i) + comp_symbol *found = tommy_hashtable_search( + list, comp_syms_compare, to_find, hashtable_hash(to_find)); + if (!found) { - if (!strcmp(list->data[i]->sym_ref->sym_name, to_find)) - { - return list->data[i]; - } + errx(1, "Did not find symbol %s!\n", to_find); } - errx(1, "Did not find symbol %s!\n", to_find); + return found; } -comp_symbol_list * -comp_syms_find_all(const char *to_find, const comp_symbol_list *list) +comp_symbol ** +comp_syms_find_all(const char *to_find, comp_symbol_list *list) { - comp_symbol_list *res = comp_syms_init(); - for (size_t i = 0; i < list->data_count; ++i) + comp_symbol **res = calloc(MAX_FIND_ALL_COUNT, sizeof(comp_symbol *)); + unsigned int res_sz = 0; + tommy_hashtable_node *curr_node + = tommy_hashtable_bucket(list, hashtable_hash(to_find)); + while (curr_node) { - if (!strcmp(list->data[i]->sym_ref->sym_name, to_find)) + if (!strcmp( + ((comp_symbol *) curr_node->data)->sym_ref->sym_name, to_find)) { - comp_syms_insert(list->data[i], res); + res[res_sz] = (comp_symbol *) curr_node->data; + res_sz += 1; } + curr_node = curr_node->next; } + assert(res_sz < MAX_FIND_ALL_COUNT - 1); + res = realloc(res, (res_sz + 1) * sizeof(comp_symbol *)); return res; } + +/******************************************************************************* + * Specialised functions + ******************************************************************************/ + +static void +gather_defined_sym(void *arg, void *sym) +{ + lib_symbol *lib_sym = (lib_symbol *) sym; + if (lib_sym->sym_shndx != 0) + { + tommy_array_insert((tommy_array *) arg, lib_sym); + } +} + +void +update_comp_syms(comp_symbol_list *comp_syms, lib_symbol_list *lib_syms, + const size_t lib_idx) +{ + tommy_array to_update; + tommy_array_init(&to_update); + tommy_hashtable_foreach_arg(lib_syms, gather_defined_sym, &to_update); + lib_symbol *curr_sym; + comp_symbol *new_cs; + for (size_t i = 0; i < tommy_array_size(&to_update); ++i) + { + curr_sym = (lib_symbol *) tommy_array_get(&to_update, i); + new_cs = malloc(sizeof(comp_symbol)); + new_cs->sym_ref = curr_sym; + new_cs->sym_lib_idx = lib_idx; + comp_syms_insert(new_cs, comp_syms); + } + tommy_array_done(&to_update); +} diff --git a/src/symbols_lib.c b/src/symbols_lib.c index 2c48272..7a66fa1 100644 --- a/src/symbols_lib.c +++ b/src/symbols_lib.c @@ -1,10 +1,40 @@ -#include "symbols.h" +#include "symbols_lib.h" + +/******************************************************************************* + * Forward static declarations + ******************************************************************************/ + +static void +lib_syms_clean_one_entry(void *); +static int +lib_syms_compare(const void *, const void *); +static void +lib_syms_print_one(void *); + +/******************************************************************************* + * Helper functions + ******************************************************************************/ static void -lib_syms_clean_one_entry(lib_symbol *sym) +lib_syms_clean_one_entry(void *sym) { - free(sym->sym_name); - free(sym); + lib_symbol *lib_sym = (lib_symbol *) sym; + free(lib_sym->sym_name); + free(lib_sym); +} + +static int +lib_syms_compare(const void *arg, const void *item) +{ + return strcmp((const char *) arg, ((const lib_symbol *) item)->sym_name); +} + +static void +lib_syms_print_one(void *sym) +{ + lib_symbol *lib_sym = (lib_symbol *) sym; + printf("LIB SYM ADDR %p - NAME %s - OFF %p\n", sym, lib_sym->sym_name, + lib_sym->sym_offset); } /******************************************************************************* @@ -15,64 +45,66 @@ lib_symbol_list * lib_syms_init() { lib_symbol_list *new_list = malloc(sizeof(lib_symbol_list)); - new_list->data_count = 0; - new_list->data = NULL; + tommy_hashtable_init(new_list, HASHTABLE_MAX_SZ); return new_list; } void lib_syms_clean(lib_symbol_list *list) { - free(list->data); + tommy_hashtable_done(list); free(list); } void lib_syms_clean_deep(lib_symbol_list *list) { - for (size_t i = 0; i < list->data_count; ++i) - { - lib_syms_clean_one_entry(list->data[i]); - } + tommy_hashtable_foreach(list, lib_syms_clean_one_entry); lib_syms_clean(list); } void lib_syms_insert(lib_symbol *to_insert, lib_symbol_list *list) { - size_t curr_count = list->data_count; - list->data = realloc(list->data, (curr_count + 1) * sizeof(lib_symbol *)); - if (list->data == NULL) - { - err(1, "Error inserting symbol %s in lib_list!", to_insert->sym_name); - } - list->data[curr_count] = to_insert; - list->data_count += 1; + tommy_hashtable_insert( + list, &to_insert->node, to_insert, hashtable_hash(to_insert->sym_name)); } lib_symbol * -lib_syms_search(const char *to_find, const lib_symbol_list *list) +lib_syms_search(const char *to_find, lib_symbol_list *list) { - for (size_t i = 0; i < list->data_count; ++i) + lib_symbol *found = tommy_hashtable_search( + list, lib_syms_compare, to_find, hashtable_hash(to_find)); + if (!found) { - if (!strcmp(list->data[i]->sym_name, to_find)) - { - return list->data[i]; - } + errx(1, "Did not find symbol %s!\n", to_find); } - errx(1, "Did not find symbol %s!\n", to_find); + return found; } -lib_symbol_list * -lib_syms_find_all(const char *to_find, const lib_symbol_list *list) +lib_symbol ** +lib_syms_find_all(const char *to_find, lib_symbol_list *list) { - lib_symbol_list *res = lib_syms_init(); - for (size_t i = 0; i < list->data_count; ++i) + lib_symbol **res = calloc(MAX_FIND_ALL_COUNT, sizeof(lib_symbol *)); + unsigned int res_sz = 0; + tommy_hashtable_node *curr_node + = tommy_hashtable_bucket(list, hashtable_hash(to_find)); + while (curr_node) { - if (!strcmp(list->data[i]->sym_name, to_find)) + if (!strcmp(((lib_symbol *) curr_node->data)->sym_name, to_find)) { - lib_syms_insert(list->data[i], res); + res[res_sz] = (lib_symbol *) curr_node->data; + res_sz += 1; } + curr_node = curr_node->next; } + assert(res_sz < MAX_FIND_ALL_COUNT - 1); + res = realloc(res, (res_sz + 1) * sizeof(lib_symbol *)); return res; } + +void +lib_syms_print(lib_symbol_list *list) +{ + tommy_hashtable_foreach(list, lib_syms_print_one); +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9639328..46741a7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,14 +1,16 @@ # Manager executables +set(BIN_INCLUDE_DIRS ${INCLUDE_DIR} ${TOML_INCLUDE_DIR} ${TOMMYDS_DIR}) + add_executable(manager_call ${TEST_DIR}/manager_caller.c ) -target_include_directories(manager_call PUBLIC ${INCLUDE_DIR} ${TOML_INCLUDE_DIR}) +target_include_directories(manager_call PUBLIC ${BIN_INCLUDE_DIRS}) target_link_libraries(manager_call PUBLIC chcomp) add_executable(manager_args ${TEST_DIR}/manager_arg_passer.c ) -target_include_directories(manager_args PUBLIC ${INCLUDE_DIR} ${TOML_INCLUDE_DIR}) +target_include_directories(manager_args PUBLIC ${BIN_INCLUDE_DIRS}) target_link_libraries(manager_args PUBLIC chcomp) # Test properties @@ -49,7 +51,7 @@ function(new_func_test test_name) ${test_name}.c) target_link_libraries(${test_name} PRIVATE chcomp) target_include_directories(${test_name} PRIVATE - ${CMAKE_SOURCE_DIR}/src ${INCLUDE_DIR} ${TOML_INCLUDE_DIR}) + ${CMAKE_SOURCE_DIR}/src ${BIN_INCLUDE_DIRS}) endfunction() # Compartment tests diff --git a/third-party/tommyds b/third-party/tommyds new file mode 160000 index 0000000..97ff743 --- /dev/null +++ b/third-party/tommyds @@ -0,0 +1 @@ +Subproject commit 97ff74356f6d5ae899b9cb672deb803da01270ca diff --git a/third-party/tommyds-makefile b/third-party/tommyds-makefile new file mode 100644 index 0000000..de57d2c --- /dev/null +++ b/third-party/tommyds-makefile @@ -0,0 +1,10 @@ +CFLAGS += --shared -fPIC + +TARGET = libtommyds.a +SOURCES = tommy.c +OBJECTS = $(SOURCES:.c=.o) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + ar rcs $@ $^