* emultempl/hppaelf.em (build_section_lists): New function.
[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
c56feb2b
AM
107 /* Call the elf32.em routine. */
108 gld${EMULATION_NAME}_finish ();
109
6f798e5c
NC
110 if (thumb_entry_symbol == NULL)
111 return;
112
41392f03
AM
113 h = bfd_link_hash_lookup (link_info.hash, thumb_entry_symbol,
114 false, false, true);
6f798e5c
NC
115
116 if (h != (struct bfd_link_hash_entry *) NULL
117 && (h->type == bfd_link_hash_defined
118 || h->type == bfd_link_hash_defweak)
119 && h->u.def.section->output_section != NULL)
120 {
121 static char buffer[32];
122 bfd_vma val;
123
124 /* Special procesing is required for a Thumb entry symbol. The
125 bottom bit of its address must be set. */
126 val = (h->u.def.value
127 + bfd_get_section_vma (output_bfd,
128 h->u.def.section->output_section)
129 + h->u.def.section->output_offset);
130
131 val |= 1;
132
133 /* Now convert this value into a string and store it in entry_symbol
134 where the lang_finish() function will pick it up. */
135 buffer[0] = '0';
136 buffer[1] = 'x';
137
138 sprintf_vma (buffer + 2, val);
139
140 if (entry_symbol != NULL && entry_from_cmdline)
141 einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
142 thumb_entry_symbol, entry_symbol);
143 entry_symbol = buffer;
144 }
145 else
41392f03
AM
146 einfo (_("%P: warning: connot find thumb start symbol %s\n"),
147 thumb_entry_symbol);
6f798e5c
NC
148}
149
252b5132
RH
150EOF
151
41392f03
AM
152# Define some shell vars to insert bits of code into the standard elf
153# parse_args and list_options functions.
154#
155PARSE_AND_LIST_PROLOGUE='
156#define OPTION_THUMB_ENTRY 301
157'
252b5132 158
5835c212
NC
159# Note we add 'n' to the short option list in order to prevent
160# getopt_long_only from thinking that -n is a unique abbreviation
161# for --no-pipeline-knowledge. There is no case to handle 'n' here
162# however, so instead it will be passed back to parse_args() in
163# lexsup.c where it will be handled.
164PARSE_AND_LIST_SHORTOPTS=pn
252b5132 165
41392f03
AM
166PARSE_AND_LIST_LONGOPTS='
167 { "no-pipeline-knowledge", no_argument, NULL, '\'p\''},
168 { "thumb-entry", required_argument, NULL, OPTION_THUMB_ENTRY},
169'
252b5132 170
41392f03
AM
171PARSE_AND_LIST_OPTIONS='
172 fprintf (file, _(" -p --no-pipeline-knowledge Stop the linker knowing about the pipeline length\n"));
173 fprintf (file, _(" --thumb-entry=<sym> Set the entry point to be Thumb symbol <sym>\n"));
174'
252b5132 175
41392f03
AM
176PARSE_AND_LIST_ARGS_CASES='
177 case '\'p\'':
178 no_pipeline_knowledge = 1;
179 break;
252b5132 180
41392f03
AM
181 case OPTION_THUMB_ENTRY:
182 thumb_entry_symbol = optarg;
183 break;
184'
252b5132 185
41392f03
AM
186# We have our own after_open and before_allocation functions, but they call
187# the standard routines, so give them a different name.
188LDEMUL_AFTER_OPEN=arm_elf_after_open
189LDEMUL_BEFORE_ALLOCATION=arm_elf_before_allocation
252b5132 190
41392f03
AM
191# Replace the elf before_parse function with our own.
192LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
252b5132 193
41392f03 194# Call the extra arm-elf function
a48ca7f2 195LDEMUL_FINISH=arm_elf_finish
This page took 0.116947 seconds and 4 git commands to generate.