diff options
author | Richard Henderson <rth@redhat.com> | 2005-05-29 23:16:09 +0000 |
---|---|---|
committer | Richard Henderson <rth@redhat.com> | 2005-05-29 23:16:09 +0000 |
commit | 8d6d53d42725d34e9f3aa51442a0741b98163fa2 (patch) | |
tree | 47bd363ed05760ae55c4928ca9eac237c761f4fb /ld/emultempl/alphaelf.em | |
parent | 6ec7057aa5cdbf5b1544ce29d0df8d0d6f603179 (diff) | |
download | gdb-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/emultempl/alphaelf.em')
-rw-r--r-- | ld/emultempl/alphaelf.em | 90 |
1 files changed, 81 insertions, 9 deletions
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 |