From b456fe2652d5b79dd2923206a0c96f23b35d44de Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Mon, 10 Jul 2017 16:53:05 +0000 Subject: [PATCH 4/4] MSP430: Define symbols to initialise high data and high bss when the upper data region could be used --- gas/config/tc-msp430.c | 23 ++++++++++++++++++++--- gas/doc/c-msp430.texi | 13 +++++++++++++ gas/testsuite/gas/msp430/high-data-bss-sym.d | 6 ++++++ gas/testsuite/gas/msp430/high-data-bss-sym.s | 19 +++++++++++++++++++ gas/testsuite/gas/msp430/msp430.exp | 2 ++ 5 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 gas/testsuite/gas/msp430/high-data-bss-sym.d create mode 100644 gas/testsuite/gas/msp430/high-data-bss-sym.s diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c index 91e0a73..62a34ed 100644 --- a/gas/config/tc-msp430.c +++ b/gas/config/tc-msp430.c @@ -676,6 +676,8 @@ static bfd_boolean warn_interrupt_nops = TRUE; #define OPTION_MCPU 'c' #define OPTION_MOVE_DATA 'd' static bfd_boolean move_data = FALSE; +#define OPTION_DATA_REGION 'r' +static bfd_boolean upper_data_region_in_use = FALSE; enum { @@ -1448,6 +1450,12 @@ md_parse_option (int c, const char * arg) case OPTION_MOVE_DATA: move_data = TRUE; return 1; + + case OPTION_DATA_REGION: + if (strcmp (arg, "upper") == 0 + || strcmp (arg, "either") == 0) + upper_data_region_in_use = TRUE; + return 1; } return 0; @@ -1478,14 +1486,19 @@ msp430_make_init_symbols (const char * name) /* Note - data assigned to the .either.data section may end up being placed in the .upper.data section if the .lower.data section is - full. Hence the need to define the crt0 symbol. */ + full. Hence the need to define the crt0 symbol. + The linker may create upper or either data sections, even when none exist + at the moment, so use the value of the data-region flag to determine if + the symbol is needed. */ if (strncmp (name, ".either.data", 12) == 0 - || strncmp (name, ".upper.data", 11) == 0) + || strncmp (name, ".upper.data", 11) == 0 + || upper_data_region_in_use) (void) symbol_find_or_make ("__crt0_move_highdata"); /* See note about .either.data above. */ if (strncmp (name, ".upper.bss", 10) == 0 - || strncmp (name, ".either.bss", 11) == 0) + || strncmp (name, ".either.bss", 11) == 0 + || upper_data_region_in_use) (void) symbol_find_or_make ("__crt0_init_highbss"); } @@ -1570,6 +1583,7 @@ struct option md_longopts[] = {"mY", no_argument, NULL, OPTION_NO_WARN_INTR_NOPS}, {"my", no_argument, NULL, OPTION_WARN_INTR_NOPS}, {"md", no_argument, NULL, OPTION_MOVE_DATA}, + {"mdata-region", required_argument, NULL, OPTION_DATA_REGION}, {NULL, no_argument, NULL, 0} }; @@ -1601,6 +1615,9 @@ md_show_usage (FILE * stream) _(" -my - warn about missing NOPs after changing interrupts (default)\n")); fprintf (stream, _(" -md - Force copying of data from ROM to RAM at startup\n")); + fprintf (stream, + _(" -mdata-region={none|lower|upper|either} - select region data will be\n" + " placed in.\n")); } symbolS * diff --git a/gas/doc/c-msp430.texi b/gas/doc/c-msp430.texi index eb0e757..76399a6 100644 --- a/gas/doc/c-msp430.texi +++ b/gas/doc/c-msp430.texi @@ -107,6 +107,19 @@ disables warnings about missing NOP instructions. mark the object file as one that requires data to copied from ROM to RAM at execution startup. Disabled by default. +@item -mdata-region=@var{region} +Select the region data will be placed in. +Region placement is performed by the compiler and linker. The only effect this +option will have on the assembler is that if @var{upper} or @var{either} is +selected, then the symbols to initialise high data and bss will be defined. +Valid @var{region} values are: +@table @code +@item none +@item lower +@item upper +@item either +@end table + @end table @node MSP430 Syntax diff --git a/gas/testsuite/gas/msp430/high-data-bss-sym.d b/gas/testsuite/gas/msp430/high-data-bss-sym.d new file mode 100644 index 0000000..1c8d95b --- /dev/null +++ b/gas/testsuite/gas/msp430/high-data-bss-sym.d @@ -0,0 +1,6 @@ +#objdump: -t +#name: Check symbols to initialise high data and high bss have been defined +#... +.*__crt0_move_highdata.* +.*__crt0_init_highbss.* +#pass diff --git a/gas/testsuite/gas/msp430/high-data-bss-sym.s b/gas/testsuite/gas/msp430/high-data-bss-sym.s new file mode 100644 index 0000000..1e6bf72 --- /dev/null +++ b/gas/testsuite/gas/msp430/high-data-bss-sym.s @@ -0,0 +1,19 @@ + .file "main.c" +.text + .balign 2 + .global main + .type main, @function +main: +; start of function +; framesize_regs: 0 +; framesize_locals: 0 +; framesize_outgoing: 0 +; framesize: 0 +; elim ap -> fp 2 +; elim fp -> sp 0 +; saved regs:(none) + ; start of prologue + ; end of prologue +.L2: + BR #.L2 + .size main, .-main diff --git a/gas/testsuite/gas/msp430/msp430.exp b/gas/testsuite/gas/msp430/msp430.exp index b83e1ac..0dfb271 100644 --- a/gas/testsuite/gas/msp430/msp430.exp +++ b/gas/testsuite/gas/msp430/msp430.exp @@ -24,4 +24,6 @@ if [expr [istarget "msp430-*-*"]] then { run_dump_test "bad" run_dump_test "errata_warns" run_dump_test "errata_fixes" + run_dump_test "high-data-bss-sym" { { as "-mdata-region=upper" } } + run_dump_test "high-data-bss-sym" { { as "-mdata-region=either" } } } -- 1.8.3.1