Merge branch 'vendor/FILE'
[dragonfly.git] / contrib / binutils-2.24 / bfd / elf64-gen.c
1 /* Generic support for 64-bit ELF
2    Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004, 2005, 2007
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
20    MA 02110-1301, USA.  */
21
22 #include "sysdep.h"
23 #include "bfd.h"
24 #include "libbfd.h"
25 #include "elf-bfd.h"
26
27 /* This does not include any relocation information, but should be
28    good enough for GDB or objdump to read the file.  */
29
30 static reloc_howto_type dummy =
31   HOWTO (0,                     /* type */
32          0,                     /* rightshift */
33          0,                     /* size (0 = byte, 1 = short, 2 = long) */
34          0,                     /* bitsize */
35          FALSE,                 /* pc_relative */
36          0,                     /* bitpos */
37          complain_overflow_dont, /* complain_on_overflow */
38          NULL,                  /* special_function */
39          "UNKNOWN",             /* name */
40          FALSE,                 /* partial_inplace */
41          0,                     /* src_mask */
42          0,                     /* dst_mask */
43          FALSE);                /* pcrel_offset */
44
45 static void
46 elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
47                            arelent *bfd_reloc,
48                            Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
49 {
50   bfd_reloc->howto = &dummy;
51 }
52
53 static void
54 elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
55                                arelent *bfd_reloc,
56                                Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
57 {
58   bfd_reloc->howto = &dummy;
59 }
60
61 static void
62 check_for_relocs (bfd * abfd, asection * o, void * failed)
63 {
64   if ((o->flags & SEC_RELOC) != 0)
65     {
66       Elf_Internal_Ehdr *ehdrp;
67
68       ehdrp = elf_elfheader (abfd);
69       _bfd_error_handler (_("%B: Relocations in generic ELF (EM: %d)"),
70                           abfd, ehdrp->e_machine);
71
72       bfd_set_error (bfd_error_wrong_format);
73       * (bfd_boolean *) failed = TRUE;
74     }
75 }
76
77 static bfd_boolean
78 elf64_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
79 {
80   bfd_boolean failed = FALSE;
81
82   /* Check if there are any relocations.  */
83   bfd_map_over_sections (abfd, check_for_relocs, & failed);
84
85   if (failed)
86     return FALSE;
87   return bfd_elf_link_add_symbols (abfd, info);
88 }
89
90 #define TARGET_LITTLE_SYM               bfd_elf64_little_generic_vec
91 #define TARGET_LITTLE_NAME              "elf64-little"
92 #define TARGET_BIG_SYM                  bfd_elf64_big_generic_vec
93 #define TARGET_BIG_NAME                 "elf64-big"
94 #define ELF_ARCH                        bfd_arch_unknown
95 #define ELF_MACHINE_CODE                EM_NONE
96 #define ELF_MAXPAGESIZE                 0x1
97 #define bfd_elf64_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
98 #define bfd_elf64_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
99 #define bfd_elf64_bfd_link_add_symbols  elf64_generic_link_add_symbols
100 #define elf_info_to_howto               elf_generic_info_to_howto
101 #define elf_info_to_howto_rel           elf_generic_info_to_howto_rel
102
103 #include "elf64-target.h"