* elf-bfd.h (struct elf_size_info): Add swap_symbol_in field.
[platform/upstream/binutils.git] / bfd / elf32-i386qnx.c
1 /* Intel 80386/80486 QNX specific support for 32-bit ELF
2    Copyright 2002
3    Free Software Foundation, Inc.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
21 #define ELF32_I386_C_INCLUDED
22 #include "elf32-i386.c"
23
24   /* Returns the end address of the segment + 1.  */
25 #define SEGMENT_END(segment, start)                     \
26   (start + (segment->p_memsz > segment->p_filesz        \
27    ? segment->p_memsz : segment->p_filesz))
28
29 static boolean elf_i386qnx_copy_private_bfd_data_p
30   PARAMS ((bfd *, asection *, bfd *, asection *));
31 static boolean elf_i386qnx_is_contained_by_filepos
32   PARAMS ((asection *, Elf_Internal_Phdr *));
33 static void elf_i386qnx_set_nonloadable_filepos
34   PARAMS ((bfd *, Elf_Internal_Phdr *));
35
36 static boolean
37 elf_i386qnx_copy_private_bfd_data_p (ibfd, isec, obfd, osec)
38      bfd *ibfd;
39      asection *isec;
40      bfd *obfd;
41      asection *osec;
42 {
43   /* We don't use these parameters, but another target might.  */
44   ibfd = ibfd;
45   obfd = obfd;
46   osec = osec;
47   return isec->next == NULL;
48 }
49
50 static boolean
51 elf_i386qnx_is_contained_by_filepos (section, segment)
52      asection *section;
53      Elf_Internal_Phdr *segment;
54 {
55   return ((bfd_vma) section->filepos >= segment->p_offset
56           && ((bfd_vma) section->filepos + section->_raw_size
57               <= SEGMENT_END (segment, segment->p_offset)));
58 }
59
60 static void
61 elf_i386qnx_set_nonloadable_filepos (abfd, phdrs)
62      bfd *abfd;
63      Elf_Internal_Phdr *phdrs;
64 {
65   struct elf_segment_map *m;
66   Elf_Internal_Phdr *p;
67   file_ptr off = 0;
68
69   for (m = elf_tdata (abfd)->segment_map, p = phdrs;
70        m != NULL;
71        m = m->next, p++)
72     {
73       unsigned int i;
74       asection **secpp;
75
76       for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
77         {
78           asection *sec;
79
80           sec = *secpp;
81
82           if (p->p_type == PT_LOAD)
83             off = sec->filepos;
84           else
85             {
86               if (i == 0)
87                 {
88                   if (sec->filepos)
89                     p->p_offset = sec->filepos;
90                   else
91                     p->p_offset = off;
92                 }
93               if (!sec->filepos)
94                 {
95                   off += sec->_raw_size;
96                   p->p_filesz += sec->_raw_size;
97                 }
98             }
99         }
100     }
101   return;
102 }
103
104 #undef  TARGET_LITTLE_SYM
105 #define TARGET_LITTLE_SYM                   bfd_elf32_i386qnx_vec
106
107 #define elf_backend_set_nonloadable_filepos elf_i386qnx_set_nonloadable_filepos
108 #define elf_backend_is_contained_by_filepos elf_i386qnx_is_contained_by_filepos
109 #define elf_backend_copy_private_bfd_data_p elf_i386qnx_copy_private_bfd_data_p
110
111 #include "elf32-target.h"