include/
[deliverable/binutils-gdb.git] / ld / emultempl / alphaelf.em
CommitLineData
c279ca3e 1# This shell script emits a C file. -*- C -*-
f13a99db 2# Copyright 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
c279ca3e 3#
f96b4a7b 4# This file is part of the GNU Binutils.
c279ca3e
AM
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
c279ca3e
AM
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
c279ca3e
AM
20#
21
22# This file is sourced from elf32.em, and defines extra alpha
23# specific routines.
24#
92b93329 25fragment <<EOF
c279ca3e
AM
26
27#include "elf/internal.h"
28#include "elf/alpha.h"
29#include "elf-bfd.h"
30
8d6d53d4
RH
31static bfd_boolean limit_32bit;
32static bfd_boolean disable_relaxation;
33
34extern bfd_boolean elf64_alpha_use_secureplt;
35extern const bfd_target bfd_elf64_alpha_vec;
36extern const bfd_target bfd_elf64_alpha_freebsd_vec;
37
c279ca3e
AM
38
39/* Set the start address as in the Tru64 ld. */
40#define ALPHA_TEXT_START_32BIT 0x12000000
41
8d6d53d4
RH
42static void
43alpha_after_open (void)
44{
f13a99db
AM
45 if (link_info.output_bfd->xvec == &bfd_elf64_alpha_vec
46 || link_info.output_bfd->xvec == &bfd_elf64_alpha_freebsd_vec)
8d6d53d4
RH
47 {
48 unsigned int num_plt;
49 lang_output_section_statement_type *os;
50 lang_output_section_statement_type *plt_os[2];
51
52 num_plt = 0;
53 for (os = &lang_output_section_statement.head->output_section_statement;
54 os != NULL;
55 os = os->next)
56 {
57 if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0)
58 {
59 if (num_plt < 2)
60 plt_os[num_plt] = os;
61 ++num_plt;
62 }
63 }
64
65 if (num_plt == 2)
66 {
67 plt_os[0]->constraint = elf64_alpha_use_secureplt ? 0 : -1;
68 plt_os[1]->constraint = elf64_alpha_use_secureplt ? -1 : 0;
69 }
70 }
71
72 gld${EMULATION_NAME}_after_open ();
73}
74
c279ca3e 75static void
0c7a8e5a 76alpha_after_parse (void)
c279ca3e 77{
8d6d53d4 78 if (limit_32bit && !link_info.shared && !link_info.relocatable)
c279ca3e
AM
79 lang_section_start (".interp",
80 exp_binop ('+',
81 exp_intop (ALPHA_TEXT_START_32BIT),
7a5df8d0
NC
82 exp_nameop (SIZEOF_HEADERS, NULL)),
83 NULL);
c279ca3e
AM
84}
85
8d6d53d4
RH
86static void
87alpha_before_allocation (void)
88{
89 /* Call main function; we're just extending it. */
90 gld${EMULATION_NAME}_before_allocation ();
91
92 /* Add -relax if -O, not -r, and not explicitly disabled. */
93 if (link_info.optimize && !link_info.relocatable && !disable_relaxation)
94 command_line.relax = TRUE;
95}
96
c279ca3e 97static void
0c7a8e5a 98alpha_finish (void)
c279ca3e 99{
8d6d53d4 100 if (limit_32bit)
f13a99db 101 elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
c279ca3e
AM
102
103 gld${EMULATION_NAME}_finish ();
104}
105EOF
106
107# Define some shell vars to insert bits of code into the standard elf
108# parse_args and list_options functions.
109#
110PARSE_AND_LIST_PROLOGUE='
8d6d53d4
RH
111#define OPTION_TASO 300
112#define OPTION_NO_RELAX (OPTION_TASO + 1)
113#define OPTION_SECUREPLT (OPTION_NO_RELAX + 1)
114#define OPTION_NO_SECUREPLT (OPTION_SECUREPLT + 1)
c279ca3e
AM
115'
116
117PARSE_AND_LIST_LONGOPTS='
8d6d53d4
RH
118 { "taso", no_argument, NULL, OPTION_TASO },
119 { "no-relax", no_argument, NULL, OPTION_NO_RELAX },
120 { "secureplt", no_argument, NULL, OPTION_SECUREPLT },
121 { "no-secureplt", no_argument, NULL, OPTION_NO_SECUREPLT },
c279ca3e
AM
122'
123
124PARSE_AND_LIST_OPTIONS='
8d6d53d4 125 fprintf (file, _("\
442996ee
AM
126 --taso Load executable in the lower 31-bit addressable\n\
127 virtual address range.\n\
128 --no-relax Do not relax call and gp sequences.\n\
129 --secureplt Force PLT in text segment.\n\
130 --no-secureplt Force PLT in data segment.\n\
8d6d53d4 131"));
c279ca3e
AM
132'
133
134PARSE_AND_LIST_ARGS_CASES='
135 case OPTION_TASO:
8d6d53d4
RH
136 limit_32bit = 1;
137 break;
138 case OPTION_NO_RELAX:
139 disable_relaxation = TRUE;
140 break;
141 case OPTION_SECUREPLT:
142 elf64_alpha_use_secureplt = TRUE;
143 break;
144 case OPTION_NO_SECUREPLT:
145 elf64_alpha_use_secureplt = FALSE;
c279ca3e
AM
146 break;
147'
148
149# Put these extra alpha routines in ld_${EMULATION_NAME}_emulation
150#
8d6d53d4 151LDEMUL_AFTER_OPEN=alpha_after_open
c279ca3e 152LDEMUL_AFTER_PARSE=alpha_after_parse
8d6d53d4 153LDEMUL_BEFORE_ALLOCATION=alpha_before_allocation
c279ca3e 154LDEMUL_FINISH=alpha_finish
This page took 0.209738 seconds and 4 git commands to generate.