From ab90591541a18371d9676ce8d731ff50d4f74a90 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 18 Sep 2013 07:50:34 +0000 Subject: [PATCH] * config/tc-msp430.c (OPTION_MOVE_DATA): Define. (move_data): New variable. (md_parse_option): Parse -md. (msp430_section): New function. Catch references to the .bss or .data sections and generate a special symbol for use by the libcrt library. (md_pseudo_table): Intercept .section directives. (md_longopt): Add -md (md_show_usage): Likewise. (msp430_operands): Generate a warning message if a NOP is inserted into the instruction stream. * doc/c-msp430.texi (node MSP430 Options): Document -md option. --- gas/ChangeLog | 17 ++++++++++++++++- gas/config/tc-msp430.c | 39 +++++++++++++++++++++++++++++++++++++++ gas/doc/c-msp430.texi | 4 ++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 2ec87a13288..62e136e4766 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,7 +1,22 @@ +2013-09-18 Nick Clifton + + * config/tc-msp430.c (OPTION_MOVE_DATA): Define. + (move_data): New variable. + (md_parse_option): Parse -md. + (msp430_section): New function. Catch references to the .bss or + .data sections and generate a special symbol for use by the libcrt + library. + (md_pseudo_table): Intercept .section directives. + (md_longopt): Add -md + (md_show_usage): Likewise. + (msp430_operands): Generate a warning message if a NOP is inserted + into the instruction stream. + * doc/c-msp430.texi (node MSP430 Options): Document -md option. + 2013-09-17 Doug Gilmore * config/tc-mips.c (mips_elf_final_processing): Set - EF_MIPS_FP64 for -mgp32 -mfp64, removing old FIXME. + EF_MIPS_FP64 for -mgp32 -mfp64, removing old FIXME. 2013-09-16 Will Newton diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c index e16fcd95278..4f34a37e983 100644 --- a/gas/config/tc-msp430.c +++ b/gas/config/tc-msp430.c @@ -1123,6 +1123,8 @@ static bfd_boolean large_model = FALSE; #define OPTION_NO_INTR_NOPS 'N' static bfd_boolean gen_interrupt_nops = TRUE; #define OPTION_MCPU 'c' +#define OPTION_MOVE_DATA 'd' +static bfd_boolean move_data = FALSE; static void msp430_set_arch (int option) @@ -1210,16 +1212,44 @@ md_parse_option (int c, char * arg) case OPTION_NO_INTR_NOPS: gen_interrupt_nops = FALSE; return 1; + + case OPTION_MOVE_DATA: + move_data = TRUE; + return 1; } return 0; } +static void +msp430_section (int arg) +{ + char * saved_ilp = input_line_pointer; + char * name = obj_elf_section_name (); + + if (strncmp (name, ".bss", 4) == 0 + || strncmp (name, ".gnu.linkonce.b.", 16) == 0) + (void) symbol_find_or_make ("__crt0_init_bss"); + + if (move_data + && (strncmp (name, ".data", 5) == 0 + || strncmp (name, ".gnu.linkonce.d.", 16) == 0)) + (void) symbol_find_or_make ("__crt0_movedata"); + + input_line_pointer = saved_ilp; + obj_elf_section (arg); +} + const pseudo_typeS md_pseudo_table[] = { {"arch", msp430_set_arch, OPTION_MMCU}, {"cpu", msp430_set_arch, OPTION_MCPU}, {"profiler", msp430_profiler, 0}, + {"section", msp430_section, 0}, + {"section.s", msp430_section, 0}, + {"sect", msp430_section, 0}, + {"sect.s", msp430_section, 0}, + {"pushsection", msp430_section, 1}, {NULL, NULL, 0} }; @@ -1233,6 +1263,7 @@ struct option md_longopts[] = {"mQ", no_argument, NULL, OPTION_RELAX}, {"ml", no_argument, NULL, OPTION_LARGE}, {"mN", no_argument, NULL, OPTION_NO_INTR_NOPS}, + {"md", no_argument, NULL, OPTION_MOVE_DATA}, {NULL, no_argument, NULL, 0} }; @@ -1252,6 +1283,8 @@ md_show_usage (FILE * stream) _(" -ml - enable large code model\n")); fprintf (stream, _(" -mN - disable generation of NOP after changing interrupts\n")); + fprintf (stream, + _(" -md - Force copying of data from ROM to RAM at startup\n")); show_mcu_list (stream); } @@ -2201,6 +2234,8 @@ msp430_operands (struct msp430_opcode_s * opcode, char * line) See 1.3.4.1 of the MSP430x5xx User Guide. */ insn_length += 2; frag = frag_more (2); + as_warn (_("a NOP instruction has been inserted after %s"), + opcode->name); bfd_putl16 ((bfd_vma) 0x4303 /* NOP */, frag); } dwarf2_emit_insn (insn_length); @@ -2285,6 +2320,8 @@ msp430_operands (struct msp430_opcode_s * opcode, char * line) insn_length += 2; frag = frag_more (2); bfd_putl16 ((bfd_vma) 0x4303 /* NOP */, frag); + as_warn (_("a NOP instruction has been inserted after %s"), + opcode->name); } dwarf2_emit_insn (insn_length); @@ -3041,6 +3078,8 @@ msp430_operands (struct msp430_opcode_s * opcode, char * line) insn_length += 2; frag = frag_more (2); bfd_putl16 ((bfd_vma) 0x4303 /* NOP */, frag); + as_warn (_("a NOP instruction has been inserted after %s"), + opcode->name); } dwarf2_emit_insn (insn_length); diff --git a/gas/doc/c-msp430.texi b/gas/doc/c-msp430.texi index 538133a6de1..2927add4bbc 100644 --- a/gas/doc/c-msp430.texi +++ b/gas/doc/c-msp430.texi @@ -57,6 +57,10 @@ instruction happens automatically, but this command line option disables this behaviour. It is then up to the programmer to ensure that interrupts are enabled and disabled correctly. +@item -md +mark the object file as one that requires data to copied from ROM to +RAM at execution startup. Disabled by default. + @end table @node MSP430 Syntax -- 2.30.2