merge from gcc
[deliverable/binutils-gdb.git] / bfd / elf32-qnx.c
1 /* QNX specific support for 32-bit ELF
2 Copyright 2002 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
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 Foundation,
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20 #include "bfd.h"
21 #include "sysdep.h"
22 #include "elf-bfd.h"
23 #include "elf32-qnx.h"
24
25 /* Returns the end address of the segment + 1. */
26 #define SEGMENT_END(segment, start) \
27 (start + (segment->p_memsz > segment->p_filesz \
28 ? segment->p_memsz : segment->p_filesz))
29
30 boolean
31 elf_qnx_copy_private_bfd_data_p (ibfd, isec, obfd, osec)
32 bfd *ibfd ATTRIBUTE_UNUSED;
33 asection *isec;
34 bfd *obfd ATTRIBUTE_UNUSED;
35 asection *osec ATTRIBUTE_UNUSED;
36 {
37 return isec->next == NULL;
38 }
39
40 boolean
41 elf_qnx_is_contained_by_filepos (section, segment)
42 asection *section;
43 Elf_Internal_Phdr *segment;
44 {
45 return ((bfd_vma) section->filepos >= segment->p_offset
46 && ((bfd_vma) section->filepos + section->_raw_size
47 <= SEGMENT_END (segment, segment->p_offset)));
48 }
49
50 void
51 elf_qnx_set_nonloadable_filepos (abfd, phdrs)
52 bfd *abfd;
53 Elf_Internal_Phdr *phdrs;
54 {
55 struct elf_segment_map *m;
56 Elf_Internal_Phdr *p;
57 file_ptr off = 0;
58
59 for (m = elf_tdata (abfd)->segment_map, p = phdrs;
60 m != NULL;
61 m = m->next, p++)
62 {
63 unsigned int i;
64 asection **secpp;
65
66 for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
67 {
68 asection *sec;
69
70 sec = *secpp;
71
72 if (p->p_type == PT_LOAD)
73 off = sec->filepos;
74 else
75 {
76 if (i == 0)
77 {
78 if (sec->filepos)
79 p->p_offset = sec->filepos;
80 else
81 p->p_offset = off;
82 }
83 if (!sec->filepos)
84 {
85 off += sec->_raw_size;
86 p->p_filesz += sec->_raw_size;
87 }
88 }
89 }
90 }
91 return;
92 }
This page took 0.03003 seconds and 4 git commands to generate.