gas/testsuite/
[deliverable/binutils-gdb.git] / ld / emultempl / elf-generic.em
CommitLineData
8ded5a0f 1# This shell script emits a C file. -*- C -*-
aa820537 2# Copyright 2006, 2007, 2008, 2009 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
f96b4a7b
NC
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
8ded5a0f
AM
20#
21
22# This file is sourced from elf32.em and from ELF targets that use
23# generic.em.
24#
92b93329 25fragment <<EOF
8ded5a0f
AM
26
27static void
28gld${EMULATION_NAME}_map_segments (bfd_boolean need_layout)
29{
f5ff60a6
AM
30 int tries = 10;
31
00bb149b 32 do
8ded5a0f 33 {
eaeb0a9d
AM
34 lang_relax_sections (need_layout);
35 need_layout = FALSE;
00bb149b 36
f13a99db 37 if (link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour
00bb149b 38 && !link_info.relocatable)
8ded5a0f
AM
39 {
40 bfd_size_type phdr_size;
41
f13a99db 42 phdr_size = elf_tdata (link_info.output_bfd)->program_header_size;
f5ff60a6
AM
43 /* If we don't have user supplied phdrs, throw away any
44 previous linker generated program headers. */
45 if (lang_phdr_list == NULL)
f13a99db
AM
46 elf_tdata (link_info.output_bfd)->segment_map = NULL;
47 if (!_bfd_elf_map_sections_to_segments (link_info.output_bfd,
48 &link_info))
8ded5a0f
AM
49 einfo ("%F%P: map sections to segments failed: %E\n");
50
f13a99db
AM
51 if (phdr_size
52 != elf_tdata (link_info.output_bfd)->program_header_size)
59e0647f
NS
53 {
54 if (tries > 6)
55 /* The first few times we allow any change to
56 phdr_size . */
57 need_layout = TRUE;
f13a99db
AM
58 else if (phdr_size
59 < elf_tdata (link_info.output_bfd)->program_header_size)
59e0647f
NS
60 /* After that we only allow the size to grow. */
61 need_layout = TRUE;
62 else
f13a99db
AM
63 elf_tdata (link_info.output_bfd)->program_header_size
64 = phdr_size;
59e0647f 65 }
8ded5a0f 66 }
8ded5a0f 67 }
00bb149b 68 while (need_layout && --tries);
f5ff60a6
AM
69
70 if (tries == 0)
71 einfo (_("%P%F: looping in map_segments"));
8ded5a0f
AM
72}
73EOF
This page took 0.253543 seconds and 4 git commands to generate.