Commit | Line | Data |
---|---|---|
59bc061d NC |
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 | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | /* Returns the end address of the segment + 1. */ | |
21 | #define SEGMENT_END(segment, start) \ | |
22 | (start + (segment->p_memsz > segment->p_filesz \ | |
23 | ? segment->p_memsz : segment->p_filesz)) | |
24 | ||
ed71e111 | 25 | static boolean elf_qnx_copy_private_bfd_data_p |
59bc061d | 26 | PARAMS ((bfd *, asection *, bfd *, asection *)); |
ed71e111 | 27 | static boolean elf_qnx_is_contained_by_filepos |
59bc061d | 28 | PARAMS ((asection *, Elf_Internal_Phdr *)); |
ed71e111 | 29 | static void elf_qnx_set_nonloadable_filepos |
59bc061d NC |
30 | PARAMS ((bfd *, Elf_Internal_Phdr *)); |
31 | ||
32 | static boolean | |
33 | elf_qnx_copy_private_bfd_data_p (ibfd, isec, obfd, osec) | |
34 | bfd *ibfd; | |
35 | asection *isec; | |
36 | bfd *obfd; | |
37 | asection *osec; | |
38 | { | |
39 | /* We don't use these parameters, but another target might. */ | |
40 | ibfd = ibfd; | |
41 | obfd = obfd; | |
42 | osec = osec; | |
43 | ||
44 | return isec->next == NULL; | |
45 | } | |
46 | ||
47 | static boolean | |
48 | elf_qnx_is_contained_by_filepos (section, segment) | |
49 | asection *section; | |
50 | Elf_Internal_Phdr *segment; | |
51 | { | |
52 | return ((bfd_vma) section->filepos >= segment->p_offset | |
53 | && ((bfd_vma) section->filepos + section->_raw_size | |
54 | <= SEGMENT_END (segment, segment->p_offset))); | |
55 | } | |
56 | ||
57 | static void | |
58 | elf_qnx_set_nonloadable_filepos (abfd, phdrs) | |
59 | bfd *abfd; | |
60 | Elf_Internal_Phdr *phdrs; | |
61 | { | |
62 | struct elf_segment_map *m; | |
63 | Elf_Internal_Phdr *p; | |
64 | file_ptr off = 0; | |
65 | ||
66 | for (m = elf_tdata (abfd)->segment_map, p = phdrs; | |
67 | m != NULL; | |
68 | m = m->next, p++) | |
69 | { | |
70 | unsigned int i; | |
71 | asection **secpp; | |
72 | ||
73 | for (i = 0, secpp = m->sections; i < m->count; i++, secpp++) | |
74 | { | |
75 | asection *sec; | |
76 | ||
77 | sec = *secpp; | |
78 | ||
79 | if (p->p_type == PT_LOAD) | |
80 | off = sec->filepos; | |
81 | else | |
82 | { | |
83 | if (i == 0) | |
84 | { | |
85 | if (sec->filepos) | |
86 | p->p_offset = sec->filepos; | |
87 | else | |
88 | p->p_offset = off; | |
89 | } | |
90 | if (!sec->filepos) | |
91 | { | |
92 | off += sec->_raw_size; | |
93 | p->p_filesz += sec->_raw_size; | |
94 | } | |
95 | } | |
96 | } | |
97 | } | |
98 | return; | |
99 | } | |
100 | ||
101 | #ifndef elf_backend_set_nonloadable_filepos | |
102 | #define elf_backend_set_nonloadable_filepos elf_qnx_set_nonloadable_filepos | |
103 | #endif | |
104 | ||
105 | #ifndef elf_backend_is_contained_by_filepos | |
106 | #define elf_backend_is_contained_by_filepos elf_qnx_is_contained_by_filepos | |
107 | #endif | |
108 | ||
109 | #ifndef elf_backend_copy_private_bfd_data_p | |
110 | #define elf_backend_copy_private_bfd_data_p elf_qnx_copy_private_bfd_data_p | |
111 | #endif |