OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [ld/] [emultempl/] [ppc32elf.em] - Blame information for rev 645

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
# This shell script emits a C file. -*- C -*-
2
#   Copyright 2003, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
3
#
4
# This file is part of the GNU Binutils.
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 3 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
18
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
# MA 02110-1301, USA.
20
#
21
 
22
# This file is sourced from elf32.em, and defines extra powerpc32-elf
23
# specific routines.
24
#
25
fragment <
26
 
27
#include "libbfd.h"
28
#include "elf32-ppc.h"
29
 
30
#define is_ppc_elf(bfd) \
31
  (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
32
   && elf_object_id (bfd) == PPC32_ELF_TDATA)
33
 
34
/* Whether to run tls optimization.  */
35
static int notlsopt = 0;
36
static int no_tls_get_addr_opt = 0;
37
 
38
/* Whether to emit symbols for stubs.  */
39
static int emit_stub_syms = -1;
40
 
41
/* Chooses the correct place for .plt and .got.  */
42
static enum ppc_elf_plt_type plt_style = PLT_UNSET;
43
static int old_got = 0;
44
 
45
static void
46
ppc_after_open (void)
47
{
48
  if (is_ppc_elf (link_info.output_bfd))
49
    {
50
      int new_plt;
51
      int keep_new;
52
      unsigned int num_plt;
53
      unsigned int num_got;
54
      lang_output_section_statement_type *os;
55
      lang_output_section_statement_type *plt_os[2];
56
      lang_output_section_statement_type *got_os[2];
57
 
58
      if (emit_stub_syms < 0)
59
        emit_stub_syms = link_info.emitrelocations || link_info.shared;
60
      new_plt = ppc_elf_select_plt_layout (link_info.output_bfd, &link_info,
61
                                           plt_style, emit_stub_syms);
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
 
103
static void
104
ppc_before_allocation (void)
105
{
106
  if (is_ppc_elf (link_info.output_bfd))
107
    {
108
      if (ppc_elf_tls_setup (link_info.output_bfd, &link_info,
109
                             no_tls_get_addr_opt)
110
          && !notlsopt)
111
        {
112
          if (!ppc_elf_tls_optimize (link_info.output_bfd, &link_info))
113
            {
114
              einfo ("%X%P: TLS problem %E\n");
115
              return;
116
            }
117
        }
118
    }
119
 
120
  gld${EMULATION_NAME}_before_allocation ();
121
 
122
  /* Turn on relaxation if executable sections have addresses that
123
     might make branches overflow.  */
124
  if (!command_line.relax)
125
    {
126
      bfd_vma low = (bfd_vma) -1;
127
      bfd_vma high = 0;
128
      asection *o;
129
 
130
      /* Run lang_size_sections (if not already done).  */
131
      if (expld.phase != lang_mark_phase_enum)
132
        {
133
          expld.phase = lang_mark_phase_enum;
134
          expld.dataseg.phase = exp_dataseg_none;
135
          one_lang_size_sections_pass (NULL, FALSE);
136
          lang_reset_memory_regions ();
137
        }
138
 
139
      for (o = link_info.output_bfd->sections; o != NULL; o = o->next)
140
        {
141
          if ((o->flags & (SEC_ALLOC | SEC_CODE)) != (SEC_ALLOC | SEC_CODE))
142
            continue;
143
          if (o->rawsize == 0)
144
            continue;
145
          if (low > o->vma)
146
            low = o->vma;
147
          if (high < o->vma + o->rawsize - 1)
148
            high = o->vma + o->rawsize - 1;
149
        }
150
      if (high > low && high - low > (1 << 25) - 1)
151
        command_line.relax = TRUE;
152
    }
153
}
154
 
155
EOF
156
 
157
if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
158
  fragment <
159
/* Special handling for embedded SPU executables.  */
160
extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
161
static bfd_boolean gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *);
162
 
163
static bfd_boolean
164
ppc_recognized_file (lang_input_statement_type *entry)
165
{
166
  if (embedded_spu_file (entry, "-m32"))
167
    return TRUE;
168
 
169
  return gld${EMULATION_NAME}_load_symbols (entry);
170
}
171
 
172
EOF
173
LDEMUL_RECOGNIZED_FILE=ppc_recognized_file
174
fi
175
 
176
# Define some shell vars to insert bits of code into the standard elf
177
# parse_args and list_options functions.
178
#
179
PARSE_AND_LIST_PROLOGUE='
180
#define OPTION_NO_TLS_OPT               301
181
#define OPTION_NO_TLS_GET_ADDR_OPT      (OPTION_NO_TLS_OPT + 1)
182
#define OPTION_NEW_PLT                  (OPTION_NO_TLS_GET_ADDR_OPT + 1)
183
#define OPTION_OLD_PLT                  (OPTION_NEW_PLT + 1)
184
#define OPTION_OLD_GOT                  (OPTION_OLD_PLT + 1)
185
#define OPTION_STUBSYMS                 (OPTION_OLD_GOT + 1)
186
#define OPTION_NO_STUBSYMS              (OPTION_STUBSYMS + 1)
187
'
188
 
189
PARSE_AND_LIST_LONGOPTS='
190
  { "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
191
  { "no-emit-stub-syms", no_argument, NULL, OPTION_NO_STUBSYMS },
192
  { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
193
  { "no-tls-get-addr-optimize", no_argument, NULL, OPTION_NO_TLS_GET_ADDR_OPT },
194
  { "secure-plt", no_argument, NULL, OPTION_NEW_PLT },
195
  { "bss-plt", no_argument, NULL, OPTION_OLD_PLT },
196
  { "sdata-got", no_argument, NULL, OPTION_OLD_GOT },
197
'
198
 
199
PARSE_AND_LIST_OPTIONS='
200
  fprintf (file, _("\
201
  --emit-stub-syms            Label linker stubs with a symbol.\n\
202
  --no-emit-stub-syms         Don'\''t label linker stubs with a symbol.\n\
203
  --no-tls-optimize           Don'\''t try to optimize TLS accesses.\n\
204
  --no-tls-get-addr-optimize  Don'\''t use a special __tls_get_addr call.\n\
205
  --secure-plt                Use new-style PLT if possible.\n\
206
  --bss-plt                   Force old-style BSS PLT.\n\
207
  --sdata-got                 Force GOT location just before .sdata.\n"
208
                   ));
209
'
210
 
211
PARSE_AND_LIST_ARGS_CASES='
212
    case OPTION_STUBSYMS:
213
      emit_stub_syms = 1;
214
      break;
215
 
216
    case OPTION_NO_STUBSYMS:
217
      emit_stub_syms = 0;
218
      break;
219
 
220
    case OPTION_NO_TLS_OPT:
221
      notlsopt = 1;
222
      break;
223
 
224
    case OPTION_NO_TLS_GET_ADDR_OPT:
225
      no_tls_get_addr_opt = 1;
226
      break;
227
 
228
    case OPTION_NEW_PLT:
229
      plt_style = PLT_NEW;
230
      break;
231
 
232
    case OPTION_OLD_PLT:
233
      plt_style = PLT_OLD;
234
      break;
235
 
236
    case OPTION_OLD_GOT:
237
      old_got = 1;
238
      break;
239
'
240
 
241
# Put these extra ppc32elf routines in ld_${EMULATION_NAME}_emulation
242
#
243
LDEMUL_AFTER_OPEN=ppc_after_open
244
LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.