1 # This shell script emits a C file. -*- C -*-
2 # Copyright 2003, 2005 Free Software Foundation, Inc.
4 # This file is part of GLD, the Gnu Linker.
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.
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, MA 02110-1301, USA.
21 # This file is sourced from elf32.em, and defines extra powerpc32-elf
24 cat >>e${EMULATION_NAME}.c <<EOF
27 #include "elf32-ppc.h"
29 extern const bfd_target bfd_elf32_powerpc_vec;
30 extern const bfd_target bfd_elf32_powerpcle_vec;
31 extern const bfd_target bfd_elf32_powerpc_vxworks_vec;
34 is_ppc_elf32_vec(const bfd_target * vec)
36 return (vec == &bfd_elf32_powerpc_vec
37 || vec == &bfd_elf32_powerpc_vxworks_vec
38 || vec == &bfd_elf32_powerpcle_vec);
41 /* Whether to run tls optimization. */
42 static int notlsopt = 0;
44 /* Chooses the correct place for .plt and .got. */
45 static int old_plt = 0;
46 static int old_got = 0;
51 if (is_ppc_elf32_vec (link_info.hash->creator))
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];
61 new_plt = ppc_elf_select_plt_layout (output_bfd, &link_info, old_plt);
63 einfo ("%X%P: select_plt_layout problem %E\n");
67 for (os = &lang_output_section_statement.head->output_section_statement;
71 if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0)
77 if (os->constraint == SPECIAL && strcmp (os->name, ".got") == 0)
85 keep_new = new_plt == 1 ? 0 : -1;
88 plt_os[0]->constraint = keep_new;
89 plt_os[1]->constraint = ~keep_new;
95 got_os[0]->constraint = keep_new;
96 got_os[1]->constraint = ~keep_new;
100 gld${EMULATION_NAME}_after_open ();
104 ppc_before_allocation (void)
106 if (is_ppc_elf32_vec (link_info.hash->creator))
108 if (ppc_elf_tls_setup (output_bfd, &link_info) && !notlsopt)
110 if (!ppc_elf_tls_optimize (output_bfd, &link_info))
112 einfo ("%X%P: TLS problem %E\n");
117 gld${EMULATION_NAME}_before_allocation ();
121 ppc_do_assignments (void)
125 if (is_ppc_elf32_vec (link_info.hash->creator))
126 ppc_elf_set_sdata_syms (output_bfd, &link_info);
128 s = bfd_get_section_by_name (output_bfd, ".sbss");
129 _bfd_elf_provide_section_bound_symbols (&link_info, s,
130 "__sbss_start", "__sbss_end");
131 _bfd_elf_provide_section_bound_symbols (&link_info, s,
132 "___sbss_start", "___sbss_end");
134 gld${EMULATION_NAME}_provide_init_fini_syms ();
139 # Define some shell vars to insert bits of code into the standard elf
140 # parse_args and list_options functions.
142 PARSE_AND_LIST_PROLOGUE='
143 #define OPTION_NO_TLS_OPT 301
144 #define OPTION_OLD_PLT 302
145 #define OPTION_OLD_GOT 303
148 PARSE_AND_LIST_LONGOPTS='
149 { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
150 { "bss-plt", no_argument, NULL, OPTION_OLD_PLT },
151 { "sdata-got", no_argument, NULL, OPTION_OLD_GOT },
154 PARSE_AND_LIST_OPTIONS='
156 --no-tls-optimize Don'\''t try to optimize TLS accesses.\n\
157 --bss-plt Force old-style BSS PLT.\n\
158 --sdata-got Force GOT location just before .sdata.\n"
162 PARSE_AND_LIST_ARGS_CASES='
163 case OPTION_NO_TLS_OPT:
176 # Put these extra ppc32elf routines in ld_${EMULATION_NAME}_emulation
178 LDEMUL_AFTER_OPEN=ppc_after_open
179 LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
180 LDEMUL_DO_ASSIGNMENTS=ppc_do_assignments