binutils-gdb/bfd/elf32-i386qnx.c
Alan Modra caf47ea6a3 * Makefile.am (BFD32_BACKENDS): Add elf32-i386qnx.lo.
(BFD32_BACKENDS_CFILES): Add elf32-i386qnx.c.
	Run "make dep-am".
	* Makefile.in: Regenerate.
	* config.bfd: Add i[3456]86-*-nto-qnx* support.
	* configure.in: Add bfd_elf32_i386qnx_vec support.
	* configure: Regenerate.
	* elf-bfd.h (struct elf_backend_data): Add set_nonloadable_filepos,
	is_contained_by_filepos, and copy_private_bfd_data_p.
	* elf.c (assign_file_positions_for_segments): Call backend
	set_nonloadable_filepos.  Fix non-K&R call to _bfd_error_handler.
	(IS_CONTAINED_BY_FILEPOS): Define.
	(INCLUDE_SECTION_IN_SEGMENT): Also test IS_CONTAINED_BY_FILEPOS.
	(copy_private_bfd_data): Use IS_CONTAINED_BY_FILEPOS.  Typo fix.
	Fix non-K&R call to _bfd_error_handler.
	(_bfd_elf_copy_private_section_data): Use backend
	copy_private_bfd_data_p.
	* elf32-i386.c: Don't include elfxx-target.h when
	ELF32_I386_C_INCLUDED is defined.
	* elf32-i386qnx.c: New QNX elf backend file.
	* elfxx-target.h: Add elf_backend_set_nonloadable_filepos,
	elf_backend_is_contained_by_filepos, and
	elf_backend_do_copy_private_bfd_data.
	* targets.c: Add bfd_target bfd_elf32_i386qnx_vec.
2002-05-31 02:59:47 +00:00

112 lines
3.2 KiB
C

/* Intel 80386/80486 QNX specific support for 32-bit ELF
Copyright 2002
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define ELF32_I386_C_INCLUDED
#include "elf32-i386.c"
/* Returns the end address of the segment + 1. */
#define SEGMENT_END(segment, start) \
(start + (segment->p_memsz > segment->p_filesz \
? segment->p_memsz : segment->p_filesz))
static boolean elf_i386qnx_copy_private_bfd_data_p
PARAMS ((bfd *, asection *, bfd *, asection *));
static boolean elf_i386qnx_is_contained_by_filepos
PARAMS ((asection *, Elf_Internal_Phdr *));
static void elf_i386qnx_set_nonloadable_filepos
PARAMS ((bfd *, Elf_Internal_Phdr *));
static boolean
elf_i386qnx_copy_private_bfd_data_p (ibfd, isec, obfd, osec)
bfd *ibfd;
asection *isec;
bfd *obfd;
asection *osec;
{
/* We don't use these parameters, but another target might. */
ibfd = ibfd;
obfd = obfd;
osec = osec;
return isec->next == NULL;
}
static boolean
elf_i386qnx_is_contained_by_filepos (section, segment)
asection *section;
Elf_Internal_Phdr *segment;
{
return ((bfd_vma) section->filepos >= segment->p_offset
&& ((bfd_vma) section->filepos + section->_raw_size
<= SEGMENT_END (segment, segment->p_offset)));
}
static void
elf_i386qnx_set_nonloadable_filepos (abfd, phdrs)
bfd *abfd;
Elf_Internal_Phdr *phdrs;
{
struct elf_segment_map *m;
Elf_Internal_Phdr *p;
file_ptr off = 0;
for (m = elf_tdata (abfd)->segment_map, p = phdrs;
m != NULL;
m = m->next, p++)
{
unsigned int i;
asection **secpp;
for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
{
asection *sec;
sec = *secpp;
if (p->p_type == PT_LOAD)
off = sec->filepos;
else
{
if (i == 0)
{
if (sec->filepos)
p->p_offset = sec->filepos;
else
p->p_offset = off;
}
if (!sec->filepos)
{
off += sec->_raw_size;
p->p_filesz += sec->_raw_size;
}
}
}
}
return;
}
#undef TARGET_LITTLE_SYM
#define TARGET_LITTLE_SYM bfd_elf32_i386qnx_vec
#define elf_backend_set_nonloadable_filepos elf_i386qnx_set_nonloadable_filepos
#define elf_backend_is_contained_by_filepos elf_i386qnx_is_contained_by_filepos
#define elf_backend_copy_private_bfd_data_p elf_i386qnx_copy_private_bfd_data_p
#include "elf32-target.h"