aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2005-05-29 23:16:09 +0000
committerRichard Henderson <rth@redhat.com>2005-05-29 23:16:09 +0000
commit8d6d53d42725d34e9f3aa51442a0741b98163fa2 (patch)
tree47bd363ed05760ae55c4928ca9eac237c761f4fb /ld
parent6ec7057aa5cdbf5b1544ce29d0df8d0d6f603179 (diff)
downloadgdb-8d6d53d42725d34e9f3aa51442a0741b98163fa2.zip
gdb-8d6d53d42725d34e9f3aa51442a0741b98163fa2.tar.gz
gdb-8d6d53d42725d34e9f3aa51442a0741b98163fa2.tar.bz2
* emulparams/elf64alpha.sh (PLT): New.
(TEXT_PLT): New. * emultempl/alphaelf.em (disable_relaxation): New. (limit_32bit): Rename from elf64alpha_32bit; update all users. (elf64_alpha_use_secureplt): Declare. (bfd_elf64_alpha_vec, bfd_elf64_alpha_freebsd_vec): Declare. (alpha_after_open): New. (alpha_before_allocation): New. (OPTION_NO_RELAX, OPTION_SECUREPLT, OPTION_NO_SECUREPLT): New. (PARSE_AND_LIST_LONGOPTS): Include them. (PARSE_AND_LIST_OPTIONS): Likewise. (PARSE_AND_LIST_ARGS_CASES): Likewise. (LDEMUL_AFTER_OPEN, LDEMUL_BEFORE_ALLOCATION): New. * scripttempl/elf.sc (TEXT_PLT): New. (PLT): Use it.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog18
-rw-r--r--ld/emulparams/elf64alpha.sh8
-rw-r--r--ld/emultempl/alphaelf.em90
-rw-r--r--ld/scripttempl/elf.sc3
4 files changed, 108 insertions, 11 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 0c1185c..32362d5 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,21 @@
+2005-05-29 Richard Henderson <rth@redhat.com>
+
+ * emulparams/elf64alpha.sh (PLT): New.
+ (TEXT_PLT): New.
+ * emultempl/alphaelf.em (disable_relaxation): New.
+ (limit_32bit): Rename from elf64alpha_32bit; update all users.
+ (elf64_alpha_use_secureplt): Declare.
+ (bfd_elf64_alpha_vec, bfd_elf64_alpha_freebsd_vec): Declare.
+ (alpha_after_open): New.
+ (alpha_before_allocation): New.
+ (OPTION_NO_RELAX, OPTION_SECUREPLT, OPTION_NO_SECUREPLT): New.
+ (PARSE_AND_LIST_LONGOPTS): Include them.
+ (PARSE_AND_LIST_OPTIONS): Likewise.
+ (PARSE_AND_LIST_ARGS_CASES): Likewise.
+ (LDEMUL_AFTER_OPEN, LDEMUL_BEFORE_ALLOCATION): New.
+ * scripttempl/elf.sc (TEXT_PLT): New.
+ (PLT): Use it.
+
2005-05-27 Andreas Schwab <schwab@suse.de>
* configure.host (HOSTING_LIBS): Add libunwind.a if it exists.
diff --git a/ld/emulparams/elf64alpha.sh b/ld/emulparams/elf64alpha.sh
index 093c8df..47a0bb0 100644
--- a/ld/emulparams/elf64alpha.sh
+++ b/ld/emulparams/elf64alpha.sh
@@ -12,7 +12,13 @@ ARCH=alpha
MACHINE=
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
-DATA_PLT=
+
+# Yes, we want duplicate .plt sections. The linker chooses the
+# appropriate one magically in alpha_after_open.
+PLT=".plt ${RELOCATING-0} : SPECIAL { *(.plt) }"
+DATA_PLT=yes
+TEXT_PLT=yes
+
# Note that the number is always big-endian, thus we have to
# reverse the digit string.
NOP=0x0000fe2f1f04ff47 # unop; nop
diff --git a/ld/emultempl/alphaelf.em b/ld/emultempl/alphaelf.em
index eeac758..62eca18 100644
--- a/ld/emultempl/alphaelf.em
+++ b/ld/emultempl/alphaelf.em
@@ -1,5 +1,5 @@
# This shell script emits a C file. -*- C -*-
-# Copyright 2003, 2004 Free Software Foundation, Inc.
+# Copyright 2003, 2004, 2005 Free Software Foundation, Inc.
#
# This file is part of GLD, the Gnu Linker.
#
@@ -27,15 +27,54 @@ cat >>e${EMULATION_NAME}.c <<EOF
#include "elf/alpha.h"
#include "elf-bfd.h"
-static int elf64alpha_32bit = 0;
+static bfd_boolean limit_32bit;
+static bfd_boolean disable_relaxation;
+
+extern bfd_boolean elf64_alpha_use_secureplt;
+extern const bfd_target bfd_elf64_alpha_vec;
+extern const bfd_target bfd_elf64_alpha_freebsd_vec;
+
/* Set the start address as in the Tru64 ld. */
#define ALPHA_TEXT_START_32BIT 0x12000000
static void
+alpha_after_open (void)
+{
+ if (link_info.hash->creator == &bfd_elf64_alpha_vec
+ || link_info.hash->creator == &bfd_elf64_alpha_freebsd_vec)
+ {
+ unsigned int num_plt;
+ lang_output_section_statement_type *os;
+ lang_output_section_statement_type *plt_os[2];
+
+ num_plt = 0;
+ for (os = &lang_output_section_statement.head->output_section_statement;
+ os != NULL;
+ os = os->next)
+ {
+ if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0)
+ {
+ if (num_plt < 2)
+ plt_os[num_plt] = os;
+ ++num_plt;
+ }
+ }
+
+ if (num_plt == 2)
+ {
+ plt_os[0]->constraint = elf64_alpha_use_secureplt ? 0 : -1;
+ plt_os[1]->constraint = elf64_alpha_use_secureplt ? -1 : 0;
+ }
+ }
+
+ gld${EMULATION_NAME}_after_open ();
+}
+
+static void
alpha_after_parse (void)
{
- if (elf64alpha_32bit && !link_info.shared && !link_info.relocatable)
+ if (limit_32bit && !link_info.shared && !link_info.relocatable)
lang_section_start (".interp",
exp_binop ('+',
exp_intop (ALPHA_TEXT_START_32BIT),
@@ -44,9 +83,20 @@ alpha_after_parse (void)
}
static void
+alpha_before_allocation (void)
+{
+ /* Call main function; we're just extending it. */
+ gld${EMULATION_NAME}_before_allocation ();
+
+ /* Add -relax if -O, not -r, and not explicitly disabled. */
+ if (link_info.optimize && !link_info.relocatable && !disable_relaxation)
+ command_line.relax = TRUE;
+}
+
+static void
alpha_finish (void)
{
- if (elf64alpha_32bit)
+ if (limit_32bit)
elf_elfheader (output_bfd)->e_flags |= EF_ALPHA_32BIT;
gld${EMULATION_NAME}_finish ();
@@ -57,25 +107,47 @@ EOF
# parse_args and list_options functions.
#
PARSE_AND_LIST_PROLOGUE='
-#define OPTION_TASO 300
+#define OPTION_TASO 300
+#define OPTION_NO_RELAX (OPTION_TASO + 1)
+#define OPTION_SECUREPLT (OPTION_NO_RELAX + 1)
+#define OPTION_NO_SECUREPLT (OPTION_SECUREPLT + 1)
'
PARSE_AND_LIST_LONGOPTS='
- {"taso", no_argument, NULL, OPTION_TASO},
+ { "taso", no_argument, NULL, OPTION_TASO },
+ { "no-relax", no_argument, NULL, OPTION_NO_RELAX },
+ { "secureplt", no_argument, NULL, OPTION_SECUREPLT },
+ { "no-secureplt", no_argument, NULL, OPTION_NO_SECUREPLT },
'
PARSE_AND_LIST_OPTIONS='
- fprintf (file, _(" -taso\t\t\tLoad executable in the lower 31-bit addressable\n"));
- fprintf (file, _("\t\t\t virtual address range\n"));
+ fprintf (file, _("\
+ --taso Load executable in the lower 31-bit addressable\n\
+ virtual address range.\n\
+ --no-relax Do not relax call and gp sequences.\n\
+ --secureplt Force PLT in text segment.\n\
+ --no-secureplt Force PLT in data segment.\n\
+"));
'
PARSE_AND_LIST_ARGS_CASES='
case OPTION_TASO:
- elf64alpha_32bit = 1;
+ limit_32bit = 1;
+ break;
+ case OPTION_NO_RELAX:
+ disable_relaxation = TRUE;
+ break;
+ case OPTION_SECUREPLT:
+ elf64_alpha_use_secureplt = TRUE;
+ break;
+ case OPTION_NO_SECUREPLT:
+ elf64_alpha_use_secureplt = FALSE;
break;
'
# Put these extra alpha routines in ld_${EMULATION_NAME}_emulation
#
+LDEMUL_AFTER_OPEN=alpha_after_open
LDEMUL_AFTER_PARSE=alpha_after_parse
+LDEMUL_BEFORE_ALLOCATION=alpha_before_allocation
LDEMUL_FINISH=alpha_finish
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index 3e0f0b0..e7702a3 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -104,6 +104,7 @@ INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
if test -z "$PLT"; then
PLT=".plt ${RELOCATING-0} : { *(.plt) }"
fi
+test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
if test -z "$GOT"; then
if test -z "$SEPARATE_GOTPLT"; then
GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }"
@@ -302,7 +303,7 @@ cat <<EOF
${RELOCATING+${INIT_END}}
} =${NOP-0}
- ${DATA_PLT-${BSS_PLT-${PLT}}}
+ ${TEXT_PLT+${PLT}}
.text ${RELOCATING-0} :
{
${RELOCATING+${TEXT_START_SYMBOLS}}