133965Sjdp/* Generic support for 32-bit ELF
2218822Sdim   Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004, 2005, 2007
3130561Sobrien   Free Software Foundation, Inc.
433965Sjdp
5218822Sdim   This file is part of BFD, the Binary File Descriptor library.
633965Sjdp
7218822Sdim   This program is free software; you can redistribute it and/or modify
8218822Sdim   it under the terms of the GNU General Public License as published by
9218822Sdim   the Free Software Foundation; either version 2 of the License, or
10218822Sdim   (at your option) any later version.
1133965Sjdp
12218822Sdim   This program is distributed in the hope that it will be useful,
13218822Sdim   but WITHOUT ANY WARRANTY; without even the implied warranty of
14218822Sdim   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15218822Sdim   GNU General Public License for more details.
1633965Sjdp
17218822Sdim   You should have received a copy of the GNU General Public License
18218822Sdim   along with this program; if not, write to the Free Software
19218822Sdim   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
2033965Sjdp
21218822Sdim#include "sysdep.h"
2233965Sjdp#include "bfd.h"
2333965Sjdp#include "libbfd.h"
2433965Sjdp#include "elf-bfd.h"
2533965Sjdp
2660484Sobrien/* This does not include any relocation information, but should be
2760484Sobrien   good enough for GDB or objdump to read the file.  */
2833965Sjdp
2960484Sobrienstatic reloc_howto_type dummy =
3060484Sobrien  HOWTO (0,			/* type */
3160484Sobrien	 0,			/* rightshift */
3260484Sobrien	 0,			/* size (0 = byte, 1 = short, 2 = long) */
3360484Sobrien	 0,			/* bitsize */
34130561Sobrien	 FALSE,			/* pc_relative */
3560484Sobrien	 0,			/* bitpos */
3660484Sobrien	 complain_overflow_dont, /* complain_on_overflow */
3760484Sobrien	 NULL,			/* special_function */
3860484Sobrien	 "UNKNOWN",		/* name */
39130561Sobrien	 FALSE,			/* partial_inplace */
4060484Sobrien	 0,			/* src_mask */
4160484Sobrien	 0,			/* dst_mask */
42130561Sobrien	 FALSE);		/* pcrel_offset */
4360484Sobrien
4460484Sobrienstatic void
45218822Sdimelf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
46218822Sdim			   arelent *bfd_reloc,
47218822Sdim			   Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
4860484Sobrien{
4960484Sobrien  bfd_reloc->howto = &dummy;
5060484Sobrien}
5160484Sobrien
5260484Sobrienstatic void
53218822Sdimelf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
54218822Sdim			       arelent *bfd_reloc,
55218822Sdim			       Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
5660484Sobrien{
5760484Sobrien  bfd_reloc->howto = &dummy;
5860484Sobrien}
5960484Sobrien
60218822Sdimstatic void
61218822Sdimcheck_for_relocs (bfd * abfd, asection * o, void * failed)
62218822Sdim{
63218822Sdim  if ((o->flags & SEC_RELOC) != 0)
64218822Sdim    {
65218822Sdim      Elf_Internal_Ehdr *ehdrp;
66218822Sdim
67218822Sdim      ehdrp = elf_elfheader (abfd);
68218822Sdim      _bfd_error_handler (_("%B: Relocations in generic ELF (EM: %d)"),
69218822Sdim			  abfd, ehdrp->e_machine);
70218822Sdim
71218822Sdim      bfd_set_error (bfd_error_wrong_format);
72218822Sdim      * (bfd_boolean *) failed = TRUE;
73218822Sdim    }
74218822Sdim}
75218822Sdim
76130561Sobrienstatic bfd_boolean
77218822Sdimelf32_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
7877298Sobrien{
79218822Sdim  bfd_boolean failed = FALSE;
8077298Sobrien
8177298Sobrien  /* Check if there are any relocations.  */
82218822Sdim  bfd_map_over_sections (abfd, check_for_relocs, & failed);
8377298Sobrien
84218822Sdim  if (failed)
85218822Sdim    return FALSE;
86130561Sobrien  return bfd_elf_link_add_symbols (abfd, info);
8777298Sobrien}
8877298Sobrien
8933965Sjdp#define TARGET_LITTLE_SYM		bfd_elf32_little_generic_vec
9033965Sjdp#define TARGET_LITTLE_NAME		"elf32-little"
9133965Sjdp#define TARGET_BIG_SYM			bfd_elf32_big_generic_vec
9233965Sjdp#define TARGET_BIG_NAME			"elf32-big"
9333965Sjdp#define ELF_ARCH			bfd_arch_unknown
9433965Sjdp#define ELF_MACHINE_CODE		EM_NONE
9560484Sobrien#define ELF_MAXPAGESIZE			0x1
9633965Sjdp#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
97218822Sdim#define bfd_elf32_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
9877298Sobrien#define bfd_elf32_bfd_link_add_symbols	elf32_generic_link_add_symbols
9960484Sobrien#define elf_info_to_howto		elf_generic_info_to_howto
10060484Sobrien#define elf_info_to_howto_rel		elf_generic_info_to_howto_rel
10133965Sjdp
10233965Sjdp#include "elf32-target.h"
103