aboutsummaryrefslogtreecommitdiffstats
path: root/gui/wxmain.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2020-08-29 19:58:08 -0400
committerClyne Sullivan <clyne@bitgloo.com>2020-08-29 19:58:08 -0400
commitd568f7ca9d7bf2d9dbf0b58d011ae8693ed6703e (patch)
tree0ea913ec1106c070b86d30a4db2b835baf7be4d3 /gui/wxmain.cpp
parent09b2c79ed6320dc6541f1edf435a01b125fe0425 (diff)
improved elf loading
Diffstat (limited to 'gui/wxmain.cpp')
-rw-r--r--gui/wxmain.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/gui/wxmain.cpp b/gui/wxmain.cpp
index c2a378a..fa9118d 100644
--- a/gui/wxmain.cpp
+++ b/gui/wxmain.cpp
@@ -181,18 +181,13 @@ void MainFrame::prepareEditor()
static const char *makefile_text = R"make(
all:
- @arm-none-eabi-g++ -x c++ -mcpu=cortex-m4 -mthumb -Os --specs=nosys.specs -nostartfiles -fPIE -c $0 -o $0.o
- @arm-none-eabi-ld -shared -n -N -z max-page-size=512 -Ttext-segment=0 \
- $0.o -o $0.so
- @arm-none-eabi-strip -s -S --strip-unneeded $0.so
- @arm-none-eabi-objcopy --remove-section .dynsym \
- --remove-section .dynstr \
- --remove-section .dynamic \
- --remove-section .hash \
- --remove-section .ARM.exidx \
- --remove-section .ARM.attributes \
- --remove-section .comment \
- $0.so
+ @arm-none-eabi-g++ -x c++ -mcpu=cortex-m4 -mthumb -Os --specs=nosys.specs -nostartfiles -fPIE $0 -o $0.o -Wl,-Ttext-segment=0 -Wl,-eprocess_data_entry -Wl,-zmax-page-size=512
+ @arm-none-eabi-strip -s -S --strip-unneeded $0.o
+ @arm-none-eabi-objcopy --remove-section .ARM.exidx \
+ --remove-section .ARM.attributes \
+ --remove-section .comment \
+ --remove-section .noinit \
+ $0.o
)make";
static const char *file_header = R"cpp(
@@ -200,10 +195,21 @@ static const char *file_header = R"cpp(
using adcsample_t = uint16_t;
-__attribute__((section(".process_data"))) void process_data(adcsample_t *samples, unsigned int size);
+static void process_data(adcsample_t *samples, unsigned int size);
-// End stmdspgui header code
+__attribute__((optimize("-O0")))
+static void *alloc(unsigned int count) {
+ void *result = nullptr;
+ asm("mov r0, %0; mov r1, %1; svc 0" :: "r" (&result), "r" (count));
+ return result;
+}
+extern "C" void process_data_entry() {
+ auto func = (void (*)())process_data;
+ func();
+}
+
+// End stmdspgui header code
)cpp";
wxString MainFrame::compileEditorCode()
@@ -223,7 +229,7 @@ wxString MainFrame::compileEditorCode()
wxString make_command = wxString("make -C ") + file_name.BeforeLast('/') +
" -f " + file_name + "make";
if (system(make_command.ToAscii()) == 0)
- return file_name + ".so";
+ return file_name + ".o";
else
return "";
}