1 /* Initialization of x86-64 specific backend library.
2 Copyright (C) 2002-2009, 2013, 2018 Red Hat, Inc.
3 Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
4 This file is part of elfutils.
5 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
6
7 This file is free software; you can redistribute it and/or modify
8 it under the terms of either
9
10 * the GNU Lesser General Public License as published by the Free
11 Software Foundation; either version 3 of the License, or (at
12 your option) any later version
13
14 or
15
16 * the GNU General Public License as published by the Free
17 Software Foundation; either version 2 of the License, or (at
18 your option) any later version
19
20 or both in parallel, as here.
21
22 elfutils is distributed in the hope that it will be useful, but
23 WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
26
27 You should have received copies of the GNU General Public License and
28 the GNU Lesser General Public License along with this program. If
29 not, see <http://www.gnu.org/licenses/>. */
30
31 #ifdef HAVE_CONFIG_H
32 # include <config.h>
33 #endif
34
35 #define BACKEND x86_64_
36 #define RELOC_PREFIX R_X86_64_
37 #include "libebl_CPU.h"
38
39 /* This defines the common reloc hooks based on x86_64_reloc.def. */
40 #include "common-reloc.c"
41
42 extern __typeof (EBLHOOK (core_note)) x32_core_note attribute_hidden;
43
44 const char *
x86_64_init(Elf * elf,GElf_Half machine,Ebl * eh,size_t ehlen)45 x86_64_init (Elf *elf __attribute__ ((unused)),
46 GElf_Half machine __attribute__ ((unused)),
47 Ebl *eh,
48 size_t ehlen)
49 {
50 /* Check whether the Elf_BH object has a sufficent size. */
51 if (ehlen < sizeof (Ebl))
52 return NULL;
53
54 /* We handle it. */
55 eh->name = "AMD x86-64";
56 x86_64_init_reloc (eh);
57 HOOK (eh, reloc_simple_type);
58 HOOK (eh, section_type_name);
59 if (eh->class == ELFCLASS32)
60 eh->core_note = x32_core_note;
61 else
62 HOOK (eh, core_note);
63 HOOK (eh, return_value_location);
64 HOOK (eh, register_info);
65 HOOK (eh, syscall_abi);
66 HOOK (eh, auxv_info);
67 HOOK (eh, disasm);
68 HOOK (eh, abi_cfi);
69 /* gcc/config/ #define DWARF_FRAME_REGISTERS. */
70 eh->frame_nregs = 17;
71 HOOK (eh, set_initial_registers_tid);
72 HOOK (eh, unwind);
73
74 return MODVERSION;
75 }
76