Commit | Line | Data |
---|---|---|
1f808cd5 AM |
1 | # This shell script emits a C file. -*- C -*- |
2 | # Copyright 2002 Free Software Foundation, Inc. | |
3 | # | |
4 | # This file is part of GLD, the Gnu Linker. | |
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
19 | # | |
20 | ||
21 | # This file is sourced from elf32.em, and defines extra powerpc64-elf | |
22 | # specific routines. | |
23 | # | |
24 | cat >>e${EMULATION_NAME}.c <<EOF | |
25 | ||
26 | #include "elf64-ppc.h" | |
27 | ||
28 | static int need_laying_out = 0; | |
29 | ||
30 | static void gld${EMULATION_NAME}_after_allocation PARAMS ((void)); | |
31 | static void gld${EMULATION_NAME}_finish PARAMS ((void)); | |
32 | ||
33 | /* Call the back-end function to set TOC base after we have placed all | |
34 | the sections. */ | |
35 | static void | |
36 | gld${EMULATION_NAME}_after_allocation () | |
37 | { | |
38 | if (!ppc64_elf_set_toc (output_bfd, &link_info)) | |
39 | einfo ("%X%P: can not set TOC base: %E\n"); | |
40 | } | |
41 | ||
42 | /* Final emulation specific call. PowerPC64 has 24 byte .plt entries, | |
43 | and needs different call stubs for any entries that cross a 64k | |
44 | boundary relative to the TOC. That means we need to wait until all | |
45 | sections have been laid out to initialise the stubs. */ | |
46 | ||
47 | static void | |
48 | gld${EMULATION_NAME}_finish () | |
49 | { | |
50 | /* If generating a relocatable output file, then we don't have any | |
51 | stubs. */ | |
52 | if (link_info.relocateable) | |
53 | return; | |
54 | ||
55 | /* bfd_elf64_discard_info just plays with debugging sections, | |
56 | ie. doesn't affect any code, so we can delay resizing the | |
57 | sections. It's likely we'll resize everything in the process of | |
58 | adjusting stub sizes. */ | |
59 | if (bfd_elf${ELFSIZE}_discard_info (output_bfd, &link_info)) | |
60 | need_laying_out = 1; | |
61 | ||
62 | while (1) | |
63 | { | |
64 | /* Call into the BFD backend to do the real work. */ | |
65 | if (! ppc64_elf_size_stubs (output_bfd, &link_info, &need_laying_out)) | |
66 | { | |
67 | einfo ("%X%P: can not size stub section: %E\n"); | |
68 | return; | |
69 | } | |
70 | ||
71 | if (!need_laying_out) | |
72 | break; | |
73 | ||
74 | /* If we have changed the size of the stub section, then we need | |
75 | to recalculate all the section offsets. After this, we may | |
76 | need to adjust the stub size again. */ | |
77 | need_laying_out = 0; | |
78 | ||
79 | /* Resize the sections. */ | |
80 | lang_size_sections (stat_ptr->head, abs_output_section, | |
81 | &stat_ptr->head, 0, (bfd_vma) 0, NULL); | |
82 | ||
83 | /* Recalculate TOC base. */ | |
84 | ldemul_after_allocation (); | |
85 | ||
86 | /* Do the assignments again. */ | |
87 | lang_do_assignments (stat_ptr->head, abs_output_section, | |
88 | (fill_type) 0, (bfd_vma) 0); | |
89 | } | |
90 | ||
91 | if (! ppc64_elf_build_stubs (output_bfd, &link_info)) | |
92 | einfo ("%X%P: can not build stubs: %E\n"); | |
93 | } | |
94 | EOF | |
95 | ||
96 | # Put these extra ppc64elf routines in ld_${EMULATION_NAME}_emulation | |
97 | # | |
98 | LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation | |
99 | LDEMUL_FINISH=gld${EMULATION_NAME}_finish |