binutils-gdb/bfd/elf32-qnx.c
Alan Modra 2bc3c89ab3 * Makefile.am (BFD32_BACKENDS): Remove elfarmqnx-nabi.lo,
elf32-i386-fbsd.lo, elf32-i386qnx.lo, elf32-ppcqnx.lo,
	elf32-sh-lin.lo, elf32-sh64-lin.lo, elf32-sh-nbsd.lo,
	elf32-sh64-nbsd.lo, elf32-shqnx.lo.  Add elf32-qnx.lo.
	(BFD32_BACKENDS_CFILES): Likewise for corresponding C files.
	(BFD64_BACKENDS): Remove elf64-sh64-lin.lo, elf64-sh64-nbsd.lo.
	(BFD64_BACKENDS_CFILES): Likewise for corresponding C files.
	(SOURCE_HFILES): Add elf32-qnx.h.
	(BUILD_HFILES): Add bfdver.h.
	Run "make dep-am".
	* Makefile.in: Regenerate.
	* configure.in Update bfd vector dependencies.
	* configure: Regenerate.
	* elf32-i386-fbsd.c: Delete.  Move code to elf32-i386.c.
	* elf32-i386qnx.c: Likewise.
	* elf32-ppcqnx.c: Delete.  Move code to elf32-ppc.c.
	* elf32-sh-nbsd.c: Delete.  Move code to elf32-sh.c.
	* elf32-sh-lin.c: Likewise.
	* elf32-shqnx.c: Likewise.
	* elf32-sh64-lin.c: Delete.  Move code to elf32-sh64.c.
	* elf32-sh64-nbsd.c: Likewise.
	* elf64-sh64-lin.c: Delete.  Move code to elf64-sh64.c.
	* elf64-sh64-nbsd.c: Likewise.
	* elfarmqnx-nabi.c: Delete.  Move code to elfarm-nabi.c.
	* elf32-arm.h (ELF_MAXPAGESIZE): Always define.
	* elf32-i386.c: Remove ELF_ARCH and ELF32_I386_C_INCLUDED tests.
	* elf32-ppc.c: Remove ELF32_PPC_C_INCLUDED tests.
	* elf32-qnx.h (elf_backend_set_nonloadable_filepos): Always define.
	(elf_backend_is_contained_by_filepos): Likewise.
	(elf_backend_copy_private_bfd_data_p): Likewise.
	Globalize and move functions to..
	* elf32-qnx.c: ..here.  New file.
	* elf32-sh.c: Remove ELF_ARCH and ELF32_SH_C_INCLUDED tests.  Don't
	emit target vectors when INCLUDE_SHMEDIA.
	* elf32-sh64.c: Remove ELF_ARCH test.  Move TARGET_* etc. defines to
	end of file.
	* elf64-sh64.c: Remove ELF_ARCH test.
	* elfarm-nabi.c: Remove ELFARM_NABI_C_INCLUDED test.
	* po/BLD-POTFILES.in: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
2002-10-16 08:39:38 +00:00

93 lines
2.6 KiB
C

/* 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. */
#include "bfd.h"
#include "sysdep.h"
#include "elf-bfd.h"
#include "elf32-qnx.h"
/* 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))
boolean
elf_qnx_copy_private_bfd_data_p (ibfd, isec, obfd, osec)
bfd *ibfd ATTRIBUTE_UNUSED;
asection *isec;
bfd *obfd ATTRIBUTE_UNUSED;
asection *osec ATTRIBUTE_UNUSED;
{
return isec->next == NULL;
}
boolean
elf_qnx_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)));
}
void
elf_qnx_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;
}