Commit | Line | Data |
---|---|---|
8ded5a0f | 1 | # This shell script emits a C file. -*- C -*- |
82704155 | 2 | # Copyright (C) 2006-2019 Free Software Foundation, Inc. |
8ded5a0f | 3 | # |
f96b4a7b | 4 | # This file is part of the GNU Binutils. |
8ded5a0f AM |
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 | |
f96b4a7b | 8 | # the Free Software Foundation; either version 3 of the License, or |
8ded5a0f AM |
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 | |
f96b4a7b NC |
18 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
19 | # MA 02110-1301, USA. | |
8ded5a0f AM |
20 | # |
21 | ||
22 | # This file is sourced from generic.em | |
23 | # | |
92b93329 | 24 | fragment <<EOF |
8ded5a0f | 25 | #include "elf-bfd.h" |
d871d478 | 26 | #include "ldelfgen.h" |
8ded5a0f AM |
27 | |
28 | EOF | |
92b93329 RM |
29 | source_em ${srcdir}/emultempl/elf-generic.em |
30 | fragment <<EOF | |
8ded5a0f | 31 | |
bcacc0f5 AM |
32 | static void |
33 | gld${EMULATION_NAME}_after_open (void) | |
34 | { | |
35 | bfd *ibfd; | |
36 | asection *sec; | |
37 | asymbol **syms; | |
38 | ||
5c3049d2 AM |
39 | after_open_default (); |
40 | ||
0e1862bb | 41 | if (bfd_link_relocatable (&link_info)) |
c72f2fb2 | 42 | for (ibfd = link_info.input_bfds; ibfd != NULL; ibfd = ibfd->link.next) |
bcacc0f5 AM |
43 | if ((syms = bfd_get_outsymbols (ibfd)) != NULL |
44 | && bfd_get_flavour (ibfd) == bfd_target_elf_flavour) | |
45 | for (sec = ibfd->sections; sec != NULL; sec = sec->next) | |
46 | if ((sec->flags & (SEC_GROUP | SEC_LINKER_CREATED)) == SEC_GROUP) | |
47 | { | |
48 | struct bfd_elf_section_data *sec_data = elf_section_data (sec); | |
3d7d6a6f AM |
49 | struct bfd_symbol *sym = syms[sec_data->this_hdr.sh_info - 1]; |
50 | elf_group_id (sec) = sym; | |
51 | sym->flags |= BSF_KEEP; | |
bcacc0f5 AM |
52 | } |
53 | } | |
eaeb0a9d | 54 | |
d0bf826b AM |
55 | static void |
56 | gld${EMULATION_NAME}_before_allocation (void) | |
57 | { | |
0e1862bb | 58 | if (bfd_link_relocatable (&link_info) |
d0bf826b | 59 | && !_bfd_elf_size_group_sections (&link_info)) |
d003af55 | 60 | einfo (_("%X%P: can not size group sections: %E\n")); |
d0bf826b AM |
61 | before_allocation_default (); |
62 | } | |
63 | ||
eaeb0a9d AM |
64 | static void |
65 | gld${EMULATION_NAME}_after_allocation (void) | |
66 | { | |
d871d478 | 67 | ldelf_map_segments (FALSE); |
eaeb0a9d | 68 | } |
8ded5a0f AM |
69 | EOF |
70 | # Put these extra routines in ld_${EMULATION_NAME}_emulation | |
71 | # | |
bcacc0f5 | 72 | LDEMUL_AFTER_OPEN=gld${EMULATION_NAME}_after_open |
d0bf826b | 73 | LDEMUL_BEFORE_ALLOCATION=gld${EMULATION_NAME}_before_allocation |
eaeb0a9d | 74 | LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation |