* pe-dll.c (build_filler_bfd): Conform error message to standard.
[deliverable/binutils-gdb.git] / ld / emultempl / ppc32elf.em
CommitLineData
f9e6bfa8 1# This shell script emits a C file. -*- C -*-
c9a2f333 2# Copyright 2003, 2005 Free Software Foundation, Inc.
f9e6bfa8
AM
3#
4# This file is part of GLD, the Gnu Linker.
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
8# the Free Software Foundation; either version 2 of the License, or
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
75be928b 18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
f9e6bfa8
AM
19#
20
c9a2f333 21# This file is sourced from elf32.em, and defines extra powerpc32-elf
f9e6bfa8
AM
22# specific routines.
23#
24cat >>e${EMULATION_NAME}.c <<EOF
25
26#include "libbfd.h"
27#include "elf32-ppc.h"
28
c9a2f333
AM
29extern const bfd_target bfd_elf32_powerpc_vec;
30extern const bfd_target bfd_elf32_powerpcle_vec;
9d8504b1
PB
31extern const bfd_target bfd_elf32_powerpc_vxworks_vec;
32
33static inline int
34is_ppc_elf32_vec(const bfd_target * vec)
35{
36 return (vec == &bfd_elf32_powerpc_vec
37 || vec == &bfd_elf32_powerpc_vxworks_vec
38 || vec == &bfd_elf32_powerpcle_vec);
39}
c9a2f333 40
f9e6bfa8
AM
41/* Whether to run tls optimization. */
42static int notlsopt = 0;
43
0cf7d72c
AM
44/* Chooses the correct place for .plt and .got. */
45static int old_plt = 0;
46static int old_got = 0;
47
48static void
49ppc_after_open (void)
50{
9d8504b1 51 if (is_ppc_elf32_vec (link_info.hash->creator))
0cf7d72c
AM
52 {
53 int new_plt;
54 int keep_new;
55 unsigned int num_plt;
56 unsigned int num_got;
57 lang_output_section_statement_type *os;
58 lang_output_section_statement_type *plt_os[2];
59 lang_output_section_statement_type *got_os[2];
60
61 new_plt = ppc_elf_select_plt_layout (output_bfd, &link_info, old_plt);
62 if (new_plt < 0)
63 einfo ("%X%P: select_plt_layout problem %E\n");
64
65 num_got = 0;
66 num_plt = 0;
67 for (os = &lang_output_section_statement.head->output_section_statement;
68 os != NULL;
69 os = os->next)
70 {
71 if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0)
72 {
73 if (num_plt < 2)
74 plt_os[num_plt] = os;
75 ++num_plt;
76 }
77 if (os->constraint == SPECIAL && strcmp (os->name, ".got") == 0)
78 {
79 if (num_got < 2)
80 got_os[num_got] = os;
81 ++num_got;
82 }
83 }
84
85 keep_new = new_plt == 1 ? 0 : -1;
86 if (num_plt == 2)
87 {
88 plt_os[0]->constraint = keep_new;
89 plt_os[1]->constraint = ~keep_new;
90 }
91 if (num_got == 2)
92 {
93 if (old_got)
94 keep_new = -1;
95 got_os[0]->constraint = keep_new;
96 got_os[1]->constraint = ~keep_new;
97 }
98 }
99
100 gld${EMULATION_NAME}_after_open ();
101}
102
f9e6bfa8 103static void
7e5d8d48 104ppc_before_allocation (void)
f9e6bfa8 105{
9d8504b1 106 if (is_ppc_elf32_vec (link_info.hash->creator))
f9e6bfa8
AM
107 {
108 if (ppc_elf_tls_setup (output_bfd, &link_info) && !notlsopt)
109 {
110 if (!ppc_elf_tls_optimize (output_bfd, &link_info))
111 {
112 einfo ("%X%P: TLS problem %E\n");
113 return;
114 }
115 }
116 }
117 gld${EMULATION_NAME}_before_allocation ();
118}
119
120EOF
121
122# Define some shell vars to insert bits of code into the standard elf
123# parse_args and list_options functions.
124#
125PARSE_AND_LIST_PROLOGUE='
126#define OPTION_NO_TLS_OPT 301
0cf7d72c
AM
127#define OPTION_OLD_PLT 302
128#define OPTION_OLD_GOT 303
f9e6bfa8
AM
129'
130
f9e6bfa8
AM
131PARSE_AND_LIST_LONGOPTS='
132 { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
0cf7d72c
AM
133 { "bss-plt", no_argument, NULL, OPTION_OLD_PLT },
134 { "sdata-got", no_argument, NULL, OPTION_OLD_GOT },
f9e6bfa8
AM
135'
136
137PARSE_AND_LIST_OPTIONS='
138 fprintf (file, _("\
0cf7d72c
AM
139 --no-tls-optimize Don'\''t try to optimize TLS accesses.\n\
140 --bss-plt Force old-style BSS PLT.\n\
141 --sdata-got Force GOT location just before .sdata.\n"
f9e6bfa8
AM
142 ));
143'
144
145PARSE_AND_LIST_ARGS_CASES='
146 case OPTION_NO_TLS_OPT:
147 notlsopt = 1;
148 break;
0cf7d72c
AM
149
150 case OPTION_OLD_PLT:
151 old_plt = 1;
152 break;
153
154 case OPTION_OLD_GOT:
155 old_got = 1;
156 break;
f9e6bfa8
AM
157'
158
c9a2f333 159# Put these extra ppc32elf routines in ld_${EMULATION_NAME}_emulation
f9e6bfa8 160#
0cf7d72c 161LDEMUL_AFTER_OPEN=ppc_after_open
f9e6bfa8 162LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
This page took 0.153577 seconds and 4 git commands to generate.