This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Commit: MSP430: Add -md command line option
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Wed, 18 Sep 2013 08:49:29 +0100
- Subject: Commit: MSP430: Add -md command line option
- Authentication-results: sourceware.org; auth=none
Hi Guys,
I am applying the patch below to add a new command line option to the
MSP430 port of GAS. This option: -md tells the assembler that it
should generate a special symbol if it sees the .data section being
used. This symbol is then referenced by the libcrt.a library (from
libgloss) and causes the start up code to include a loop to copy
writable data from ROM to RAM.
Cheers
Nick
gas/ChangeLog
2013-09-18 Nick Clifton <nickc@redhat.com>
* 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.
Index: gas/config/tc-msp430.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-msp430.c,v
retrieving revision 1.37
diff -u -3 -p -r1.37 tc-msp430.c
--- gas/config/tc-msp430.c 25 Jun 2013 08:21:43 -0000 1.37
+++ gas/config/tc-msp430.c 18 Sep 2013 07:21:14 -0000
@@ -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
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
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
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);
Index: gas/doc/c-msp430.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/c-msp430.texi,v
retrieving revision 1.9
diff -u -3 -p -r1.9 c-msp430.texi
--- gas/doc/c-msp430.texi 16 May 2013 16:47:14 -0000 1.9
+++ gas/doc/c-msp430.texi 18 Sep 2013 07:21:14 -0000
@@ -57,6 +57,10 @@ instruction happens automatically, but t
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