diff --git a/rewriter/tests/CMakeLists.txt b/rewriter/tests/CMakeLists.txt index d93c9827bb..838cc13a88 100644 --- a/rewriter/tests/CMakeLists.txt +++ b/rewriter/tests/CMakeLists.txt @@ -45,6 +45,7 @@ add_subdirectory(heap_two_keys) # add_subdirectory(libusb) add_subdirectory(macro_attr) add_subdirectory(minimal) +add_subdirectory(minimal_arm) add_subdirectory(mmap_loop) # TODO: support C++ namespaces #add_subdirectory(namespaces) diff --git a/rewriter/tests/minimal_arm/CMakeLists.txt b/rewriter/tests/minimal_arm/CMakeLists.txt new file mode 100644 index 0000000000..e0dfe47b5b --- /dev/null +++ b/rewriter/tests/minimal_arm/CMakeLists.txt @@ -0,0 +1,11 @@ +# Build the wrapped lib +define_shared_lib(SRCS minimal.c) + +# Build the test +define_test( + SRCS main.c + NEEDS_LD_WRAP +) + +# Build the wrapper lib +define_ia2_wrapper() diff --git a/rewriter/tests/minimal_arm/Output/minimal.out b/rewriter/tests/minimal_arm/Output/minimal.out new file mode 100644 index 0000000000..257cc5642c --- /dev/null +++ b/rewriter/tests/minimal_arm/Output/minimal.out @@ -0,0 +1 @@ +foo diff --git a/rewriter/tests/minimal_arm/include/minimal.h b/rewriter/tests/minimal_arm/include/minimal.h new file mode 100644 index 0000000000..b55f1ff740 --- /dev/null +++ b/rewriter/tests/minimal_arm/include/minimal.h @@ -0,0 +1,10 @@ +#pragma once + +// This function does nothing +void foo(); + +// This returns an integer +int return_val(); + +// This takes an integer +void arg1(int x); diff --git a/rewriter/tests/minimal_arm/main.c b/rewriter/tests/minimal_arm/main.c new file mode 100644 index 0000000000..0d52a46385 --- /dev/null +++ b/rewriter/tests/minimal_arm/main.c @@ -0,0 +1,18 @@ +/* +RUN: sh -c 'if [ ! -s "minimal_call_gates_0.ld" ]; then echo "No link args as expected"; exit 0; fi; echo "Unexpected link args"; exit 1;' +*/ + +// Check that readelf shows exactly one executable segment + +#include "minimal.h" +#include +#include + +INIT_RUNTIME(1); +#define IA2_COMPARTMENT 1 +#include + +int main() { + printf("Calling foo"); + foo(); +} diff --git a/rewriter/tests/minimal_arm/minimal.c b/rewriter/tests/minimal_arm/minimal.c new file mode 100644 index 0000000000..f8db4f9b0f --- /dev/null +++ b/rewriter/tests/minimal_arm/minimal.c @@ -0,0 +1,23 @@ +/* +RUN: cat minimal_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s +*/ + +#include "minimal.h" +#include + +// LINKARGS: --wrap=arg1 +void arg1(int x) { + printf("arg1"); +} + +// LINKARGS: --wrap=foo +void foo() { + printf("foo"); +} + +// LINKARGS: --wrap=return_val +int return_val() { + printf("return_val"); + return 1; +} +