aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/mmo.em
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2002-02-01 08:24:03 +0000
committerHans-Peter Nilsson <hp@axis.com>2002-02-01 08:24:03 +0000
commit48fa4a5def1116273c2c2a236939e96eb9b6231a (patch)
treeb8597630be4f09f870fede949598daddae5d1d15 /ld/emultempl/mmo.em
parent930b4cb2c2da2be8643a1e79fe09fe7328544d32 (diff)
downloadgdb-48fa4a5def1116273c2c2a236939e96eb9b6231a.zip
gdb-48fa4a5def1116273c2c2a236939e96eb9b6231a.tar.gz
gdb-48fa4a5def1116273c2c2a236939e96eb9b6231a.tar.bz2
Support on-demand global register allocation from
R_MMIX_BASE_PLUS_OFFSET relocs. * emultempl/mmix-elfnmmo.em (mmix_after_allocation): Rename from mmix_set_reg_section_vma. Call _bfd_mmix_finalize_linker_allocated_gregs. (mmix_before_allocation): New function. (LDEMUL_AFTER_ALLOCATION): Set to mmix_after_allocation. (LDEMUL_BEFORE_ALLOCATION): Define to mmix_before_allocation. * scripttempl/mmo.sc (.text): Mark .init, .fini as KEEP. (.MMIX.reg_contents): Add .MMIX.reg_contents.linker_allocated before .MMIX.reg_contents. * emultempl/mmo.em (gldmmo_before_allocation): Define to default. (mmo_after_open): New function. (LDEMUL_AFTER_OPEN): Define to mmo_after_open. * emulparams/elf64mmix.sh (OTHER_SECTIONS): Tweak formatting. Add .MMIX.reg_contents.linker_allocated before .MMIX.reg_contents.
Diffstat (limited to 'ld/emultempl/mmo.em')
-rw-r--r--ld/emultempl/mmo.em28
1 files changed, 27 insertions, 1 deletions
diff --git a/ld/emultempl/mmo.em b/ld/emultempl/mmo.em
index 8fed0f6..1a3941d 100644
--- a/ld/emultempl/mmo.em
+++ b/ld/emultempl/mmo.em
@@ -1,5 +1,5 @@
# This shell script emits a C file. -*- C -*-
-# Copyright 2001 Free Software Foundation, Inc.
+# Copyright 2001, 2002 Free Software Foundation, Inc.
#
# This file is part of GLD, the Gnu Linker.
#
@@ -21,6 +21,13 @@
# This file is sourced from elf32.em and mmo.em, used to define
# linker MMIX-specifics common to ELF and MMO.
+cat >>e${EMULATION_NAME}.c <<EOF
+/* Need to have this define before mmix-elfnmmo, which includes
+ needrelax.em which uses this name for the before_allocation function,
+ normally defined in elf32.em. */
+#define gldmmo_before_allocation before_allocation_default
+EOF
+
. ${srcdir}/emultempl/mmix-elfnmmo.em
cat >>e${EMULATION_NAME}.c <<EOF
@@ -31,6 +38,7 @@ static asection *output_prev_sec_find
PARAMS ((lang_output_section_statement_type *));
static void mmo_finish PARAMS ((void));
static void mmo_wipe_sec_reloc_flag PARAMS ((bfd *, asection *, PTR));
+static void mmo_after_open PARAMS ((void));
/* Find the last output section before given output statement.
Used by place_orphan. */
@@ -220,8 +228,26 @@ mmo_finish ()
{
bfd_map_over_sections (output_bfd, mmo_wipe_sec_reloc_flag, NULL);
}
+
+/* To get on-demand global register allocation right, we need to parse the
+ relocs, like what happens when linking to ELF. It needs to be done
+ before all input sections are supposed to be present. When linking to
+ ELF, it's done when reading symbols. When linking to mmo, we do it
+ when all input files are seen, which is equivalent. */
+static void
+mmo_after_open ()
+{
+ LANG_FOR_EACH_INPUT_STATEMENT (is)
+ {
+ if (bfd_get_flavour (is->the_bfd) == bfd_target_elf_flavour
+ && !_bfd_mmix_check_all_relocs (is->the_bfd, &link_info))
+ einfo ("%X%P: Internal problems scanning %B after opening it",
+ is->the_bfd);
+ }
+}
EOF
LDEMUL_PLACE_ORPHAN=mmo_place_orphan
LDEMUL_FINISH=mmo_finish
+LDEMUL_AFTER_OPEN=mmo_after_open