aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2014-01-24 14:43:58 -0500
committerDJ Delorie <dj@redhat.com>2014-01-24 14:43:58 -0500
commit34b822e3bc707d31e8b8f07cfe264845bc3c6697 (patch)
treefd8a0f2278f42e1f3a26fd756dcf3528cc7669f0 /gas
parenta5262f834a754dcc37db768c1ee24d7ae52247e5 (diff)
downloadgdb-34b822e3bc707d31e8b8f07cfe264845bc3c6697.zip
gdb-34b822e3bc707d31e8b8f07cfe264845bc3c6697.tar.gz
gdb-34b822e3bc707d31e8b8f07cfe264845bc3c6697.tar.bz2
Add .data and .bss refsym symbols
For each object, if it has a nonempty .data or .bss section, emit a symbol that could cause the startup code to selectively link in the code to initialize those sections. * config/tc-msp430.c (msp430_section): Always flag data sections, regardless of -md. (msp430_frob_section): New. Make sure all sections are noticed if they have content. (msp430_lcomm): New. Flag bss if .lcomm is seen. (msp430_comm): New. Likewise. (md_pseudo_table): Add them. * config/tc-msp430.h (msp430_frob_section): Declare. (tc_frob_section): Define.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog12
-rw-r--r--gas/config/tc-msp430.c53
-rw-r--r--gas/config/tc-msp430.h7
3 files changed, 68 insertions, 4 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 8177db2..99bc518 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,15 @@
+2014-01-24 DJ Delorie <dj@redhat.com>
+
+ * config/tc-msp430.c (msp430_section): Always flag data sections,
+ regardless of -md.
+ (msp430_frob_section): New. Make sure all sections are noticed if
+ they have content.
+ (msp430_lcomm): New. Flag bss if .lcomm is seen.
+ (msp430_comm): New. Likewise.
+ (md_pseudo_table): Add them.
+ * config/tc-msp430.h (msp430_frob_section): Declare.
+ (tc_frob_section): Define.
+
2014-01-23 Nick Clifton <nickc@redhat.com>
* config/tc-msp430.c (show_mcu_list): Delete.
diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index 6c794f9..a9aa0ea 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -1220,6 +1220,18 @@ md_parse_option (int c, char * arg)
return 0;
}
+/* The intention here is to have the mere presence of these sections
+ cause the object to have a reference to a well-known symbol. This
+ reference pulls in the bits of the runtime (crt0) that initialize
+ these sections. Thus, for example, the startup code to call
+ memset() to initialize .bss will only be linked in when there is a
+ non-empty .bss section. Otherwise, the call would exist but have a
+ zero length parameter, which is a waste of memory and cycles.
+
+ The code which initializes these sections should have a global
+ label for these symbols, and should be marked with KEEP() in the
+ linker script.
+ */
static void
msp430_section (int arg)
{
@@ -1230,15 +1242,48 @@ msp430_section (int arg)
|| 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))
+ if (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);
}
+void
+msp430_frob_section (asection *sec)
+{
+ const char *name = sec->name;
+
+ if (sec->size == 0)
+ return;
+
+ if (strncmp (name, ".bss", 4) == 0
+ || strncmp (name, ".gnu.linkonce.b.", 16) == 0)
+ (void) symbol_find_or_make ("__crt0_init_bss");
+
+ if (strncmp (name, ".data", 5) == 0
+ || strncmp (name, ".gnu.linkonce.d.", 16) == 0)
+ (void) symbol_find_or_make ("__crt0_movedata");
+}
+
+static void
+msp430_lcomm (int ignore ATTRIBUTE_UNUSED)
+{
+ symbolS *symbolP = s_comm_internal (0, s_lcomm_internal);
+
+ if (symbolP)
+ symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT;
+ (void) symbol_find_or_make ("__crt0_init_bss");
+}
+
+static void
+msp430_comm (int needs_align)
+{
+ s_comm_internal (needs_align, elf_common_parse);
+ (void) symbol_find_or_make ("__crt0_init_bss");
+}
+
static void
msp430_refsym (int arg ATTRIBUTE_UNUSED)
{
@@ -1259,6 +1304,8 @@ const pseudo_typeS md_pseudo_table[] =
{"sect.s", msp430_section, 0},
{"pushsection", msp430_section, 1},
{"refsym", msp430_refsym, 0},
+ {"comm", msp430_comm, 0},
+ {"lcomm", msp430_lcomm, 0},
{NULL, NULL, 0}
};
diff --git a/gas/config/tc-msp430.h b/gas/config/tc-msp430.h
index f805f66..5f14bbf 100644
--- a/gas/config/tc-msp430.h
+++ b/gas/config/tc-msp430.h
@@ -1,5 +1,5 @@
/* This file is tc-msp430.h
- Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ Copyright (C) 2002-2014 Free Software Foundation, Inc.
Contributed by Dmitry Diky <diwil@mail.ru>
@@ -120,6 +120,11 @@ extern long msp430_relax_frag (segT, fragS *, long);
msp430_force_relocation_local (FIX)
extern int msp430_force_relocation_local (struct fix *);
+/* We need to add reference symbols for .data/.bss. */
+#define tc_frob_section(sec) msp430_frob_section (sec)
+extern void msp430_frob_section (asection *);
+
+
extern int msp430_enable_relax;
extern int msp430_enable_polys;