Coverage Report

Created: 2025-06-24 06:45

/src/binutils-gdb/bfd/elf64-gen.c
Line
Count
Source (jump to first uncovered line)
1
/* Generic support for 64-bit ELF
2
   Copyright (C) 1993-2025 Free Software Foundation, Inc.
3
4
   This file is part of BFD, the Binary File Descriptor library.
5
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
8
   the Free Software Foundation; either version 3 of the License, or
9
   (at your option) any later version.
10
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.
15
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
18
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
   MA 02110-1301, USA.  */
20
21
#include "sysdep.h"
22
#include "bfd.h"
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
29
static reloc_howto_type dummy =
30
  HOWTO (0,     /* type */
31
   0,     /* rightshift */
32
   0,     /* size */
33
   0,     /* bitsize */
34
   false,     /* pc_relative */
35
   0,     /* bitpos */
36
   complain_overflow_dont, /* complain_on_overflow */
37
   NULL,      /* special_function */
38
   "UNKNOWN",   /* name */
39
   false,     /* partial_inplace */
40
   0,     /* src_mask */
41
   0,     /* dst_mask */
42
   false);    /* pcrel_offset */
43
44
static bool
45
elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
46
         arelent *bfd_reloc,
47
         Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
48
45.8k
{
49
45.8k
  bfd_reloc->howto = &dummy;
50
45.8k
  return true;
51
45.8k
}
52
53
static bool
54
elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
55
             arelent *bfd_reloc,
56
             Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
57
0
{
58
0
  bfd_reloc->howto = &dummy;
59
0
  return true;
60
0
}
61
62
static void
63
check_for_relocs (bfd * abfd, asection * o, void * failed)
64
0
{
65
0
  if ((o->flags & SEC_RELOC) != 0)
66
0
    {
67
0
      Elf_Internal_Ehdr *ehdrp;
68
69
0
      ehdrp = elf_elfheader (abfd);
70
      /* xgettext:c-format */
71
0
      _bfd_error_handler (_("%pB: Relocations in generic ELF (EM: %d)"),
72
0
        abfd, ehdrp->e_machine);
73
74
0
      bfd_set_error (bfd_error_wrong_format);
75
0
      * (bool *) failed = true;
76
0
    }
77
0
}
78
79
static bool
80
elf64_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
81
0
{
82
0
  bool failed = false;
83
84
  /* Check if there are any relocations.  */
85
0
  bfd_map_over_sections (abfd, check_for_relocs, & failed);
86
87
0
  if (failed)
88
0
    return false;
89
0
  return bfd_elf_link_add_symbols (abfd, info);
90
0
}
91
92
#define TARGET_LITTLE_SYM   elf64_le_vec
93
#define TARGET_LITTLE_NAME    "elf64-little"
94
#define TARGET_BIG_SYM      elf64_be_vec
95
#define TARGET_BIG_NAME     "elf64-big"
96
#define ELF_ARCH      bfd_arch_unknown
97
#define ELF_MACHINE_CODE    EM_NONE
98
#define ELF_MAXPAGESIZE     0x1
99
#define bfd_elf64_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
100
#define bfd_elf64_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
101
#define bfd_elf64_bfd_link_add_symbols  elf64_generic_link_add_symbols
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 "elf64-target.h"