Simplify app to more match Roc's controlled environment

This commit is contained in:
Brendan Hansknecht 2021-08-20 22:33:42 -07:00
parent 16c929d33a
commit b84d958a9a
3 changed files with 16 additions and 17 deletions

View file

@ -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 platform: platform.o linker.ld libapp.so
$(CXX) $(SHARED_ARGS) -L. -lapp -fPIE -T linker.ld -o $@ $< $(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 platform.o: platform.cc
$(CXX) $(SHARED_ARGS) -c -o $@ $^ $(CXX) $(SHARED_ARGS) -c -o $@ $^
app.o: app.cc
$(CXX) -fPIC -c -o $@ $^
libapp.so: app.cc libapp.so: app.cc
$(CXX) $(SHARED_ARGS) -shared -o $@ $^ $(CXX) $(SHARED_ARGS) -shared -o $@ $^

View file

@ -1,8 +1,3 @@
#include <iostream> const char* init() { return "Application initializing...\n"; }
const char* app() { return "Hello World from the application\n"; }
void init() { std::cout << "Application initializing...\n"; } const char* cleanup() { return "Cleaning up application...\n"; }
void app() { std::cout << "Hello World from the application\n"; }
int cleanup() {
std::cout << "Cleaning up application...\n";
return 0;
}

View file

@ -1,12 +1,12 @@
#include <iostream> #include <iostream>
void init(); const char* init();
void app(); const char* app();
int cleanup(); 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() { int main() {
std::cout << "Hello World from the platform\n"; 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 // Long term we want to support this case cause if it accidentially arises, we
// don't want bugs. // don't want bugs.
int (*func_pointer)(); const char* (*func_pointer)();
func_pointer = &cleanup; func_pointer = &cleanup;
return (*func_pointer)(); std::cout << (*func_pointer)();
return 0;
} }