1 # This shell script emits a C file. -*- C -*-
2 # Copyright 2003, 2005, 2007 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
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 3 of the License, or
9 # (at your option) any later version.
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.
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
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 # This file is sourced from elf32.em, and defines extra powerpc32-elf
28 #include "elf32-ppc.h"
30 extern const bfd_target bfd_elf32_powerpc_vec;
31 extern const bfd_target bfd_elf32_powerpcle_vec;
32 extern const bfd_target bfd_elf32_powerpc_vxworks_vec;
35 is_ppc_elf32_vec(const bfd_target * vec)
37 return (vec == &bfd_elf32_powerpc_vec
38 || vec == &bfd_elf32_powerpc_vxworks_vec
39 || vec == &bfd_elf32_powerpcle_vec);
42 /* Whether to run tls optimization. */
43 static int notlsopt = 0;
45 /* Whether to emit symbols for stubs. */
46 static int emit_stub_syms = 0;
48 /* Chooses the correct place for .plt and .got. */
49 static enum ppc_elf_plt_type plt_style = PLT_UNSET;
50 static int old_got = 0;
55 if (is_ppc_elf32_vec (link_info.hash->creator))
61 lang_output_section_statement_type *os;
62 lang_output_section_statement_type *plt_os[2];
63 lang_output_section_statement_type *got_os[2];
65 emit_stub_syms |= link_info.emitrelocations;
66 new_plt = ppc_elf_select_plt_layout (output_bfd, &link_info, plt_style,
69 einfo ("%X%P: select_plt_layout problem %E\n");
73 for (os = &lang_output_section_statement.head->output_section_statement;
77 if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0)
83 if (os->constraint == SPECIAL && strcmp (os->name, ".got") == 0)
91 keep_new = new_plt == 1 ? 0 : -1;
94 plt_os[0]->constraint = keep_new;
95 plt_os[1]->constraint = ~keep_new;
101 got_os[0]->constraint = keep_new;
102 got_os[1]->constraint = ~keep_new;
106 gld${EMULATION_NAME}_after_open ();
110 ppc_before_allocation (void)
112 if (is_ppc_elf32_vec (link_info.hash->creator))
114 if (ppc_elf_tls_setup (output_bfd, &link_info) && !notlsopt)
116 if (!ppc_elf_tls_optimize (output_bfd, &link_info))
118 einfo ("%X%P: TLS problem %E\n");
123 gld${EMULATION_NAME}_before_allocation ();
128 if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
130 /* Special handling for embedded SPU executables. */
131 extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
132 static bfd_boolean gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *);
135 ppc_recognized_file (lang_input_statement_type *entry)
137 if (embedded_spu_file (entry, "-m32"))
140 return gld${EMULATION_NAME}_load_symbols (entry);
144 LDEMUL_RECOGNIZED_FILE=ppc_recognized_file
147 # Define some shell vars to insert bits of code into the standard elf
148 # parse_args and list_options functions.
150 PARSE_AND_LIST_PROLOGUE='
151 #define OPTION_NO_TLS_OPT 301
152 #define OPTION_NEW_PLT 302
153 #define OPTION_OLD_PLT 303
154 #define OPTION_OLD_GOT 304
155 #define OPTION_STUBSYMS 305
158 PARSE_AND_LIST_LONGOPTS='
159 { "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
160 { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
161 { "secure-plt", no_argument, NULL, OPTION_NEW_PLT },
162 { "bss-plt", no_argument, NULL, OPTION_OLD_PLT },
163 { "sdata-got", no_argument, NULL, OPTION_OLD_GOT },
166 PARSE_AND_LIST_OPTIONS='
168 --emit-stub-syms Label linker stubs with a symbol.\n\
169 --no-tls-optimize Don'\''t try to optimize TLS accesses.\n\
170 --secure-plt Use new-style PLT if possible.\n\
171 --bss-plt Force old-style BSS PLT.\n\
172 --sdata-got Force GOT location just before .sdata.\n"
176 PARSE_AND_LIST_ARGS_CASES='
177 case OPTION_STUBSYMS:
181 case OPTION_NO_TLS_OPT:
198 # Put these extra ppc32elf routines in ld_${EMULATION_NAME}_emulation
200 LDEMUL_AFTER_OPEN=ppc_after_open
201 LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation