1 /* This file is is generated by a shell script. DO NOT EDIT! */
3 /* Handle embedded relocs for MIPS.
4 Copyright 1994 Free Software Foundation, Inc.
7 This file is part of GLD, the Gnu Linker.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23 #define TARGET_IS_mipsidt
25 #include "libiberty.h"
37 static void gldmipsidt_before_parse PARAMS ((void));
38 static void gldmipsidt_after_open PARAMS ((void));
39 static void check_sections PARAMS ((bfd *, asection *, PTR));
40 static void gldmipsidt_after_allocation PARAMS ((void));
41 static char *gldmipsidt_get_script PARAMS ((int *isfile));
44 gldmipsidt_before_parse()
46 #ifndef TARGET_ /* I.e., if not generic. */
47 ldfile_output_architecture = bfd_arch_mips;
48 #endif /* not TARGET_ */
51 /* This function is run after all the input files have been opened.
52 We create a .rel.sdata section for each input file with a non zero
53 .sdata section. The BFD backend will fill in these sections with
54 magic numbers which can be used to relocate the data section at run
55 time. This will only do the right thing if all the input files
56 have been compiled using -membedded-pic. */
59 gldmipsidt_after_open ()
63 if (! command_line.embedded_relocs
64 || link_info.relocateable)
67 for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
71 datasec = bfd_get_section_by_name (abfd, ".sdata");
73 /* Note that we assume that the reloc_count field has already
74 been set up. We could call bfd_get_reloc_upper_bound, but
75 that returns the size of a memory buffer rather than a reloc
76 count. We do not want to call bfd_canonicalize_reloc,
77 because although it would always work it would force us to
78 read in the relocs into BFD canonical form, which would waste
79 a significant amount of time and memory. */
80 if (datasec != NULL && datasec->reloc_count > 0)
84 relsec = bfd_make_section (abfd, ".rel.sdata");
86 || ! bfd_set_section_flags (abfd, relsec,
91 || ! bfd_set_section_alignment (abfd, relsec, 2)
92 || ! bfd_set_section_size (abfd, relsec,
93 datasec->reloc_count * 4))
94 einfo ("%F%B: can not create .rel.sdata section: %E");
97 /* Double check that all other data sections are empty, as is
98 required for embedded PIC code. */
99 bfd_map_over_sections (abfd, check_sections, (PTR) datasec);
103 /* Check that of the data sections, only the .sdata section has
104 relocs. This is called via bfd_map_over_sections. */
107 check_sections (abfd, sec, sdatasec)
112 if ((bfd_get_section_flags (abfd, sec) & SEC_CODE) == 0
113 && sec != (asection *) sdatasec
114 && sec->reloc_count != 0)
115 einfo ("%F%X: section %s has relocs; can not use --embedded-relocs",
116 abfd, bfd_get_section_name (abfd, sec));
119 /* This function is called after the section sizes and offsets have
120 been set. If we are generating embedded relocs, it calls a special
121 BFD backend routine to do the work. */
124 gldmipsidt_after_allocation ()
128 if (! command_line.embedded_relocs
129 || link_info.relocateable)
132 for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
134 asection *datasec, *relsec;
137 datasec = bfd_get_section_by_name (abfd, ".sdata");
139 if (datasec == NULL || datasec->reloc_count == 0)
142 relsec = bfd_get_section_by_name (abfd, ".rel.sdata");
143 ASSERT (relsec != NULL);
145 if (! bfd_mips_ecoff_create_embedded_relocs (abfd, &link_info,
150 einfo ("%B%X: can not create runtime reloc information: %E",
153 einfo ("%X%B: can not create runtime reloc information: %s",
160 gldmipsidt_get_script(isfile)
165 if (link_info.relocateable == true && config.build_constructors == true)
168 "OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\
169 \"ecoff-littlemips\")\n\
170 SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\
209 ; else if (link_info.relocateable == true) return
210 "OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\
211 \"ecoff-littlemips\")\n\
212 SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\
250 ; else if (!config.text_read_only) return
252 "OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\
253 \"ecoff-littlemips\")\n\
254 SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\
264 PROVIDE (__runtime_reloc_start = .);\n\
266 PROVIDE (__runtime_reloc_stop = .);\n\
275 _fdata = ALIGN(16);\n\
280 _gp = ALIGN(16) + 0x8000;\n\
305 ; else if (!config.magic_demand_paged) return
307 "OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\
308 \"ecoff-littlemips\")\n\
309 SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\
319 PROVIDE (__runtime_reloc_start = .);\n\
321 PROVIDE (__runtime_reloc_stop = .);\n\
330 _fdata = ALIGN(16);\n\
335 _gp = ALIGN(16) + 0x8000;\n\
362 "OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\
363 \"ecoff-littlemips\")\n\
364 SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\
374 PROVIDE (__runtime_reloc_start = .);\n\
376 PROVIDE (__runtime_reloc_stop = .);\n\
385 _fdata = ALIGN(16);\n\
390 _gp = ALIGN(16) + 0x8000;\n\
417 struct ld_emulation_xfer_struct ld_mipsidt_emulation =
419 gldmipsidt_before_parse,
423 gldmipsidt_after_open,
424 gldmipsidt_after_allocation,
425 set_output_arch_default,
426 ldemul_default_target,
427 before_allocation_default,
428 gldmipsidt_get_script,