]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/elf32-gen.c
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / bfd / elf32-gen.c
CommitLineData
252b5132 1/* Generic support for 32-bit ELF
fd67aa11 2 Copyright (C) 1993-2024 Free Software Foundation, Inc.
252b5132 3
c8e7bf0d 4 This file is part of BFD, the Binary File Descriptor library.
252b5132 5
c8e7bf0d
NC
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
cd123cb7 8 the Free Software Foundation; either version 3 of the License, or
c8e7bf0d 9 (at your option) any later version.
252b5132 10
c8e7bf0d
NC
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
252b5132 15
c8e7bf0d
NC
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
cd123cb7
NC
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
252b5132 20
252b5132 21#include "sysdep.h"
3db64b00 22#include "bfd.h"
252b5132
RH
23#include "libbfd.h"
24#include "elf-bfd.h"
25
26/* This does not include any relocation information, but should be
27 good enough for GDB or objdump to read the file. */
28
29static reloc_howto_type dummy =
30 HOWTO (0, /* type */
31 0, /* rightshift */
c94cb026 32 0, /* size */
252b5132 33 0, /* bitsize */
0a1b45a2 34 false, /* pc_relative */
252b5132
RH
35 0, /* bitpos */
36 complain_overflow_dont, /* complain_on_overflow */
37 NULL, /* special_function */
38 "UNKNOWN", /* name */
0a1b45a2 39 false, /* partial_inplace */
252b5132
RH
40 0, /* src_mask */
41 0, /* dst_mask */
0a1b45a2 42 false); /* pcrel_offset */
252b5132 43
0a1b45a2 44static bool
c8e7bf0d
NC
45elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
46 arelent *bfd_reloc,
47 Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
252b5132
RH
48{
49 bfd_reloc->howto = &dummy;
0a1b45a2 50 return true;
252b5132
RH
51}
52
0a1b45a2 53static bool
c8e7bf0d
NC
54elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
55 arelent *bfd_reloc,
56 Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
252b5132
RH
57{
58 bfd_reloc->howto = &dummy;
0a1b45a2 59 return true;
252b5132
RH
60}
61
c8e7bf0d
NC
62static void
63check_for_relocs (bfd * abfd, asection * o, void * failed)
eb4a6e4f 64{
c8e7bf0d
NC
65 if ((o->flags & SEC_RELOC) != 0)
66 {
67 Elf_Internal_Ehdr *ehdrp;
eb4a6e4f 68
c8e7bf0d 69 ehdrp = elf_elfheader (abfd);
695344c0 70 /* xgettext:c-format */
9793eb77 71 _bfd_error_handler (_("%pB: relocations in generic ELF (EM: %d)"),
c8e7bf0d 72 abfd, ehdrp->e_machine);
eb4a6e4f 73
c8e7bf0d 74 bfd_set_error (bfd_error_wrong_format);
0a1b45a2 75 * (bool *) failed = true;
c8e7bf0d
NC
76 }
77}
eb4a6e4f 78
0a1b45a2 79static bool
c8e7bf0d
NC
80elf32_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
81{
0a1b45a2 82 bool failed = false;
c8e7bf0d
NC
83
84 /* Check if there are any relocations. */
85 bfd_map_over_sections (abfd, check_for_relocs, & failed);
eb4a6e4f 86
c8e7bf0d 87 if (failed)
0a1b45a2 88 return false;
4ad4eba5 89 return bfd_elf_link_add_symbols (abfd, info);
eb4a6e4f
L
90}
91
6d00b590 92#define TARGET_LITTLE_SYM elf32_le_vec
252b5132 93#define TARGET_LITTLE_NAME "elf32-little"
6d00b590 94#define TARGET_BIG_SYM elf32_be_vec
252b5132
RH
95#define TARGET_BIG_NAME "elf32-big"
96#define ELF_ARCH bfd_arch_unknown
97#define ELF_MACHINE_CODE EM_NONE
79e5982f 98#define ELF_MAXPAGESIZE 0x1
252b5132 99#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
157090f7 100#define bfd_elf32_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
eb4a6e4f 101#define bfd_elf32_bfd_link_add_symbols elf32_generic_link_add_symbols
252b5132
RH
102#define elf_info_to_howto elf_generic_info_to_howto
103#define elf_info_to_howto_rel elf_generic_info_to_howto_rel
104
105#include "elf32-target.h"