]> code.bitgloo.com Git - bitgloo/alee-forth.git/commitdiff
msp430: reduce excess memory usage; trim linker script
authorClyne Sullivan <clyne@bitgloo.com>
Sun, 12 Nov 2023 16:13:20 +0000 (11:13 -0500)
committerClyne Sullivan <clyne@bitgloo.com>
Sun, 12 Nov 2023 16:13:20 +0000 (11:13 -0500)
libalee/dictionary.hpp
msp430/alee-msp430.cpp
msp430/msp430fr2476.ld

index 2b7afdf25e8fa2f4118e05160d1ec8c76447d723..96db2ea5e07be9d6c388d1f9001ecfbc02193a8c 100644 (file)
@@ -37,9 +37,8 @@
  *  - 0+ bytes of entry's data...
  */
 
-class Dictionary
+struct Dictionary
 {
-public:
     /**
      * The beginning of the dictionary is used for "internal" variables.
      */
@@ -129,7 +128,7 @@ public:
         return std::equal(b1, e1, b2, eqchars);
     }
 
-    virtual ~Dictionary() = default;
+    virtual ~Dictionary() {};
 
 private:
     // Case-insensitive comparison.
index 48a806eed57a371fb3fd7d2a762d2dee3eaf4905..c2706129d2cca3cf92b3a70d50b0d6fa4726a60e 100644 (file)
@@ -42,13 +42,18 @@ static void initUART();
 static void Software_Trim();
 #define MCLK_FREQ_MHZ (8)    // MCLK = 8MHz
 
-#define ALEE_RODICTSIZE (7000)
+#define ALEE_RODICTSIZE (9200)
 __attribute__((section(".lodict")))
 #include "core.fth.h"
 
 static bool exitLpm;
 static Addr isr_list[24] = {};
-static SplitMemDictRW<ALEE_RODICTSIZE, 32767> dict (alee_dat, 0x10000);
+
+using DictType = SplitMemDictRW<ALEE_RODICTSIZE, 32767>;
+
+alignas(DictType)
+static unsigned char dictbuf[sizeof(DictType)];
+static auto dict = reinterpret_cast<DictType *>(dictbuf);
 
 int main()
 {
@@ -59,7 +64,9 @@ int main()
     SYSCFG0 = FRWPPW;
 
     (void)alee_dat_len;
-    State state (dict, readchar);
+    dict->lodict = alee_dat;
+    dict->hidict = 0x10000;
+    State state (*dict, readchar);
     Parser::customParse = findword;
 
     serputs("alee forth\n\r");
@@ -371,7 +378,7 @@ bool alee_isr_handle(unsigned index)
     const Addr isr = isr_list[index];
 
     if (isr != 0) {
-        State isrstate (dict, readchar);
+        State isrstate (*dict, readchar);
         exitLpm = false;
         isrstate.execute(isr);
         return exitLpm;
index 9a2b089fc280bf1842e4aef938530b0b83ada918..08b0299f3484d53360124a6b162740dbcc9a37b1 100644 (file)
@@ -166,10 +166,8 @@ SECTIONS
   .rodata :\r
   {\r
     . = ALIGN(2);\r
-    *(.plt)\r
     *(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*)\r
     *(.rodata1)\r
-    KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)\r
   } > FRAM\r
 \r
   /* Note: This is a separate .rodata section for sections which are\r
@@ -193,8 +191,6 @@ SECTIONS
     KEEP (*(SORT(.fini_array.*)))\r
     PROVIDE (__fini_array_end = .);\r
     . = ALIGN(2);\r
-    *(.eh_frame_hdr)\r
-    KEEP (*(.eh_frame))\r
 \r
     /* gcc uses crtbegin.o to find the start of the constructors, so\r
        we make sure it is first.  Because this is a wildcard, it\r
@@ -218,17 +214,6 @@ SECTIONS
     KEEP (*(.dtors))\r
   } > FRAM\r
 \r
-  /* This section contains data that is initialised during load\r
-     but not on application reset.  */\r
-  .persistent :\r
-  {\r
-    . = ALIGN(2);\r
-    PROVIDE (__persistent_start = .);\r
-    *(.persistent)\r
-    . = ALIGN(2);\r
-    PROVIDE (__persistent_end = .);\r
-  } > FRAM\r
-\r
   .tinyram : {} > TINYRAM\r
 \r
   .data :\r
@@ -236,15 +221,10 @@ SECTIONS
     . = ALIGN(2);\r
     PROVIDE (__datastart = .);\r
 \r
-    KEEP (*(.jcr))\r
-    *(.data.rel.ro.local) *(.data.rel.ro*)\r
-    *(.dynamic)\r
-\r
     *(.data .data.* .gnu.linkonce.d.*)\r
     KEEP (*(.gnu.linkonce.d.*personality*))\r
     SORT(CONSTRUCTORS)\r
     *(.data1)\r
-    *(.got.plt) *(.got)\r
 \r
     /* We want the small data sections together, so single-instruction offsets\r
        can access them all, and initialized data all before uninitialized, so\r
@@ -268,7 +248,6 @@ SECTIONS
   {\r
     . = ALIGN(2);\r
     PROVIDE (__bssstart = .);\r
-    *(.dynbss)\r
     *(.sbss .sbss.*)\r
     *(.bss .bss.* .gnu.linkonce.b.*)\r
     . = ALIGN(2);\r
@@ -288,29 +267,6 @@ SECTIONS
     PROVIDE (__noinit_end = .);\r
   } > RAM\r
 \r
-  /* We create this section so that "end" will always be in the\r
-     RAM region (matching .stack below), even if the .bss\r
-     section is empty.  */\r
-  .heap (NOLOAD) :\r
-  {\r
-    . = ALIGN(2);\r
-    __heap_start__ = .;\r
-    _end = __heap_start__;\r
-    PROVIDE (end = .);\r
-    KEEP (*(.heap))\r
-    _end = .;\r
-    PROVIDE (end = .);\r
-    /* This word is here so that the section is not empty, and thus\r
-       not discarded by the linker.  The actual value does not matter\r
-       and is ignored.  */\r
-    LONG(0);\r
-    __heap_end__ = .;\r
-    __HeapLimit = __heap_end__;\r
-  } > RAM\r
-  /* WARNING: Do not place anything in RAM here.\r
-     The heap section must be the last section in RAM and the stack\r
-     section must be placed at the very end of the RAM region.  */\r
-\r
   .stack (ORIGIN (RAM) + LENGTH(RAM)) :\r
   {\r
     PROVIDE (__stack = .);\r
@@ -330,19 +286,9 @@ SECTIONS
     . = ALIGN(2);\r
     KEEP (*(SORT(.crt_*)))\r
 \r
-    . = ALIGN(2);\r
-    KEEP (*(.lowtext))\r
-\r
     . = ALIGN(2);\r
     *(.text .stub .text.* .gnu.linkonce.t.* .text:*)\r
 \r
-    KEEP (*(.text.*personality*))\r
-    /* .gnu.warning sections are handled specially by elf32.em.  */\r
-    *(.gnu.warning)\r
-    *(.interp .hash .dynsym .dynstr .gnu.version*)\r
-    PROVIDE (__etext = .);\r
-    PROVIDE (_etext = .);\r
-    PROVIDE (etext = .);\r
     . = ALIGN(2);\r
     KEEP (*(.init))\r
     KEEP (*(.fini))\r