From b84d958a9af19926070f593e5cdcbe0bbd2ea61a Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Fri, 20 Aug 2021 22:33:42 -0700 Subject: [PATCH] Simplify app to more match Roc's controlled environment --- linker/tests/Makefile | 7 +++++-- linker/tests/app.cc | 11 +++-------- linker/tests/platform.cc | 15 ++++++++------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/linker/tests/Makefile b/linker/tests/Makefile index 5f78650e36..a61394c27a 100644 --- a/linker/tests/Makefile +++ b/linker/tests/Makefile @@ -1,6 +1,6 @@ -SHARED_ARGS = -fPIC -ffunction-sections +SHARED_ARGS = -fPIC -ffunction-sections -all: platform +all: platform app.o platform: platform.o linker.ld libapp.so $(CXX) $(SHARED_ARGS) -L. -lapp -fPIE -T linker.ld -o $@ $< @@ -8,6 +8,9 @@ platform: platform.o linker.ld libapp.so platform.o: platform.cc $(CXX) $(SHARED_ARGS) -c -o $@ $^ +app.o: app.cc + $(CXX) -fPIC -c -o $@ $^ + libapp.so: app.cc $(CXX) $(SHARED_ARGS) -shared -o $@ $^ diff --git a/linker/tests/app.cc b/linker/tests/app.cc index 9ffcae0ff6..15c93d0806 100644 --- a/linker/tests/app.cc +++ b/linker/tests/app.cc @@ -1,8 +1,3 @@ -#include - -void init() { std::cout << "Application initializing...\n"; } -void app() { std::cout << "Hello World from the application\n"; } -int cleanup() { - std::cout << "Cleaning up application...\n"; - return 0; -} +const char* init() { return "Application initializing...\n"; } +const char* app() { return "Hello World from the application\n"; } +const char* cleanup() { return "Cleaning up application...\n"; } diff --git a/linker/tests/platform.cc b/linker/tests/platform.cc index 7f2c271407..4e0711528b 100644 --- a/linker/tests/platform.cc +++ b/linker/tests/platform.cc @@ -1,12 +1,12 @@ #include -void init(); -void app(); -int cleanup(); +const char* init(); +const char* app(); +const char* cleanup(); -void func_section_1() { init(); } +void func_section_1() { std::cout << init(); } -void func_section_2() { app(); } +void func_section_2() { std::cout << app(); } int main() { std::cout << "Hello World from the platform\n"; @@ -15,7 +15,8 @@ int main() { // Long term we want to support this case cause if it accidentially arises, we // don't want bugs. - int (*func_pointer)(); + const char* (*func_pointer)(); func_pointer = &cleanup; - return (*func_pointer)(); + std::cout << (*func_pointer)(); + return 0; } \ No newline at end of file