2000-03-08 H.J. Lu (hjl@gnu.org)
[binutils.git] / ld / mpw-elfmips.c
blobe8ab0560aa83a0df3c3ed4002bfdea3b6b4f368e
1 /* This file is is generated by a shell script. DO NOT EDIT! */
3 /* 32 bit ELF emulation code for elf32ebmip
4 Copyright (C) 1991, 93, 94, 95, 1996, 1998 Free Software Foundation, Inc.
5 Written by Steve Chamberlain <sac@cygnus.com>
6 ELF support by Ian Lance Taylor <ian@cygnus.com>
8 This file is part of GLD, the Gnu Linker.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 #define TARGET_IS_elf32ebmip
26 #include "bfd.h"
27 #include "sysdep.h"
29 #include <ctype.h>
31 #include "bfdlink.h"
33 #include "ld.h"
34 #include "ldmain.h"
35 #include "ldemul.h"
36 #include "ldfile.h"
37 #include "ldmisc.h"
38 #include "ldexp.h"
39 #include "ldlang.h"
40 #include "ldgram.h"
42 static void gldelf32ebmip_before_parse PARAMS ((void));
43 static boolean gldelf32ebmip_open_dynamic_archive
44 PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *));
45 static void gldelf32ebmip_after_open PARAMS ((void));
46 static void gldelf32ebmip_check_needed
47 PARAMS ((lang_input_statement_type *));
48 static void gldelf32ebmip_stat_needed
49 PARAMS ((lang_input_statement_type *));
50 static boolean gldelf32ebmip_search_needed
51 PARAMS ((const char *, const char *));
52 static boolean gldelf32ebmip_try_needed PARAMS ((const char *));
53 static void gldelf32ebmip_before_allocation PARAMS ((void));
54 static void gldelf32ebmip_find_statement_assignment
55 PARAMS ((lang_statement_union_type *));
56 static void gldelf32ebmip_find_exp_assignment PARAMS ((etree_type *));
57 static boolean gldelf32ebmip_place_orphan
58 PARAMS ((lang_input_statement_type *, asection *));
59 static void gldelf32ebmip_place_section
60 PARAMS ((lang_statement_union_type *));
61 static char *gldelf32ebmip_get_script PARAMS ((int *isfile));
63 static void
64 gldelf32ebmip_before_parse()
66 ldfile_output_architecture = bfd_arch_mips;
67 config.dynamic_link = true;
70 /* Try to open a dynamic archive. This is where we know that ELF
71 dynamic libraries have an extension of .so. */
73 static boolean
74 gldelf32ebmip_open_dynamic_archive (arch, search, entry)
75 const char *arch;
76 search_dirs_type *search;
77 lang_input_statement_type *entry;
79 const char *filename;
80 char *string;
82 if (! entry->is_archive)
83 return false;
85 filename = entry->filename;
87 string = (char *) xmalloc (strlen (search->name)
88 + strlen (filename)
89 + strlen (arch)
90 + sizeof "/lib.so");
92 sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
94 if (! ldfile_try_open_bfd (string, entry))
96 free (string);
97 return false;
100 entry->filename = string;
102 /* We have found a dynamic object to include in the link. The ELF
103 backend linker will create a DT_NEEDED entry in the .dynamic
104 section naming this file. If this file includes a DT_SONAME
105 entry, it will be used. Otherwise, the ELF linker will just use
106 the name of the file. For an archive found by searching, like
107 this one, the DT_NEEDED entry should consist of just the name of
108 the file, without the path information used to find it. Note
109 that we only need to do this if we have a dynamic object; an
110 archive will never be referenced by a DT_NEEDED entry.
112 FIXME: This approach--using bfd_elf_set_dt_needed_name--is not
113 very pretty. I haven't been able to think of anything that is
114 pretty, though. */
115 if (bfd_check_format (entry->the_bfd, bfd_object)
116 && (entry->the_bfd->flags & DYNAMIC) != 0)
118 char *needed_name;
120 ASSERT (entry->is_archive && entry->search_dirs_flag);
121 needed_name = (char *) xmalloc (strlen (filename)
122 + strlen (arch)
123 + sizeof "lib.so");
124 sprintf (needed_name, "lib%s%s.so", filename, arch);
125 bfd_elf_set_dt_needed_name (entry->the_bfd, needed_name);
128 return true;
132 /* These variables are required to pass information back and forth
133 between after_open and check_needed and stat_needed. */
135 static struct bfd_link_needed_list *global_needed;
136 static struct stat global_stat;
137 static boolean global_found;
139 /* This is called after all the input files have been opened. */
141 static void
142 gldelf32ebmip_after_open ()
144 struct bfd_link_needed_list *needed, *l;
146 /* We only need to worry about this when doing a final link. */
147 if (link_info.relocateable || link_info.shared)
148 return;
150 /* Get the list of files which appear in DT_NEEDED entries in
151 dynamic objects included in the link (often there will be none).
152 For each such file, we want to track down the corresponding
153 library, and include the symbol table in the link. This is what
154 the runtime dynamic linker will do. Tracking the files down here
155 permits one dynamic object to include another without requiring
156 special action by the person doing the link. Note that the
157 needed list can actually grow while we are stepping through this
158 loop. */
159 needed = bfd_elf_get_needed_list (output_bfd, &link_info);
160 for (l = needed; l != NULL; l = l->next)
162 struct bfd_link_needed_list *ll;
163 const char *lib_path;
164 size_t len;
165 search_dirs_type *search;
167 /* If we've already seen this file, skip it. */
168 for (ll = needed; ll != l; ll = ll->next)
169 if (strcmp (ll->name, l->name) == 0)
170 break;
171 if (ll != l)
172 continue;
174 /* See if this file was included in the link explicitly. */
175 global_needed = l;
176 global_found = false;
177 lang_for_each_input_file (gldelf32ebmip_check_needed);
178 if (global_found)
179 continue;
181 /* We need to find this file and include the symbol table. We
182 want to search for the file in the same way that the dynamic
183 linker will search. That means that we want to use
184 rpath_link, rpath, then the environment variable
185 LD_LIBRARY_PATH (native only), then the linker script
186 LIB_SEARCH_DIRS. We do not search using the -L arguments. */
187 if (gldelf32ebmip_search_needed (command_line.rpath_link,
188 l->name))
189 continue;
190 if (gldelf32ebmip_search_needed (command_line.rpath, l->name))
191 continue;
192 if (command_line.rpath_link == NULL
193 && command_line.rpath == NULL)
195 lib_path = (const char *) getenv ("LD_RUN_PATH");
196 if (gldelf32ebmip_search_needed (lib_path, l->name))
197 continue;
199 len = strlen (l->name);
200 for (search = search_head; search != NULL; search = search->next)
202 char *filename;
204 if (search->cmdline)
205 continue;
206 filename = (char *) xmalloc (strlen (search->name) + len + 2);
207 sprintf (filename, "%s/%s", search->name, l->name);
208 if (gldelf32ebmip_try_needed (filename))
209 break;
210 free (filename);
212 if (search != NULL)
213 continue;
215 einfo (_("%P: warning: %s, needed by %B, not found\n"),
216 l->name, l->by);
220 /* Search for a needed file in a path. */
222 static boolean
223 gldelf32ebmip_search_needed (path, name)
224 const char *path;
225 const char *name;
227 const char *s;
228 size_t len;
230 if (path == NULL || *path == '\0')
231 return false;
232 len = strlen (name);
233 while (1)
235 char *filename, *sset;
237 s = strchr (path, ':');
238 if (s == NULL)
239 s = path + strlen (path);
241 filename = (char *) xmalloc (s - path + len + 2);
242 if (s == path)
243 sset = filename;
244 else
246 memcpy (filename, path, s - path);
247 filename[s - path] = '/';
248 sset = filename + (s - path) + 1;
250 strcpy (sset, name);
252 if (gldelf32ebmip_try_needed (filename))
253 return true;
255 free (filename);
257 if (*s == '\0')
258 break;
259 path = s + 1;
262 return false;
265 /* This function is called for each possible name for a dynamic object
266 named by a DT_NEEDED entry. */
268 static boolean
269 gldelf32ebmip_try_needed (name)
270 const char *name;
272 bfd *abfd;
274 abfd = bfd_openr (name, bfd_get_target (output_bfd));
275 if (abfd == NULL)
276 return false;
277 if (! bfd_check_format (abfd, bfd_object))
279 (void) bfd_close (abfd);
280 return false;
282 if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0)
284 (void) bfd_close (abfd);
285 return false;
288 /* We've found a dynamic object matching the DT_NEEDED entry. */
290 /* We have already checked that there is no other input file of the
291 same name. We must now check again that we are not including the
292 same file twice. We need to do this because on many systems
293 libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will
294 reference libc.so.1. If we have already included libc.so, we
295 don't want to include libc.so.1 if they are the same file, and we
296 can only check that using stat. */
298 if (bfd_stat (abfd, &global_stat) != 0)
299 einfo (_("%F%P:%B: bfd_stat failed: %E\n"), abfd);
300 global_found = false;
301 lang_for_each_input_file (gldelf32ebmip_stat_needed);
302 if (global_found)
304 /* Return true to indicate that we found the file, even though
305 we aren't going to do anything with it. */
306 return true;
309 /* Tell the ELF backend that don't want the output file to have a
310 DT_NEEDED entry for this file. */
311 bfd_elf_set_dt_needed_name (abfd, "");
313 /* Add this file into the symbol table. */
314 if (! bfd_link_add_symbols (abfd, &link_info))
315 einfo (_("%F%B: could not read symbols: %E\n"), abfd);
317 return true;
320 /* See if an input file matches a DT_NEEDED entry by name. */
322 static void
323 gldelf32ebmip_check_needed (s)
324 lang_input_statement_type *s;
326 if (global_found)
327 return;
329 if (s->filename != NULL
330 && strcmp (s->filename, global_needed->name) == 0)
332 global_found = true;
333 return;
336 if (s->the_bfd != NULL)
338 const char *soname;
340 soname = bfd_elf_get_dt_soname (s->the_bfd);
341 if (soname != NULL
342 && strcmp (soname, global_needed->name) == 0)
344 global_found = true;
345 return;
349 if (s->search_dirs_flag
350 && s->filename != NULL
351 && strchr (global_needed->name, '/') == NULL)
353 const char *f;
355 f = strrchr (s->filename, '/');
356 if (f != NULL
357 && strcmp (f + 1, global_needed->name) == 0)
359 global_found = true;
360 return;
365 /* See if an input file matches a DT_NEEDED entry by running stat on
366 the file. */
368 static void
369 gldelf32ebmip_stat_needed (s)
370 lang_input_statement_type *s;
372 struct stat st;
373 const char *suffix;
374 const char *soname;
375 const char *f;
377 if (global_found)
378 return;
379 if (s->the_bfd == NULL)
380 return;
382 if (bfd_stat (s->the_bfd, &st) != 0)
384 einfo (_("%P:%B: bfd_stat failed: %E\n"), s->the_bfd);
385 return;
388 if (st.st_dev == global_stat.st_dev
389 && st.st_ino == global_stat.st_ino)
391 global_found = true;
392 return;
395 /* We issue a warning if it looks like we are including two
396 different versions of the same shared library. For example,
397 there may be a problem if -lc picks up libc.so.6 but some other
398 shared library has a DT_NEEDED entry of libc.so.5. This is a
399 hueristic test, and it will only work if the name looks like
400 NAME.so.VERSION. FIXME: Depending on file names is error-prone.
401 If we really want to issue warnings about mixing version numbers
402 of shared libraries, we need to find a better way. */
404 if (strchr (global_needed->name, '/') != NULL)
405 return;
406 suffix = strstr (global_needed->name, ".so.");
407 if (suffix == NULL)
408 return;
409 suffix += sizeof ".so." - 1;
411 soname = bfd_elf_get_dt_soname (s->the_bfd);
412 if (soname == NULL)
413 soname = s->filename;
415 f = strrchr (soname, '/');
416 if (f != NULL)
417 ++f;
418 else
419 f = soname;
421 if (strncmp (f, global_needed->name, suffix - global_needed->name) == 0)
422 einfo (_("%P: warning: %s, needed by %B, may conflict with %s\n"),
423 global_needed->name, global_needed->by, f);
426 /* This is called after the sections have been attached to output
427 sections, but before any sizes or addresses have been set. */
429 static void
430 gldelf32ebmip_before_allocation ()
432 const char *rpath;
433 asection *sinterp;
435 /* If we are going to make any variable assignments, we need to let
436 the ELF backend know about them in case the variables are
437 referred to by dynamic objects. */
438 lang_for_each_statement (gldelf32ebmip_find_statement_assignment);
440 /* Let the ELF backend work out the sizes of any sections required
441 by dynamic linking. */
442 rpath = command_line.rpath;
443 if (rpath == NULL)
444 rpath = (const char *) getenv ("LD_RUN_PATH");
445 if (! bfd_elf32_size_dynamic_sections (output_bfd,
446 command_line.soname,
447 rpath,
448 command_line.export_dynamic,
449 &link_info,
450 &sinterp))
451 einfo (_("%P%F: failed to set dynamic section sizes: %E\n"));
453 /* Let the user override the dynamic linker we are using. */
454 if (command_line.interpreter != NULL
455 && sinterp != NULL)
457 sinterp->contents = (bfd_byte *) command_line.interpreter;
458 sinterp->_raw_size = strlen (command_line.interpreter) + 1;
461 /* Look for any sections named .gnu.warning. As a GNU extensions,
462 we treat such sections as containing warning messages. We print
463 out the warning message, and then zero out the section size so
464 that it does not get copied into the output file. */
467 LANG_FOR_EACH_INPUT_STATEMENT (is)
469 asection *s;
470 bfd_size_type sz;
471 char *msg;
472 boolean ret;
474 if (is->just_syms_flag)
475 continue;
477 s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning");
478 if (s == NULL)
479 continue;
481 sz = bfd_section_size (is->the_bfd, s);
482 msg = xmalloc ((size_t) sz + 1);
483 if (! bfd_get_section_contents (is->the_bfd, s, msg, (file_ptr) 0, sz))
484 einfo (_("%F%B: Can't read contents of section .gnu.warning: %E\n"),
485 is->the_bfd);
486 msg[sz] = '\0';
487 ret = link_info.callbacks->warning (&link_info, msg,
488 (const char *) NULL,
489 is->the_bfd, (asection *) NULL,
490 (bfd_vma) 0);
491 ASSERT (ret);
492 free (msg);
494 /* Clobber the section size, so that we don't waste copying the
495 warning into the output file. */
496 s->_raw_size = 0;
501 /* This is called by the before_allocation routine via
502 lang_for_each_statement. It locates any assignment statements, and
503 tells the ELF backend about them, in case they are assignments to
504 symbols which are referred to by dynamic objects. */
506 static void
507 gldelf32ebmip_find_statement_assignment (s)
508 lang_statement_union_type *s;
510 if (s->header.type == lang_assignment_statement_enum)
511 gldelf32ebmip_find_exp_assignment (s->assignment_statement.exp);
514 /* Look through an expression for an assignment statement. */
516 static void
517 gldelf32ebmip_find_exp_assignment (exp)
518 etree_type *exp;
520 struct bfd_link_hash_entry *h;
522 switch (exp->type.node_class)
524 case etree_provide:
525 h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst,
526 false, false, false);
527 if (h == NULL)
528 break;
530 /* We call record_link_assignment even if the symbol is defined.
531 This is because if it is defined by a dynamic object, we
532 actually want to use the value defined by the linker script,
533 not the value from the dynamic object (because we are setting
534 symbols like etext). If the symbol is defined by a regular
535 object, then, as it happens, calling record_link_assignment
536 will do no harm. */
538 /* Fall through. */
539 case etree_assign:
540 if (strcmp (exp->assign.dst, ".") != 0)
542 if (! (bfd_elf32_record_link_assignment
543 (output_bfd, &link_info, exp->assign.dst,
544 exp->type.node_class == etree_provide ? true : false)))
545 einfo (_("%P%F: failed to record assignment to %s: %E\n"),
546 exp->assign.dst);
548 gldelf32ebmip_find_exp_assignment (exp->assign.src);
549 break;
551 case etree_binary:
552 gldelf32ebmip_find_exp_assignment (exp->binary.lhs);
553 gldelf32ebmip_find_exp_assignment (exp->binary.rhs);
554 break;
556 case etree_trinary:
557 gldelf32ebmip_find_exp_assignment (exp->trinary.cond);
558 gldelf32ebmip_find_exp_assignment (exp->trinary.lhs);
559 gldelf32ebmip_find_exp_assignment (exp->trinary.rhs);
560 break;
562 case etree_unary:
563 gldelf32ebmip_find_exp_assignment (exp->unary.child);
564 break;
566 default:
567 break;
571 /* Place an orphan section. We use this to put random SHF_ALLOC
572 sections in the right segment. */
574 static asection *hold_section;
575 static lang_output_section_statement_type *hold_use;
576 static lang_output_section_statement_type *hold_text;
577 static lang_output_section_statement_type *hold_rodata;
578 static lang_output_section_statement_type *hold_data;
579 static lang_output_section_statement_type *hold_bss;
580 static lang_output_section_statement_type *hold_rel;
582 /*ARGSUSED*/
583 static boolean
584 gldelf32ebmip_place_orphan (file, s)
585 lang_input_statement_type *file;
586 asection *s;
588 lang_output_section_statement_type *place;
589 asection *snew, **pps;
590 lang_statement_list_type *old;
591 lang_statement_list_type add;
592 etree_type *address;
593 const char *secname, *ps;
594 lang_output_section_statement_type *os;
596 if ((s->flags & SEC_ALLOC) == 0)
597 return false;
599 /* Look through the script to see where to place this section. */
600 hold_section = s;
601 hold_use = NULL;
602 lang_for_each_statement (gldelf32ebmip_place_section);
604 if (hold_use != NULL)
606 /* We have already placed a section with this name. */
607 wild_doit (&hold_use->children, s, hold_use, file);
608 return true;
611 secname = bfd_get_section_name (s->owner, s);
613 /* If this is a final link, then always put .gnu.warning.SYMBOL
614 sections into the .text section to get them out of the way. */
615 if (! link_info.shared
616 && ! link_info.relocateable
617 && strncmp (secname, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0
618 && hold_text != NULL)
620 wild_doit (&hold_text->children, s, hold_text, file);
621 return true;
624 /* Decide which segment the section should go in based on the
625 section name and section flags. */
626 place = NULL;
627 if ((s->flags & SEC_HAS_CONTENTS) == 0
628 && hold_bss != NULL)
629 place = hold_bss;
630 else if ((s->flags & SEC_READONLY) == 0
631 && hold_data != NULL)
632 place = hold_data;
633 else if (strncmp (secname, ".rel", 4) == 0
634 && hold_rel != NULL)
635 place = hold_rel;
636 else if ((s->flags & SEC_CODE) == 0
637 && (s->flags & SEC_READONLY) != 0
638 && hold_rodata != NULL)
639 place = hold_rodata;
640 else if ((s->flags & SEC_READONLY) != 0
641 && hold_text != NULL)
642 place = hold_text;
643 if (place == NULL)
644 return false;
646 /* Create the section in the output file, and put it in the right
647 place. This shuffling is to make the output file look neater. */
648 snew = bfd_make_section (output_bfd, secname);
649 if (snew == NULL)
650 einfo (_("%P%F: output format %s cannot represent section called %s\n"),
651 output_bfd->xvec->name, secname);
652 if (place->bfd_section != NULL)
654 for (pps = &output_bfd->sections; *pps != snew; pps = &(*pps)->next)
656 *pps = snew->next;
657 snew->next = place->bfd_section->next;
658 place->bfd_section->next = snew;
661 /* Start building a list of statements for this section. */
662 old = stat_ptr;
663 stat_ptr = &add;
664 lang_list_init (stat_ptr);
666 /* If the name of the section is representable in C, then create
667 symbols to mark the start and the end of the section. */
668 for (ps = secname; *ps != '\0'; ps++)
669 if (! isalnum (*ps) && *ps != '_')
670 break;
671 if (*ps == '\0' && config.build_constructors)
673 char *symname;
675 symname = (char *) xmalloc (ps - secname + sizeof "__start_");
676 sprintf (symname, "__start_%s", secname);
677 lang_add_assignment (exp_assop ('=', symname,
678 exp_unop (ALIGN_K,
679 exp_intop ((bfd_vma) 1
680 << s->alignment_power))));
683 if (! link_info.relocateable)
684 address = NULL;
685 else
686 address = exp_intop ((bfd_vma) 0);
688 lang_enter_output_section_statement (secname, address, 0,
689 (bfd_vma) 0,
690 (etree_type *) NULL,
691 (etree_type *) NULL,
692 (etree_type *) NULL);
694 os = lang_output_section_statement_lookup (secname);
695 wild_doit (&os->children, s, os, file);
697 lang_leave_output_section_statement ((bfd_vma) 0, "*default*");
698 stat_ptr = &add;
700 if (*ps == '\0' && config.build_constructors)
702 char *symname;
704 symname = (char *) xmalloc (ps - secname + sizeof "__stop_");
705 sprintf (symname, "__stop_%s", secname);
706 lang_add_assignment (exp_assop ('=', symname,
707 exp_nameop (NAME, ".")));
710 /* Now stick the new statement list right after PLACE. */
711 *add.tail = place->header.next;
712 place->header.next = add.head;
714 stat_ptr = old;
716 return true;
719 static void
720 gldelf32ebmip_place_section (s)
721 lang_statement_union_type *s;
723 lang_output_section_statement_type *os;
725 if (s->header.type != lang_output_section_statement_enum)
726 return;
728 os = &s->output_section_statement;
730 if (strcmp (os->name, hold_section->name) == 0)
731 hold_use = os;
733 if (strcmp (os->name, ".text") == 0)
734 hold_text = os;
735 else if (strcmp (os->name, ".rodata") == 0)
736 hold_rodata = os;
737 else if (strcmp (os->name, ".data") == 0)
738 hold_data = os;
739 else if (strcmp (os->name, ".bss") == 0)
740 hold_bss = os;
741 else if (hold_rel == NULL
742 && os->bfd_section != NULL
743 && strncmp (os->name, ".rel", 4) == 0)
744 hold_rel = os;
747 static char *
748 gldelf32ebmip_get_script(isfile)
749 int *isfile;
751 *isfile = 0;
753 if (link_info.relocateable == true && config.build_constructors == true)
754 return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\
755 \"elf32-littlemips\")\n\
756 OUTPUT_ARCH(mips)\n\
757 ENTRY(_start)\n\
758 /* For some reason, the Solaris linker makes bad executables\n\
759 if gld -r is used and the intermediate file has sections starting\n\
760 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld\n\
761 bug. But for now assigning the zero vmas works. */\n\
762 SECTIONS\n\
763 {\n\
764 /* Read-only sections, merged into text segment: */\n\
765 .interp 0 : { *(.interp) }\n\
766 .reginfo 0 : { *(.reginfo) }\n\
767 .dynamic 0 : { *(.dynamic) }\n\
768 .dynstr 0 : { *(.dynstr) }\n\
769 .dynsym 0 : { *(.dynsym) }\n\
770 .hash 0 : { *(.hash) }\n\
771 .rel.text 0 : { *(.rel.text) }\n\
772 .rela.text 0 : { *(.rela.text) }\n\
773 .rel.data 0 : { *(.rel.data) }\n\
774 .rela.data 0 : { *(.rela.data) }\n\
775 .rel.rodata 0 : { *(.rel.rodata) }\n\
776 .rela.rodata 0 : { *(.rela.rodata) }\n\
777 .rel.got 0 : { *(.rel.got) }\n\
778 .rela.got 0 : { *(.rela.got) }\n\
779 .rel.ctors 0 : { *(.rel.ctors) }\n\
780 .rela.ctors 0 : { *(.rela.ctors) }\n\
781 .rel.dtors 0 : { *(.rel.dtors) }\n\
782 .rela.dtors 0 : { *(.rela.dtors) }\n\
783 .rel.init 0 : { *(.rel.init) }\n\
784 .rela.init 0 : { *(.rela.init) }\n\
785 .rel.fini 0 : { *(.rel.fini) }\n\
786 .rela.fini 0 : { *(.rela.fini) }\n\
787 .rel.bss 0 : { *(.rel.bss) }\n\
788 .rela.bss 0 : { *(.rela.bss) }\n\
789 .rel.plt 0 : { *(.rel.plt) }\n\
790 .rela.plt 0 : { *(.rela.plt) }\n\
791 .rodata 0 : { *(.rodata) }\n\
792 .rodata1 0 : { *(.rodata1) }\n\
793 .init 0 : { *(.init) } =0\n\
794 .text 0 :\n\
795 {\n\
796 *(.text)\n\
797 *(.stub)\n\
798 /* .gnu.warning sections are handled specially by elf32.em. */\n\
799 *(.gnu.warning)\n\
800 } =0\n\
801 .fini 0 : { *(.fini) } =0\n\
802 /* Adjust the address for the data segment. We want to adjust up to\n\
803 the same address within the page on the next page up. It would\n\
804 be more correct to do this:\n\
805 The current expression does not correctly handle the case of a\n\
806 text segment ending precisely at the end of a page; it causes the\n\
807 data segment to skip a page. The above expression does not have\n\
808 this problem, but it will currently (2/95) cause BFD to allocate\n\
809 a single segment, combining both text and data, for this case.\n\
810 This will prevent the text segment from being shared among\n\
811 multiple executions of the program; I think that is more\n\
812 important than losing a page of the virtual address space (note\n\
813 that no actual memory is lost; the page which is skipped can not\n\
814 be referenced). */\n\
815 .data 0 :\n\
816 {\n\
817 *(.data)\n\
818 CONSTRUCTORS\n\
819 }\n\
820 .data1 0 : { *(.data1) }\n\
821 .ctors 0 : { *(.ctors) }\n\
822 .dtors 0 : { *(.dtors) }\n\
823 .got 0 :\n\
824 {\n\
825 *(.got.plt) *(.got)\n\
826 }\n\
827 /* We want the small data sections together, so single-instruction offsets\n\
828 can access them all, and initialized data all before uninitialized, so\n\
829 we can shorten the on-disk segment size. */\n\
830 .sdata 0 : { *(.sdata) }\n\
831 .sbss 0 : { *(.sbss) *(.scommon) }\n\
832 .bss 0 :\n\
833 {\n\
834 *(.dynbss)\n\
835 *(.bss)\n\
836 *(COMMON)\n\
837 }\n\
838 /* These are needed for ELF backends which have not yet been\n\
839 converted to the new style linker. */\n\
840 .stab 0 : { *(.stab) }\n\
841 .stabstr 0 : { *(.stabstr) }\n\
842 /* DWARF debug sections.\n\
843 Symbols in the .debug DWARF section are relative to the beginning of the\n\
844 section so we begin .debug at 0. It's not clear yet what needs to happen\n\
845 for the others. */\n\
846 .debug 0 : { *(.debug) }\n\
847 .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\
848 .debug_aranges 0 : { *(.debug_aranges) }\n\
849 .debug_pubnames 0 : { *(.debug_pubnames) }\n\
850 .debug_sfnames 0 : { *(.debug_sfnames) }\n\
851 .line 0 : { *(.line) }\n\
852 /* These must appear regardless of . */\n\
853 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\
854 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\
855 }\n\n";
856 else if (link_info.relocateable == true)
857 return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\
858 \"elf32-littlemips\")\n\
859 OUTPUT_ARCH(mips)\n\
860 ENTRY(_start)\n\
861 /* For some reason, the Solaris linker makes bad executables\n\
862 if gld -r is used and the intermediate file has sections starting\n\
863 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld\n\
864 bug. But for now assigning the zero vmas works. */\n\
865 SECTIONS\n\
866 {\n\
867 /* Read-only sections, merged into text segment: */\n\
868 .interp 0 : { *(.interp) }\n\
869 .reginfo 0 : { *(.reginfo) }\n\
870 .dynamic 0 : { *(.dynamic) }\n\
871 .dynstr 0 : { *(.dynstr) }\n\
872 .dynsym 0 : { *(.dynsym) }\n\
873 .hash 0 : { *(.hash) }\n\
874 .rel.text 0 : { *(.rel.text) }\n\
875 .rela.text 0 : { *(.rela.text) }\n\
876 .rel.data 0 : { *(.rel.data) }\n\
877 .rela.data 0 : { *(.rela.data) }\n\
878 .rel.rodata 0 : { *(.rel.rodata) }\n\
879 .rela.rodata 0 : { *(.rela.rodata) }\n\
880 .rel.got 0 : { *(.rel.got) }\n\
881 .rela.got 0 : { *(.rela.got) }\n\
882 .rel.ctors 0 : { *(.rel.ctors) }\n\
883 .rela.ctors 0 : { *(.rela.ctors) }\n\
884 .rel.dtors 0 : { *(.rel.dtors) }\n\
885 .rela.dtors 0 : { *(.rela.dtors) }\n\
886 .rel.init 0 : { *(.rel.init) }\n\
887 .rela.init 0 : { *(.rela.init) }\n\
888 .rel.fini 0 : { *(.rel.fini) }\n\
889 .rela.fini 0 : { *(.rela.fini) }\n\
890 .rel.bss 0 : { *(.rel.bss) }\n\
891 .rela.bss 0 : { *(.rela.bss) }\n\
892 .rel.plt 0 : { *(.rel.plt) }\n\
893 .rela.plt 0 : { *(.rela.plt) }\n\
894 .rodata 0 : { *(.rodata) }\n\
895 .rodata1 0 : { *(.rodata1) }\n\
896 .init 0 : { *(.init) } =0\n\
897 .text 0 :\n\
898 {\n\
899 *(.text)\n\
900 *(.stub)\n\
901 /* .gnu.warning sections are handled specially by elf32.em. */\n\
902 *(.gnu.warning)\n\
903 } =0\n\
904 .fini 0 : { *(.fini) } =0\n\
905 /* Adjust the address for the data segment. We want to adjust up to\n\
906 the same address within the page on the next page up. It would\n\
907 be more correct to do this:\n\
908 The current expression does not correctly handle the case of a\n\
909 text segment ending precisely at the end of a page; it causes the\n\
910 data segment to skip a page. The above expression does not have\n\
911 this problem, but it will currently (2/95) cause BFD to allocate\n\
912 a single segment, combining both text and data, for this case.\n\
913 This will prevent the text segment from being shared among\n\
914 multiple executions of the program; I think that is more\n\
915 important than losing a page of the virtual address space (note\n\
916 that no actual memory is lost; the page which is skipped can not\n\
917 be referenced). */\n\
918 .data 0 :\n\
919 {\n\
920 *(.data)\n\
921 }\n\
922 .data1 0 : { *(.data1) }\n\
923 .ctors 0 : { *(.ctors) }\n\
924 .dtors 0 : { *(.dtors) }\n\
925 .got 0 :\n\
926 {\n\
927 *(.got.plt) *(.got)\n\
928 }\n\
929 /* We want the small data sections together, so single-instruction offsets\n\
930 can access them all, and initialized data all before uninitialized, so\n\
931 we can shorten the on-disk segment size. */\n\
932 .sdata 0 : { *(.sdata) }\n\
933 .sbss 0 : { *(.sbss) *(.scommon) }\n\
934 .bss 0 :\n\
935 {\n\
936 *(.dynbss)\n\
937 *(.bss)\n\
938 *(COMMON)\n\
939 }\n\
940 /* These are needed for ELF backends which have not yet been\n\
941 converted to the new style linker. */\n\
942 .stab 0 : { *(.stab) }\n\
943 .stabstr 0 : { *(.stabstr) }\n\
944 /* DWARF debug sections.\n\
945 Symbols in the .debug DWARF section are relative to the beginning of the\n\
946 section so we begin .debug at 0. It's not clear yet what needs to happen\n\
947 for the others. */\n\
948 .debug 0 : { *(.debug) }\n\
949 .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\
950 .debug_aranges 0 : { *(.debug_aranges) }\n\
951 .debug_pubnames 0 : { *(.debug_pubnames) }\n\
952 .debug_sfnames 0 : { *(.debug_sfnames) }\n\
953 .line 0 : { *(.line) }\n\
954 /* These must appear regardless of . */\n\
955 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\
956 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\
957 }\n\n";
958 else if (!config.text_read_only)
959 return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\
960 \"elf32-littlemips\")\n\
961 OUTPUT_ARCH(mips)\n\
962 ENTRY(_start)\n\
963 SEARCH_DIR(/usr/local/mips-elf/lib);\n\
964 /* Do we need any of these for elf?\n\
965 __DYNAMIC = 0; */\n\
966 SECTIONS\n\
967 {\n\
968 /* Read-only sections, merged into text segment: */\n\
969 . = 0x0400000;\n\
970 .interp : { *(.interp) }\n\
971 .reginfo : { *(.reginfo) }\n\
972 .dynamic : { *(.dynamic) }\n\
973 .dynstr : { *(.dynstr) }\n\
974 .dynsym : { *(.dynsym) }\n\
975 .hash : { *(.hash) }\n\
976 .rel.text : { *(.rel.text) }\n\
977 .rela.text : { *(.rela.text) }\n\
978 .rel.data : { *(.rel.data) }\n\
979 .rela.data : { *(.rela.data) }\n\
980 .rel.rodata : { *(.rel.rodata) }\n\
981 .rela.rodata : { *(.rela.rodata) }\n\
982 .rel.got : { *(.rel.got) }\n\
983 .rela.got : { *(.rela.got) }\n\
984 .rel.ctors : { *(.rel.ctors) }\n\
985 .rela.ctors : { *(.rela.ctors) }\n\
986 .rel.dtors : { *(.rel.dtors) }\n\
987 .rela.dtors : { *(.rela.dtors) }\n\
988 .rel.init : { *(.rel.init) }\n\
989 .rela.init : { *(.rela.init) }\n\
990 .rel.fini : { *(.rel.fini) }\n\
991 .rela.fini : { *(.rela.fini) }\n\
992 .rel.bss : { *(.rel.bss) }\n\
993 .rela.bss : { *(.rela.bss) }\n\
994 .rel.plt : { *(.rel.plt) }\n\
995 .rela.plt : { *(.rela.plt) }\n\
996 .rodata : { *(.rodata) }\n\
997 .rodata1 : { *(.rodata1) }\n\
998 .init : { *(.init) } =0\n\
999 .text :\n\
1000 {\n\
1001 _ftext = . ;\n\
1002 *(.text)\n\
1003 *(.stub)\n\
1004 /* .gnu.warning sections are handled specially by elf32.em. */\n\
1005 *(.gnu.warning)\n\
1006 } =0\n\
1007 _etext = .;\n\
1008 PROVIDE (etext = .);\n\
1009 .fini : { *(.fini) } =0\n\
1010 /* Adjust the address for the data segment. We want to adjust up to\n\
1011 the same address within the page on the next page up. It would\n\
1012 be more correct to do this:\n\
1013 . = .;\n\
1014 The current expression does not correctly handle the case of a\n\
1015 text segment ending precisely at the end of a page; it causes the\n\
1016 data segment to skip a page. The above expression does not have\n\
1017 this problem, but it will currently (2/95) cause BFD to allocate\n\
1018 a single segment, combining both text and data, for this case.\n\
1019 This will prevent the text segment from being shared among\n\
1020 multiple executions of the program; I think that is more\n\
1021 important than losing a page of the virtual address space (note\n\
1022 that no actual memory is lost; the page which is skipped can not\n\
1023 be referenced). */\n\
1024 . += . - 0x0400000;\n\
1025 .data :\n\
1026 {\n\
1027 _fdata = . ;\n\
1028 *(.data)\n\
1029 CONSTRUCTORS\n\
1030 }\n\
1031 .data1 : { *(.data1) }\n\
1032 .ctors : { *(.ctors) }\n\
1033 .dtors : { *(.dtors) }\n\
1034 _gp = ALIGN(16) + 0x7ff0;\n\
1035 .got :\n\
1036 {\n\
1037 *(.got.plt) *(.got)\n\
1038 }\n\
1039 /* We want the small data sections together, so single-instruction offsets\n\
1040 can access them all, and initialized data all before uninitialized, so\n\
1041 we can shorten the on-disk segment size. */\n\
1042 .sdata : { *(.sdata) }\n\
1043 .lit8 : { *(.lit8) }\n\
1044 .lit4 : { *(.lit4) }\n\
1045 _edata = .;\n\
1046 PROVIDE (edata = .);\n\
1047 __bss_start = .;\n\
1048 _fbss = .;\n\
1049 .sbss : { *(.sbss) *(.scommon) }\n\
1050 .bss :\n\
1051 {\n\
1052 *(.dynbss)\n\
1053 *(.bss)\n\
1054 *(COMMON)\n\
1055 }\n\
1056 _end = . ;\n\
1057 PROVIDE (end = .);\n\
1058 /* These are needed for ELF backends which have not yet been\n\
1059 converted to the new style linker. */\n\
1060 .stab 0 : { *(.stab) }\n\
1061 .stabstr 0 : { *(.stabstr) }\n\
1062 /* DWARF debug sections.\n\
1063 Symbols in the .debug DWARF section are relative to the beginning of the\n\
1064 section so we begin .debug at 0. It's not clear yet what needs to happen\n\
1065 for the others. */\n\
1066 .debug 0 : { *(.debug) }\n\
1067 .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\
1068 .debug_aranges 0 : { *(.debug_aranges) }\n\
1069 .debug_pubnames 0 : { *(.debug_pubnames) }\n\
1070 .debug_sfnames 0 : { *(.debug_sfnames) }\n\
1071 .line 0 : { *(.line) }\n\
1072 /* These must appear regardless of . */\n\
1073 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\
1074 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\
1075 }\n\n";
1076 else if (!config.magic_demand_paged)
1077 return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\
1078 \"elf32-littlemips\")\n\
1079 OUTPUT_ARCH(mips)\n\
1080 ENTRY(_start)\n\
1081 SEARCH_DIR(/usr/local/mips-elf/lib);\n\
1082 /* Do we need any of these for elf?\n\
1083 __DYNAMIC = 0; */\n\
1084 SECTIONS\n\
1085 {\n\
1086 /* Read-only sections, merged into text segment: */\n\
1087 . = 0x0400000;\n\
1088 .interp : { *(.interp) }\n\
1089 .reginfo : { *(.reginfo) }\n\
1090 .dynamic : { *(.dynamic) }\n\
1091 .dynstr : { *(.dynstr) }\n\
1092 .dynsym : { *(.dynsym) }\n\
1093 .hash : { *(.hash) }\n\
1094 .rel.text : { *(.rel.text) }\n\
1095 .rela.text : { *(.rela.text) }\n\
1096 .rel.data : { *(.rel.data) }\n\
1097 .rela.data : { *(.rela.data) }\n\
1098 .rel.rodata : { *(.rel.rodata) }\n\
1099 .rela.rodata : { *(.rela.rodata) }\n\
1100 .rel.got : { *(.rel.got) }\n\
1101 .rela.got : { *(.rela.got) }\n\
1102 .rel.ctors : { *(.rel.ctors) }\n\
1103 .rela.ctors : { *(.rela.ctors) }\n\
1104 .rel.dtors : { *(.rel.dtors) }\n\
1105 .rela.dtors : { *(.rela.dtors) }\n\
1106 .rel.init : { *(.rel.init) }\n\
1107 .rela.init : { *(.rela.init) }\n\
1108 .rel.fini : { *(.rel.fini) }\n\
1109 .rela.fini : { *(.rela.fini) }\n\
1110 .rel.bss : { *(.rel.bss) }\n\
1111 .rela.bss : { *(.rela.bss) }\n\
1112 .rel.plt : { *(.rel.plt) }\n\
1113 .rela.plt : { *(.rela.plt) }\n\
1114 .rodata : { *(.rodata) }\n\
1115 .rodata1 : { *(.rodata1) }\n\
1116 .init : { *(.init) } =0\n\
1117 .text :\n\
1118 {\n\
1119 _ftext = . ;\n\
1120 *(.text)\n\
1121 *(.stub)\n\
1122 /* .gnu.warning sections are handled specially by elf32.em. */\n\
1123 *(.gnu.warning)\n\
1124 } =0\n\
1125 _etext = .;\n\
1126 PROVIDE (etext = .);\n\
1127 .fini : { *(.fini) } =0\n\
1128 /* Adjust the address for the data segment. We want to adjust up to\n\
1129 the same address within the page on the next page up. It would\n\
1130 be more correct to do this:\n\
1131 . = 0x10000000;\n\
1132 The current expression does not correctly handle the case of a\n\
1133 text segment ending precisely at the end of a page; it causes the\n\
1134 data segment to skip a page. The above expression does not have\n\
1135 this problem, but it will currently (2/95) cause BFD to allocate\n\
1136 a single segment, combining both text and data, for this case.\n\
1137 This will prevent the text segment from being shared among\n\
1138 multiple executions of the program; I think that is more\n\
1139 important than losing a page of the virtual address space (note\n\
1140 that no actual memory is lost; the page which is skipped can not\n\
1141 be referenced). */\n\
1142 . += 0x10000000 - 0x0400000;\n\
1143 .data :\n\
1144 {\n\
1145 _fdata = . ;\n\
1146 *(.data)\n\
1147 CONSTRUCTORS\n\
1148 }\n\
1149 .data1 : { *(.data1) }\n\
1150 .ctors : { *(.ctors) }\n\
1151 .dtors : { *(.dtors) }\n\
1152 _gp = ALIGN(16) + 0x7ff0;\n\
1153 .got :\n\
1154 {\n\
1155 *(.got.plt) *(.got)\n\
1156 }\n\
1157 /* We want the small data sections together, so single-instruction offsets\n\
1158 can access them all, and initialized data all before uninitialized, so\n\
1159 we can shorten the on-disk segment size. */\n\
1160 .sdata : { *(.sdata) }\n\
1161 .lit8 : { *(.lit8) }\n\
1162 .lit4 : { *(.lit4) }\n\
1163 _edata = .;\n\
1164 PROVIDE (edata = .);\n\
1165 __bss_start = .;\n\
1166 _fbss = .;\n\
1167 .sbss : { *(.sbss) *(.scommon) }\n\
1168 .bss :\n\
1169 {\n\
1170 *(.dynbss)\n\
1171 *(.bss)\n\
1172 *(COMMON)\n\
1173 }\n\
1174 _end = . ;\n\
1175 PROVIDE (end = .);\n\
1176 /* These are needed for ELF backends which have not yet been\n\
1177 converted to the new style linker. */\n\
1178 .stab 0 : { *(.stab) }\n\
1179 .stabstr 0 : { *(.stabstr) }\n\
1180 /* DWARF debug sections.\n\
1181 Symbols in the .debug DWARF section are relative to the beginning of the\n\
1182 section so we begin .debug at 0. It's not clear yet what needs to happen\n\
1183 for the others. */\n\
1184 .debug 0 : { *(.debug) }\n\
1185 .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\
1186 .debug_aranges 0 : { *(.debug_aranges) }\n\
1187 .debug_pubnames 0 : { *(.debug_pubnames) }\n\
1188 .debug_sfnames 0 : { *(.debug_sfnames) }\n\
1189 .line 0 : { *(.line) }\n\
1190 /* These must appear regardless of . */\n\
1191 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\
1192 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\
1193 }\n\n";
1194 else if (link_info.shared)
1195 return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\
1196 \"elf32-littlemips\")\n\
1197 OUTPUT_ARCH(mips)\n\
1198 ENTRY(_start)\n\
1199 SEARCH_DIR(/usr/local/mips-elf/lib);\n\
1200 /* Do we need any of these for elf?\n\
1201 __DYNAMIC = 0; */\n\
1202 SECTIONS\n\
1203 {\n\
1204 /* Read-only sections, merged into text segment: */\n\
1205 . = 0x5ffe0000 + SIZEOF_HEADERS;\n\
1206 .reginfo : { *(.reginfo) }\n\
1207 .dynamic : { *(.dynamic) }\n\
1208 .dynstr : { *(.dynstr) }\n\
1209 .dynsym : { *(.dynsym) }\n\
1210 .hash : { *(.hash) }\n\
1211 .rel.text : { *(.rel.text) }\n\
1212 .rela.text : { *(.rela.text) }\n\
1213 .rel.data : { *(.rel.data) }\n\
1214 .rela.data : { *(.rela.data) }\n\
1215 .rel.rodata : { *(.rel.rodata) }\n\
1216 .rela.rodata : { *(.rela.rodata) }\n\
1217 .rel.got : { *(.rel.got) }\n\
1218 .rela.got : { *(.rela.got) }\n\
1219 .rel.ctors : { *(.rel.ctors) }\n\
1220 .rela.ctors : { *(.rela.ctors) }\n\
1221 .rel.dtors : { *(.rel.dtors) }\n\
1222 .rela.dtors : { *(.rela.dtors) }\n\
1223 .rel.init : { *(.rel.init) }\n\
1224 .rela.init : { *(.rela.init) }\n\
1225 .rel.fini : { *(.rel.fini) }\n\
1226 .rela.fini : { *(.rela.fini) }\n\
1227 .rel.bss : { *(.rel.bss) }\n\
1228 .rela.bss : { *(.rela.bss) }\n\
1229 .rel.plt : { *(.rel.plt) }\n\
1230 .rela.plt : { *(.rela.plt) }\n\
1231 .rodata : { *(.rodata) }\n\
1232 .rodata1 : { *(.rodata1) }\n\
1233 .init : { *(.init) } =0\n\
1234 .text :\n\
1235 {\n\
1236 *(.text)\n\
1237 *(.stub)\n\
1238 /* .gnu.warning sections are handled specially by elf32.em. */\n\
1239 *(.gnu.warning)\n\
1240 } =0\n\
1241 .fini : { *(.fini) } =0\n\
1242 /* Adjust the address for the data segment. We want to adjust up to\n\
1243 the same address within the page on the next page up. It would\n\
1244 be more correct to do this:\n\
1245 . = 0x10000000;\n\
1246 The current expression does not correctly handle the case of a\n\
1247 text segment ending precisely at the end of a page; it causes the\n\
1248 data segment to skip a page. The above expression does not have\n\
1249 this problem, but it will currently (2/95) cause BFD to allocate\n\
1250 a single segment, combining both text and data, for this case.\n\
1251 This will prevent the text segment from being shared among\n\
1252 multiple executions of the program; I think that is more\n\
1253 important than losing a page of the virtual address space (note\n\
1254 that no actual memory is lost; the page which is skipped can not\n\
1255 be referenced). */\n\
1256 . += 0x10000;\n\
1257 .data :\n\
1258 {\n\
1259 *(.data)\n\
1260 CONSTRUCTORS\n\
1261 }\n\
1262 .data1 : { *(.data1) }\n\
1263 .ctors : { *(.ctors) }\n\
1264 .dtors : { *(.dtors) }\n\
1265 _gp = ALIGN(16) + 0x7ff0;\n\
1266 .got :\n\
1267 {\n\
1268 *(.got.plt) *(.got)\n\
1269 }\n\
1270 /* We want the small data sections together, so single-instruction offsets\n\
1271 can access them all, and initialized data all before uninitialized, so\n\
1272 we can shorten the on-disk segment size. */\n\
1273 .sdata : { *(.sdata) }\n\
1274 .lit8 : { *(.lit8) }\n\
1275 .lit4 : { *(.lit4) }\n\
1276 .sbss : { *(.sbss) *(.scommon) }\n\
1277 .bss :\n\
1278 {\n\
1279 *(.dynbss)\n\
1280 *(.bss)\n\
1281 *(COMMON)\n\
1282 }\n\
1283 /* These are needed for ELF backends which have not yet been\n\
1284 converted to the new style linker. */\n\
1285 .stab 0 : { *(.stab) }\n\
1286 .stabstr 0 : { *(.stabstr) }\n\
1287 /* DWARF debug sections.\n\
1288 Symbols in the .debug DWARF section are relative to the beginning of the\n\
1289 section so we begin .debug at 0. It's not clear yet what needs to happen\n\
1290 for the others. */\n\
1291 .debug 0 : { *(.debug) }\n\
1292 .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\
1293 .debug_aranges 0 : { *(.debug_aranges) }\n\
1294 .debug_pubnames 0 : { *(.debug_pubnames) }\n\
1295 .debug_sfnames 0 : { *(.debug_sfnames) }\n\
1296 .line 0 : { *(.line) }\n\
1297 /* These must appear regardless of . */\n\
1298 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\
1299 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\
1300 }\n\n";
1301 else
1302 return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\
1303 \"elf32-littlemips\")\n\
1304 OUTPUT_ARCH(mips)\n\
1305 ENTRY(_start)\n\
1306 SEARCH_DIR(/usr/local/mips-elf/lib);\n\
1307 /* Do we need any of these for elf?\n\
1308 __DYNAMIC = 0; */\n\
1309 SECTIONS\n\
1310 {\n\
1311 /* Read-only sections, merged into text segment: */\n\
1312 . = 0x0400000;\n\
1313 .interp : { *(.interp) }\n\
1314 .reginfo : { *(.reginfo) }\n\
1315 .dynamic : { *(.dynamic) }\n\
1316 .dynstr : { *(.dynstr) }\n\
1317 .dynsym : { *(.dynsym) }\n\
1318 .hash : { *(.hash) }\n\
1319 .rel.text : { *(.rel.text) }\n\
1320 .rela.text : { *(.rela.text) }\n\
1321 .rel.data : { *(.rel.data) }\n\
1322 .rela.data : { *(.rela.data) }\n\
1323 .rel.rodata : { *(.rel.rodata) }\n\
1324 .rela.rodata : { *(.rela.rodata) }\n\
1325 .rel.got : { *(.rel.got) }\n\
1326 .rela.got : { *(.rela.got) }\n\
1327 .rel.ctors : { *(.rel.ctors) }\n\
1328 .rela.ctors : { *(.rela.ctors) }\n\
1329 .rel.dtors : { *(.rel.dtors) }\n\
1330 .rela.dtors : { *(.rela.dtors) }\n\
1331 .rel.init : { *(.rel.init) }\n\
1332 .rela.init : { *(.rela.init) }\n\
1333 .rel.fini : { *(.rel.fini) }\n\
1334 .rela.fini : { *(.rela.fini) }\n\
1335 .rel.bss : { *(.rel.bss) }\n\
1336 .rela.bss : { *(.rela.bss) }\n\
1337 .rel.plt : { *(.rel.plt) }\n\
1338 .rela.plt : { *(.rela.plt) }\n\
1339 .rodata : { *(.rodata) }\n\
1340 .rodata1 : { *(.rodata1) }\n\
1341 .init : { *(.init) } =0\n\
1342 .text :\n\
1343 {\n\
1344 _ftext = . ;\n\
1345 *(.text)\n\
1346 *(.stub)\n\
1347 /* .gnu.warning sections are handled specially by elf32.em. */\n\
1348 *(.gnu.warning)\n\
1349 } =0\n\
1350 _etext = .;\n\
1351 PROVIDE (etext = .);\n\
1352 .fini : { *(.fini) } =0\n\
1353 /* Adjust the address for the data segment. We want to adjust up to\n\
1354 the same address within the page on the next page up. It would\n\
1355 be more correct to do this:\n\
1356 . = 0x10000000;\n\
1357 The current expression does not correctly handle the case of a\n\
1358 text segment ending precisely at the end of a page; it causes the\n\
1359 data segment to skip a page. The above expression does not have\n\
1360 this problem, but it will currently (2/95) cause BFD to allocate\n\
1361 a single segment, combining both text and data, for this case.\n\
1362 This will prevent the text segment from being shared among\n\
1363 multiple executions of the program; I think that is more\n\
1364 important than losing a page of the virtual address space (note\n\
1365 that no actual memory is lost; the page which is skipped can not\n\
1366 be referenced). */\n\
1367 . += 0x10000000 - 0x0400000;\n\
1368 .data :\n\
1369 {\n\
1370 _fdata = . ;\n\
1371 *(.data)\n\
1372 CONSTRUCTORS\n\
1373 }\n\
1374 .data1 : { *(.data1) }\n\
1375 .ctors : { *(.ctors) }\n\
1376 .dtors : { *(.dtors) }\n\
1377 _gp = ALIGN(16) + 0x7ff0;\n\
1378 .got :\n\
1379 {\n\
1380 *(.got.plt) *(.got)\n\
1381 }\n\
1382 /* We want the small data sections together, so single-instruction offsets\n\
1383 can access them all, and initialized data all before uninitialized, so\n\
1384 we can shorten the on-disk segment size. */\n\
1385 .sdata : { *(.sdata) }\n\
1386 .lit8 : { *(.lit8) }\n\
1387 .lit4 : { *(.lit4) }\n\
1388 _edata = .;\n\
1389 PROVIDE (edata = .);\n\
1390 __bss_start = .;\n\
1391 _fbss = .;\n\
1392 .sbss : { *(.sbss) *(.scommon) }\n\
1393 .bss :\n\
1394 {\n\
1395 *(.dynbss)\n\
1396 *(.bss)\n\
1397 *(COMMON)\n\
1398 }\n\
1399 _end = . ;\n\
1400 PROVIDE (end = .);\n\
1401 /* These are needed for ELF backends which have not yet been\n\
1402 converted to the new style linker. */\n\
1403 .stab 0 : { *(.stab) }\n\
1404 .stabstr 0 : { *(.stabstr) }\n\
1405 /* DWARF debug sections.\n\
1406 Symbols in the .debug DWARF section are relative to the beginning of the\n\
1407 section so we begin .debug at 0. It's not clear yet what needs to happen\n\
1408 for the others. */\n\
1409 .debug 0 : { *(.debug) }\n\
1410 .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\
1411 .debug_aranges 0 : { *(.debug_aranges) }\n\
1412 .debug_pubnames 0 : { *(.debug_pubnames) }\n\
1413 .debug_sfnames 0 : { *(.debug_sfnames) }\n\
1414 .line 0 : { *(.line) }\n\
1415 /* These must appear regardless of . */\n\
1416 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\
1417 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\
1418 }\n\n";
1421 struct ld_emulation_xfer_struct ld_elf32ebmip_emulation =
1423 gldelf32ebmip_before_parse,
1424 syslib_default,
1425 hll_default,
1426 after_parse_default,
1427 gldelf32ebmip_after_open,
1428 after_allocation_default,
1429 set_output_arch_default,
1430 ldemul_default_target,
1431 gldelf32ebmip_before_allocation,
1432 gldelf32ebmip_get_script,
1433 "elf32ebmip",
1434 "elf32-bigmips",
1435 NULL,
1436 NULL,
1437 gldelf32ebmip_open_dynamic_archive,
1438 gldelf32ebmip_place_orphan