msp430: reduce excess memory usage; trim linker script

master
Clyne 1 year ago
parent f8f73362a8
commit 69152efdad
Signed by: clyne
GPG Key ID: 3267C8EBF3F9AFC7

@ -37,9 +37,8 @@
* - 0+ bytes of entry's data... * - 0+ bytes of entry's data...
*/ */
class Dictionary struct Dictionary
{ {
public:
/** /**
* The beginning of the dictionary is used for "internal" variables. * The beginning of the dictionary is used for "internal" variables.
*/ */
@ -129,7 +128,7 @@ public:
return std::equal(b1, e1, b2, eqchars); return std::equal(b1, e1, b2, eqchars);
} }
virtual ~Dictionary() = default; virtual ~Dictionary() {};
private: private:
// Case-insensitive comparison. // Case-insensitive comparison.

@ -42,13 +42,18 @@ static void initUART();
static void Software_Trim(); static void Software_Trim();
#define MCLK_FREQ_MHZ (8) // MCLK = 8MHz #define MCLK_FREQ_MHZ (8) // MCLK = 8MHz
#define ALEE_RODICTSIZE (7000) #define ALEE_RODICTSIZE (9200)
__attribute__((section(".lodict"))) __attribute__((section(".lodict")))
#include "core.fth.h" #include "core.fth.h"
static bool exitLpm; static bool exitLpm;
static Addr isr_list[24] = {}; 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() int main()
{ {
@ -59,7 +64,9 @@ int main()
SYSCFG0 = FRWPPW; SYSCFG0 = FRWPPW;
(void)alee_dat_len; (void)alee_dat_len;
State state (dict, readchar); dict->lodict = alee_dat;
dict->hidict = 0x10000;
State state (*dict, readchar);
Parser::customParse = findword; Parser::customParse = findword;
serputs("alee forth\n\r"); serputs("alee forth\n\r");
@ -371,7 +378,7 @@ bool alee_isr_handle(unsigned index)
const Addr isr = isr_list[index]; const Addr isr = isr_list[index];
if (isr != 0) { if (isr != 0) {
State isrstate (dict, readchar); State isrstate (*dict, readchar);
exitLpm = false; exitLpm = false;
isrstate.execute(isr); isrstate.execute(isr);
return exitLpm; return exitLpm;

@ -166,10 +166,8 @@ SECTIONS
.rodata : .rodata :
{ {
. = ALIGN(2); . = ALIGN(2);
*(.plt)
*(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*) *(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*)
*(.rodata1) *(.rodata1)
KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
} > FRAM } > FRAM
/* Note: This is a separate .rodata section for sections which are /* Note: This is a separate .rodata section for sections which are
@ -193,8 +191,6 @@ SECTIONS
KEEP (*(SORT(.fini_array.*))) KEEP (*(SORT(.fini_array.*)))
PROVIDE (__fini_array_end = .); PROVIDE (__fini_array_end = .);
. = ALIGN(2); . = ALIGN(2);
*(.eh_frame_hdr)
KEEP (*(.eh_frame))
/* gcc uses crtbegin.o to find the start of the constructors, so /* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it we make sure it is first. Because this is a wildcard, it
@ -218,17 +214,6 @@ SECTIONS
KEEP (*(.dtors)) KEEP (*(.dtors))
} > FRAM } > FRAM
/* This section contains data that is initialised during load
but not on application reset. */
.persistent :
{
. = ALIGN(2);
PROVIDE (__persistent_start = .);
*(.persistent)
. = ALIGN(2);
PROVIDE (__persistent_end = .);
} > FRAM
.tinyram : {} > TINYRAM .tinyram : {} > TINYRAM
.data : .data :
@ -236,15 +221,10 @@ SECTIONS
. = ALIGN(2); . = ALIGN(2);
PROVIDE (__datastart = .); PROVIDE (__datastart = .);
KEEP (*(.jcr))
*(.data.rel.ro.local) *(.data.rel.ro*)
*(.dynamic)
*(.data .data.* .gnu.linkonce.d.*) *(.data .data.* .gnu.linkonce.d.*)
KEEP (*(.gnu.linkonce.d.*personality*)) KEEP (*(.gnu.linkonce.d.*personality*))
SORT(CONSTRUCTORS) SORT(CONSTRUCTORS)
*(.data1) *(.data1)
*(.got.plt) *(.got)
/* We want the small data sections together, so single-instruction offsets /* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so can access them all, and initialized data all before uninitialized, so
@ -268,7 +248,6 @@ SECTIONS
{ {
. = ALIGN(2); . = ALIGN(2);
PROVIDE (__bssstart = .); PROVIDE (__bssstart = .);
*(.dynbss)
*(.sbss .sbss.*) *(.sbss .sbss.*)
*(.bss .bss.* .gnu.linkonce.b.*) *(.bss .bss.* .gnu.linkonce.b.*)
. = ALIGN(2); . = ALIGN(2);
@ -288,29 +267,6 @@ SECTIONS
PROVIDE (__noinit_end = .); PROVIDE (__noinit_end = .);
} > RAM } > RAM
/* We create this section so that "end" will always be in the
RAM region (matching .stack below), even if the .bss
section is empty. */
.heap (NOLOAD) :
{
. = ALIGN(2);
__heap_start__ = .;
_end = __heap_start__;
PROVIDE (end = .);
KEEP (*(.heap))
_end = .;
PROVIDE (end = .);
/* This word is here so that the section is not empty, and thus
not discarded by the linker. The actual value does not matter
and is ignored. */
LONG(0);
__heap_end__ = .;
__HeapLimit = __heap_end__;
} > RAM
/* WARNING: Do not place anything in RAM here.
The heap section must be the last section in RAM and the stack
section must be placed at the very end of the RAM region. */
.stack (ORIGIN (RAM) + LENGTH(RAM)) : .stack (ORIGIN (RAM) + LENGTH(RAM)) :
{ {
PROVIDE (__stack = .); PROVIDE (__stack = .);
@ -330,19 +286,9 @@ SECTIONS
. = ALIGN(2); . = ALIGN(2);
KEEP (*(SORT(.crt_*))) KEEP (*(SORT(.crt_*)))
. = ALIGN(2);
KEEP (*(.lowtext))
. = ALIGN(2); . = ALIGN(2);
*(.text .stub .text.* .gnu.linkonce.t.* .text:*) *(.text .stub .text.* .gnu.linkonce.t.* .text:*)
KEEP (*(.text.*personality*))
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.interp .hash .dynsym .dynstr .gnu.version*)
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
. = ALIGN(2); . = ALIGN(2);
KEEP (*(.init)) KEEP (*(.init))
KEEP (*(.fini)) KEEP (*(.fini))

Loading…
Cancel
Save