* po/POTFILES.in: Regenerate.
[deliverable/binutils-gdb.git] / ld / emultempl / armelf.em
CommitLineData
252b5132 1# This shell script emits a C file. -*- C -*-
a2b64bed 2# Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000
41392f03
AM
3# Free Software Foundation, Inc.
4#
5# This file is part of GLD, the Gnu Linker.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20#
21
22# This file is sourced from elf32.em, and defines extra arm-elf
23# specific routines.
24#
25cat >>e${EMULATION_NAME}.c <<EOF
7ca69e9e 26
7ca69e9e 27static int no_pipeline_knowledge = 0;
41392f03 28static char *thumb_entry_symbol = NULL;
7ca69e9e 29
252b5132
RH
30
31static void
32gld${EMULATION_NAME}_before_parse ()
33{
34#ifndef TARGET_ /* I.e., if not generic. */
35 ldfile_set_output_arch ("`echo ${ARCH}`");
36#endif /* not TARGET_ */
31ce0628
NC
37 config.dynamic_link = ${DYNAMIC_LINK-true};
38 config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo true ; else echo false ; fi`;
252b5132
RH
39}
40
1220a729 41
41392f03 42static void arm_elf_after_open PARAMS((void));
1220a729
NC
43
44static void
41392f03 45arm_elf_after_open ()
1220a729 46{
f11523b0 47 if (strstr (bfd_get_target (output_bfd), "arm") == NULL)
1220a729 48 {
f11523b0
NC
49 /* The arm backend needs special fields in the output hash structure.
50 These will only be created if the output format is an arm format,
51 hence we do not support linking and changing output formats at the
52 same time. Use a link followed by objcopy to change output formats. */
53 einfo ("%F%X%P: error: cannot change output format whilst linking ARM binaries\n");
54 return;
1220a729
NC
55 }
56
f11523b0
NC
57 {
58 LANG_FOR_EACH_INPUT_STATEMENT (is)
59 {
60 /* The interworking bfd must be the last one to be processed */
61 if (!is->next)
62 bfd_elf32_arm_get_bfd_for_interworking (is->the_bfd, & link_info);
63 }
64 }
65
41392f03
AM
66 /* Call the standard elf routine. */
67 gld${EMULATION_NAME}_after_open ();
1220a729
NC
68}
69
1220a729 70
41392f03 71static void arm_elf_before_allocation PARAMS ((void));
1220a729
NC
72
73static void
41392f03 74arm_elf_before_allocation ()
1220a729 75{
41392f03
AM
76 /* Call the standard elf routine. */
77 gld${EMULATION_NAME}_before_allocation ();
1220a729 78
41392f03 79 /* We should be able to set the size of the interworking stub section */
252b5132
RH
80
81 /* Here we rummage through the found bfds to collect glue information */
82 /* FIXME: should this be based on a command line option? krk@cygnus.com */
83 {
84 LANG_FOR_EACH_INPUT_STATEMENT (is)
85 {
7ca69e9e
NC
86 if (!bfd_elf32_arm_process_before_allocation (is->the_bfd, & link_info,
87 no_pipeline_knowledge))
252b5132
RH
88 {
89 /* xgettext:c-format */
90 einfo (_("Errors encountered processing file %s"), is->filename);
91 }
92 }
93 }
94
95 /* We have seen it all. Allocate it, and carry on */
96 bfd_elf32_arm_allocate_interworking_sections (& link_info);
97}
98
41392f03 99
a48ca7f2 100static void arm_elf_finish PARAMS ((void));
41392f03 101
6f798e5c 102static void
a48ca7f2 103arm_elf_finish ()
6f798e5c
NC
104{
105 struct bfd_link_hash_entry * h;
106
107 if (thumb_entry_symbol == NULL)
108 return;
109
41392f03
AM
110 h = bfd_link_hash_lookup (link_info.hash, thumb_entry_symbol,
111 false, false, true);
6f798e5c
NC
112
113 if (h != (struct bfd_link_hash_entry *) NULL
114 && (h->type == bfd_link_hash_defined
115 || h->type == bfd_link_hash_defweak)
116 && h->u.def.section->output_section != NULL)
117 {
118 static char buffer[32];
119 bfd_vma val;
120
121 /* Special procesing is required for a Thumb entry symbol. The
122 bottom bit of its address must be set. */
123 val = (h->u.def.value
124 + bfd_get_section_vma (output_bfd,
125 h->u.def.section->output_section)
126 + h->u.def.section->output_offset);
127
128 val |= 1;
129
130 /* Now convert this value into a string and store it in entry_symbol
131 where the lang_finish() function will pick it up. */
132 buffer[0] = '0';
133 buffer[1] = 'x';
134
135 sprintf_vma (buffer + 2, val);
136
137 if (entry_symbol != NULL && entry_from_cmdline)
138 einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
139 thumb_entry_symbol, entry_symbol);
140 entry_symbol = buffer;
141 }
142 else
41392f03
AM
143 einfo (_("%P: warning: connot find thumb start symbol %s\n"),
144 thumb_entry_symbol);
6f798e5c
NC
145}
146
252b5132
RH
147EOF
148
41392f03
AM
149# Define some shell vars to insert bits of code into the standard elf
150# parse_args and list_options functions.
151#
152PARSE_AND_LIST_PROLOGUE='
153#define OPTION_THUMB_ENTRY 301
154'
252b5132 155
41392f03 156PARSE_AND_LIST_SHORTOPTS=p
252b5132 157
41392f03
AM
158PARSE_AND_LIST_LONGOPTS='
159 { "no-pipeline-knowledge", no_argument, NULL, '\'p\''},
160 { "thumb-entry", required_argument, NULL, OPTION_THUMB_ENTRY},
161'
252b5132 162
41392f03
AM
163PARSE_AND_LIST_OPTIONS='
164 fprintf (file, _(" -p --no-pipeline-knowledge Stop the linker knowing about the pipeline length\n"));
165 fprintf (file, _(" --thumb-entry=<sym> Set the entry point to be Thumb symbol <sym>\n"));
166'
252b5132 167
41392f03
AM
168PARSE_AND_LIST_ARGS_CASES='
169 case '\'p\'':
170 no_pipeline_knowledge = 1;
171 break;
252b5132 172
41392f03
AM
173 case OPTION_THUMB_ENTRY:
174 thumb_entry_symbol = optarg;
175 break;
176'
252b5132 177
41392f03
AM
178# We have our own after_open and before_allocation functions, but they call
179# the standard routines, so give them a different name.
180LDEMUL_AFTER_OPEN=arm_elf_after_open
181LDEMUL_BEFORE_ALLOCATION=arm_elf_before_allocation
252b5132 182
41392f03
AM
183# Replace the elf before_parse function with our own.
184LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
252b5132 185
41392f03 186# Call the extra arm-elf function
a48ca7f2 187LDEMUL_FINISH=arm_elf_finish
This page took 0.107555 seconds and 4 git commands to generate.