OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [ld/] [emultempl/] [ppc32elf.em] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
# This shell script emits a C file. -*- C -*-
2
#   Copyright 2003, 2005, 2007, 2008 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
 
37
/* Whether to emit symbols for stubs.  */
38
static int emit_stub_syms = 0;
39
 
40
/* Chooses the correct place for .plt and .got.  */
41
static enum ppc_elf_plt_type plt_style = PLT_UNSET;
42
static int old_got = 0;
43
 
44
static void
45
ppc_after_open (void)
46
{
47
  if (is_ppc_elf (link_info.output_bfd))
48
    {
49
      int new_plt;
50
      int keep_new;
51
      unsigned int num_plt;
52
      unsigned int num_got;
53
      lang_output_section_statement_type *os;
54
      lang_output_section_statement_type *plt_os[2];
55
      lang_output_section_statement_type *got_os[2];
56
 
57
      emit_stub_syms |= link_info.emitrelocations;
58
      new_plt = ppc_elf_select_plt_layout (link_info.output_bfd, &link_info,
59
                                           plt_style, emit_stub_syms);
60
      if (new_plt < 0)
61
        einfo ("%X%P: select_plt_layout problem %E\n");
62
 
63
      num_got = 0;
64
      num_plt = 0;
65
      for (os = &lang_output_section_statement.head->output_section_statement;
66
           os != NULL;
67
           os = os->next)
68
        {
69
          if (os->constraint == SPECIAL && strcmp (os->name, ".plt") == 0)
70
            {
71
              if (num_plt < 2)
72
                plt_os[num_plt] = os;
73
              ++num_plt;
74
            }
75
          if (os->constraint == SPECIAL && strcmp (os->name, ".got") == 0)
76
            {
77
              if (num_got < 2)
78
                got_os[num_got] = os;
79
              ++num_got;
80
            }
81
        }
82
 
83
      keep_new = new_plt == 1 ? 0 : -1;
84
      if (num_plt == 2)
85
        {
86
          plt_os[0]->constraint = keep_new;
87
          plt_os[1]->constraint = ~keep_new;
88
        }
89
      if (num_got == 2)
90
        {
91
          if (old_got)
92
            keep_new = -1;
93
          got_os[0]->constraint = keep_new;
94
          got_os[1]->constraint = ~keep_new;
95
        }
96
    }
97
 
98
  gld${EMULATION_NAME}_after_open ();
99
}
100
 
101
static void
102
ppc_before_allocation (void)
103
{
104
  if (is_ppc_elf (link_info.output_bfd))
105
    {
106
      if (ppc_elf_tls_setup (link_info.output_bfd, &link_info) && !notlsopt)
107
        {
108
          if (!ppc_elf_tls_optimize (link_info.output_bfd, &link_info))
109
            {
110
              einfo ("%X%P: TLS problem %E\n");
111
              return;
112
            }
113
        }
114
    }
115
  gld${EMULATION_NAME}_before_allocation ();
116
}
117
 
118
EOF
119
 
120
if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
121
  fragment <
122
/* Special handling for embedded SPU executables.  */
123
extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
124
static bfd_boolean gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *);
125
 
126
static bfd_boolean
127
ppc_recognized_file (lang_input_statement_type *entry)
128
{
129
  if (embedded_spu_file (entry, "-m32"))
130
    return TRUE;
131
 
132
  return gld${EMULATION_NAME}_load_symbols (entry);
133
}
134
 
135
EOF
136
LDEMUL_RECOGNIZED_FILE=ppc_recognized_file
137
fi
138
 
139
# Define some shell vars to insert bits of code into the standard elf
140
# parse_args and list_options functions.
141
#
142
PARSE_AND_LIST_PROLOGUE='
143
#define OPTION_NO_TLS_OPT               301
144
#define OPTION_NEW_PLT                  302
145
#define OPTION_OLD_PLT                  303
146
#define OPTION_OLD_GOT                  304
147
#define OPTION_STUBSYMS                 305
148
'
149
 
150
PARSE_AND_LIST_LONGOPTS='
151
  { "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
152
  { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
153
  { "secure-plt", no_argument, NULL, OPTION_NEW_PLT },
154
  { "bss-plt", no_argument, NULL, OPTION_OLD_PLT },
155
  { "sdata-got", no_argument, NULL, OPTION_OLD_GOT },
156
'
157
 
158
PARSE_AND_LIST_OPTIONS='
159
  fprintf (file, _("\
160
  --emit-stub-syms            Label linker stubs with a symbol.\n\
161
  --no-tls-optimize           Don'\''t try to optimize TLS accesses.\n\
162
  --secure-plt                Use new-style PLT if possible.\n\
163
  --bss-plt                   Force old-style BSS PLT.\n\
164
  --sdata-got                 Force GOT location just before .sdata.\n"
165
                   ));
166
'
167
 
168
PARSE_AND_LIST_ARGS_CASES='
169
    case OPTION_STUBSYMS:
170
      emit_stub_syms = 1;
171
      break;
172
 
173
    case OPTION_NO_TLS_OPT:
174
      notlsopt = 1;
175
      break;
176
 
177
    case OPTION_NEW_PLT:
178
      plt_style = PLT_NEW;
179
      break;
180
 
181
    case OPTION_OLD_PLT:
182
      plt_style = PLT_OLD;
183
      break;
184
 
185
    case OPTION_OLD_GOT:
186
      old_got = 1;
187
      break;
188
'
189
 
190
# Put these extra ppc32elf routines in ld_${EMULATION_NAME}_emulation
191
#
192
LDEMUL_AFTER_OPEN=ppc_after_open
193
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.