aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2000-09-15 18:52:52 +0000
committerNick Clifton <nickc@redhat.com>2000-09-15 18:52:52 +0000
commit0752970ef843fa6a9e7ac8bb5a30608eded7f228 (patch)
tree681414cd31e8fe3f2fb29df4cbcd4c91520f64b3 /ld
parentffcb7aff0f99aaa26b99e04b8258009279096402 (diff)
downloadgdb-0752970ef843fa6a9e7ac8bb5a30608eded7f228.zip
gdb-0752970ef843fa6a9e7ac8bb5a30608eded7f228.tar.gz
gdb-0752970ef843fa6a9e7ac8bb5a30608eded7f228.tar.bz2
add support for embedded relocs in m68k ELF port
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/Makefile.am3
-rw-r--r--ld/Makefile.in3
-rw-r--r--ld/emulparams/m68kelf.sh1
-rw-r--r--ld/emultempl/m68kelf.em154
-rw-r--r--ld/po/ld.pot58
6 files changed, 197 insertions, 29 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4b12001..c77f8f8 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2000-09-10 Michael Sokolov <msokolov@ivan.Harhan.ORG>
+
+ * emultempl/m68kelf.em: New file.
+ * emulparams/m68kelf.sh (EXTRA_EM_FILE): Use it.
+ * Makefile.am (em68kelf.c): Add dependency on m68kelf.em.
+ * Makefile.in: Regenerate.
+
2000-09-15 Alan Modra <alan@linuxcare.com.au>
* emulparams/hppalinux.sh (DATA_START_SYMBOLS): Provide $global$
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 2bd3850..abb3f13 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -615,7 +615,8 @@ em68kcoff.c: $(srcdir)/emulparams/m68kcoff.sh \
$(srcdir)/emultempl/m68kcoff.em $(srcdir)/scripttempl/m68kcoff.sc ${GEN_DEPENDS}
${GENSCRIPTS} m68kcoff "$(tdir_m68kcoff)"
em68kelf.c: $(srcdir)/emulparams/m68kelf.sh \
- $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+ $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/m68kelf.em \
+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} m68kelf "$(tdir_m68kelf)"
em68klinux.c: $(srcdir)/emulparams/m68klinux.sh \
$(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 5b2c8e8..125aaf1 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -1329,7 +1329,8 @@ em68kcoff.c: $(srcdir)/emulparams/m68kcoff.sh \
$(srcdir)/emultempl/m68kcoff.em $(srcdir)/scripttempl/m68kcoff.sc ${GEN_DEPENDS}
${GENSCRIPTS} m68kcoff "$(tdir_m68kcoff)"
em68kelf.c: $(srcdir)/emulparams/m68kelf.sh \
- $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+ $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/m68kelf.em \
+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} m68kelf "$(tdir_m68kelf)"
em68klinux.c: $(srcdir)/emulparams/m68klinux.sh \
$(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
diff --git a/ld/emulparams/m68kelf.sh b/ld/emulparams/m68kelf.sh
index ad352c5..a27f63c 100644
--- a/ld/emulparams/m68kelf.sh
+++ b/ld/emulparams/m68kelf.sh
@@ -7,4 +7,5 @@ ARCH=m68k
MACHINE=
NOP=0x4e75
TEMPLATE_NAME=elf32
+EXTRA_EM_FILE=m68kelf
GENERATE_SHLIB_SCRIPT=yes
diff --git a/ld/emultempl/m68kelf.em b/ld/emultempl/m68kelf.em
new file mode 100644
index 0000000..a5e0373
--- /dev/null
+++ b/ld/emultempl/m68kelf.em
@@ -0,0 +1,154 @@
+# This shell script emits a C file. -*- C -*-
+# Copyright (C) 2000 Free Software Foundation, Inc.
+# Written by Michael Sokolov <msokolov@ivan.Harhan.ORG>, based on armelf.em
+#
+# This file is part of GLD, the Gnu Linker.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+# This file is sourced from elf32.em, and defines extra m68k ELF
+# specific routines.
+#
+cat >>e${EMULATION_NAME}.c <<EOF
+
+static void m68k_elf_after_open PARAMS((void));
+static void check_sections PARAMS ((bfd *, asection *, PTR));
+static void m68k_elf_after_allocation PARAMS ((void));
+
+/* This function is run after all the input files have been opened.
+ We create a .emreloc section for each input file with a non zero
+ .data section. The BFD backend will fill in these sections with
+ magic numbers which can be used to relocate the data section at run
+ time. */
+
+static void
+m68k_elf_after_open ()
+{
+ bfd *abfd;
+
+ /* Call the standard elf routine. */
+ gld${EMULATION_NAME}_after_open ();
+
+ if (! command_line.embedded_relocs
+ || link_info.relocateable)
+ return;
+
+ for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
+ {
+ asection *datasec;
+
+ /* As first-order business, make sure that each input BFD is ELF. It
+ better be, as we are directly calling a ELF backend function. */
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+ einfo ("%F%B: all input objects must be ELF for --embedded-relocs\n");
+
+ datasec = bfd_get_section_by_name (abfd, ".data");
+
+ /* Note that we assume that the reloc_count field has already
+ been set up. We could call bfd_get_reloc_upper_bound, but
+ that returns the size of a memory buffer rather than a reloc
+ count. We do not want to call bfd_canonicalize_reloc,
+ because although it would always work it would force us to
+ read in the relocs into BFD canonical form, which would waste
+ a significant amount of time and memory. */
+ if (datasec != NULL && datasec->reloc_count > 0)
+ {
+ asection *relsec;
+
+ relsec = bfd_make_section (abfd, ".emreloc");
+ if (relsec == NULL
+ || ! bfd_set_section_flags (abfd, relsec,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY))
+ || ! bfd_set_section_alignment (abfd, relsec, 2)
+ || ! bfd_set_section_size (abfd, relsec,
+ datasec->reloc_count * 12))
+ einfo ("%F%B: can not create .emreloc section: %E\n");
+ }
+
+ /* Double check that all other data sections are empty, as is
+ required for embedded PIC code. */
+ bfd_map_over_sections (abfd, check_sections, (PTR) datasec);
+ }
+}
+
+/* Check that of the data sections, only the .data section has
+ relocs. This is called via bfd_map_over_sections. */
+
+static void
+check_sections (abfd, sec, datasec)
+ bfd *abfd;
+ asection *sec;
+ PTR datasec;
+{
+ if ((bfd_get_section_flags (abfd, sec) & SEC_DATA)
+ && sec != (asection *) datasec
+ && sec->reloc_count != 0)
+ einfo ("%B%X: section %s has relocs; can not use --embedded-relocs\n",
+ abfd, bfd_get_section_name (abfd, sec));
+}
+
+/* This function is called after the section sizes and offsets have
+ been set. If we are generating embedded relocs, it calls a special
+ BFD backend routine to do the work. */
+
+static void
+m68k_elf_after_allocation ()
+{
+ bfd *abfd;
+
+ /* Call the standard elf routine. */
+ gld${EMULATION_NAME}_before_allocation ();
+
+ if (! command_line.embedded_relocs
+ || link_info.relocateable)
+ return;
+
+ for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
+ {
+ asection *datasec, *relsec;
+ char *errmsg;
+
+ datasec = bfd_get_section_by_name (abfd, ".data");
+
+ if (datasec == NULL || datasec->reloc_count == 0)
+ continue;
+
+ relsec = bfd_get_section_by_name (abfd, ".emreloc");
+ ASSERT (relsec != NULL);
+
+ if (! bfd_m68k_elf32_create_embedded_relocs (abfd, &link_info,
+ datasec, relsec,
+ &errmsg))
+ {
+ if (errmsg == NULL)
+ einfo ("%B%X: can not create runtime reloc information: %E\n",
+ abfd);
+ else
+ einfo ("%X%B: can not create runtime reloc information: %s\n",
+ abfd, errmsg);
+ }
+ }
+}
+
+EOF
+
+# We have our own after_open and after_allocation functions, but they call
+# the standard routines, so give them a different name.
+LDEMUL_AFTER_OPEN=m68k_elf_after_open
+LDEMUL_AFTER_ALLOCATION=m68k_elf_after_allocation
diff --git a/ld/po/ld.pot b/ld/po/ld.pot
index e66a238..fac2eec 100644
--- a/ld/po/ld.pot
+++ b/ld/po/ld.pot
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2000-09-05 14:40-0700\n"
+"POT-Creation-Date: 2000-09-15 11:43-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -233,7 +233,7 @@ msgstr ""
msgid "Errors encountered processing file %s for interworking"
msgstr ""
-#: emultempl/pe.em:971 ldlang.c:1991 ldlang.c:4364 ldlang.c:4398 ldmain.c:1013
+#: emultempl/pe.em:971 ldlang.c:1991 ldlang.c:4364 ldlang.c:4398 ldmain.c:1020
msgid "%P%F: bfd_link_hash_lookup failed: %E\n"
msgstr ""
@@ -272,11 +272,11 @@ msgstr ""
msgid "%B%F: could not read symbols; %E\n"
msgstr ""
-#: ldcref.c:445 ldmain.c:1081 ldmain.c:1085
+#: ldcref.c:445 ldmain.c:1088 ldmain.c:1092
msgid "%B%F: could not read symbols: %E\n"
msgstr ""
-#: ldcref.c:517 ldcref.c:524 ldmain.c:1131 ldmain.c:1138
+#: ldcref.c:517 ldcref.c:524 ldmain.c:1138 ldmain.c:1145
msgid "%B%F: could not read relocs: %E\n"
msgstr ""
@@ -788,92 +788,96 @@ msgstr ""
msgid "%D: first defined here\n"
msgstr ""
-#: ldmain.c:894
+#: ldmain.c:869
+msgid "%P: Disabling relaxation: it will not work with multiple definitions\n"
+msgstr ""
+
+#: ldmain.c:901
msgid "%B: warning: definition of `%T' overriding common\n"
msgstr ""
-#: ldmain.c:897
+#: ldmain.c:904
msgid "%B: warning: common is here\n"
msgstr ""
-#: ldmain.c:904
+#: ldmain.c:911
msgid "%B: warning: common of `%T' overridden by definition\n"
msgstr ""
-#: ldmain.c:907
+#: ldmain.c:914
msgid "%B: warning: defined here\n"
msgstr ""
-#: ldmain.c:914
+#: ldmain.c:921
msgid "%B: warning: common of `%T' overridden by larger common\n"
msgstr ""
-#: ldmain.c:917
+#: ldmain.c:924
msgid "%B: warning: larger common is here\n"
msgstr ""
-#: ldmain.c:921
+#: ldmain.c:928
msgid "%B: warning: common of `%T' overriding smaller common\n"
msgstr ""
-#: ldmain.c:924
+#: ldmain.c:931
msgid "%B: warning: smaller common is here\n"
msgstr ""
-#: ldmain.c:928
+#: ldmain.c:935
msgid "%B: warning: multiple common of `%T'\n"
msgstr ""
-#: ldmain.c:930
+#: ldmain.c:937
msgid "%B: warning: previous common is here\n"
msgstr ""
-#: ldmain.c:952 ldmain.c:991
+#: ldmain.c:959 ldmain.c:998
msgid "%P: warning: global constructor %s used\n"
msgstr ""
-#: ldmain.c:1001
+#: ldmain.c:1008
msgid "%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n"
msgstr ""
-#: ldmain.c:1188
+#: ldmain.c:1195
msgid "%F%P: bfd_hash_table_init failed: %E\n"
msgstr ""
-#: ldmain.c:1195
+#: ldmain.c:1202
msgid "%F%P: bfd_hash_lookup failed: %E\n"
msgstr ""
-#: ldmain.c:1215
+#: ldmain.c:1222
msgid "%C: undefined reference to `%T'\n"
msgstr ""
-#: ldmain.c:1221
+#: ldmain.c:1228
msgid "%D: more undefined references to `%T' follow\n"
msgstr ""
-#: ldmain.c:1228
+#: ldmain.c:1235
msgid "%B: undefined reference to `%T'\n"
msgstr ""
-#: ldmain.c:1234
+#: ldmain.c:1241
msgid "%B: more undefined references to `%T' follow\n"
msgstr ""
-#: ldmain.c:1255 ldmain.c:1277 ldmain.c:1297
+#: ldmain.c:1262 ldmain.c:1284 ldmain.c:1304
msgid "%P%X: generated"
msgstr ""
-#: ldmain.c:1258
+#: ldmain.c:1265
msgid " relocation truncated to fit: %s %T"
msgstr ""
-#: ldmain.c:1280
+#: ldmain.c:1287
#, c-format
msgid "dangerous relocation: %s\n"
msgstr ""
-#: ldmain.c:1300
+#: ldmain.c:1307
msgid " reloc refers to symbol `%T' which is not being output\n"
msgstr ""
@@ -1484,7 +1488,7 @@ msgstr ""
msgid "Report bugs to %s\n"
msgstr ""
-#: mri.c:343
+#: mri.c:323
msgid "%P%F: unknown format type %s\n"
msgstr ""