Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 1 | /* Initialization of PPC64 specific backend library. |
Mark Wielaard | 0c4a868 | 2014-01-04 19:19:16 +0100 | [diff] [blame] | 2 | Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013, 2014 Red Hat, Inc. |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 3 | This file is part of elfutils. |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 4 | Written by Ulrich Drepper <drepper@redhat.com>, 2004. |
| 5 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 6 | This file is free software; you can redistribute it and/or modify |
| 7 | it under the terms of either |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 8 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 9 | * the GNU Lesser General Public License as published by the Free |
| 10 | Software Foundation; either version 3 of the License, or (at |
| 11 | your option) any later version |
| 12 | |
| 13 | or |
| 14 | |
| 15 | * the GNU General Public License as published by the Free |
| 16 | Software Foundation; either version 2 of the License, or (at |
| 17 | your option) any later version |
| 18 | |
| 19 | or both in parallel, as here. |
| 20 | |
| 21 | elfutils is distributed in the hope that it will be useful, but |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 22 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 24 | General Public License for more details. |
| 25 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 26 | You should have received copies of the GNU General Public License and |
| 27 | the GNU Lesser General Public License along with this program. If |
| 28 | not, see <http://www.gnu.org/licenses/>. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 29 | |
| 30 | #ifdef HAVE_CONFIG_H |
| 31 | # include <config.h> |
| 32 | #endif |
| 33 | |
Mark Wielaard | 159ac52 | 2013-12-18 11:05:54 +0100 | [diff] [blame] | 34 | #include <string.h> |
| 35 | |
Roland McGrath | cd60ea8 | 2005-11-16 01:57:40 +0000 | [diff] [blame] | 36 | #define BACKEND ppc64_ |
| 37 | #define RELOC_PREFIX R_PPC64_ |
| 38 | #include "libebl_CPU.h" |
| 39 | |
| 40 | /* This defines the common reloc hooks based on ppc64_reloc.def. */ |
| 41 | #include "common-reloc.c" |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 42 | |
| 43 | |
| 44 | const char * |
| 45 | ppc64_init (elf, machine, eh, ehlen) |
| 46 | Elf *elf __attribute__ ((unused)); |
| 47 | GElf_Half machine __attribute__ ((unused)); |
| 48 | Ebl *eh; |
| 49 | size_t ehlen; |
| 50 | { |
| 51 | /* Check whether the Elf_BH object has a sufficent size. */ |
| 52 | if (ehlen < sizeof (Ebl)) |
| 53 | return NULL; |
| 54 | |
| 55 | /* We handle it. */ |
| 56 | eh->name = "PowerPC 64-bit"; |
Roland McGrath | cd60ea8 | 2005-11-16 01:57:40 +0000 | [diff] [blame] | 57 | ppc64_init_reloc (eh); |
Roland McGrath | f47ba53 | 2005-11-19 07:40:29 +0000 | [diff] [blame] | 58 | HOOK (eh, reloc_simple_type); |
| 59 | HOOK (eh, dynamic_tag_name); |
| 60 | HOOK (eh, dynamic_tag_check); |
Mark Wielaard | 0c4a868 | 2014-01-04 19:19:16 +0100 | [diff] [blame] | 61 | HOOK (eh, machine_flag_check); |
Roland McGrath | f47ba53 | 2005-11-19 07:40:29 +0000 | [diff] [blame] | 62 | HOOK (eh, copy_reloc_p); |
| 63 | HOOK (eh, check_special_symbol); |
Mark Wielaard | a95c4ad | 2014-07-04 14:30:48 +0200 | [diff] [blame] | 64 | HOOK (eh, check_st_other_bits); |
Roland McGrath | f47ba53 | 2005-11-19 07:40:29 +0000 | [diff] [blame] | 65 | HOOK (eh, bss_plt_p); |
| 66 | HOOK (eh, return_value_location); |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 67 | HOOK (eh, register_info); |
Roland McGrath | 1d8bb25 | 2008-08-07 08:39:41 +0000 | [diff] [blame] | 68 | HOOK (eh, syscall_abi); |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 69 | HOOK (eh, core_note); |
| 70 | HOOK (eh, auxv_info); |
Jan Kratochvil | ed9d2ca | 2013-08-27 22:49:36 +0200 | [diff] [blame] | 71 | HOOK (eh, abi_cfi); |
Jan Kratochvil | 5cbf42a | 2013-12-15 18:56:17 +0100 | [diff] [blame] | 72 | /* gcc/config/ #define DWARF_FRAME_REGISTERS. */ |
| 73 | eh->frame_nregs = (114 - 1) + 32; |
| 74 | HOOK (eh, set_initial_registers_tid); |
| 75 | HOOK (eh, dwarf_to_regno); |
Mark Wielaard | 159ac52 | 2013-12-18 11:05:54 +0100 | [diff] [blame] | 76 | HOOK (eh, resolve_sym_value); |
| 77 | |
| 78 | /* Find the function descriptor .opd table for resolve_sym_value. */ |
| 79 | if (elf != NULL) |
| 80 | { |
| 81 | GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (elf, &ehdr_mem); |
| 82 | if (ehdr != NULL && ehdr->e_type != ET_REL) |
| 83 | { |
| 84 | /* We could also try through DT_PPC64_OPD and DT_PPC64_OPDSZ. */ |
| 85 | GElf_Shdr opd_shdr_mem, *opd_shdr; |
| 86 | Elf_Scn *scn = NULL; |
| 87 | while ((scn = elf_nextscn (elf, scn)) != NULL) |
| 88 | { |
| 89 | opd_shdr = gelf_getshdr (scn, &opd_shdr_mem); |
| 90 | if (opd_shdr != NULL |
| 91 | && (opd_shdr->sh_flags & SHF_ALLOC) != 0 |
| 92 | && opd_shdr->sh_type == SHT_PROGBITS |
Mark Wielaard | 5c1a45c | 2014-11-17 23:15:45 +0100 | [diff] [blame] | 93 | && opd_shdr->sh_size > 0) |
Mark Wielaard | 159ac52 | 2013-12-18 11:05:54 +0100 | [diff] [blame] | 94 | { |
Mark Wielaard | 5c1a45c | 2014-11-17 23:15:45 +0100 | [diff] [blame] | 95 | const char *name = elf_strptr (elf, ehdr->e_shstrndx, |
| 96 | opd_shdr->sh_name); |
| 97 | if (name != NULL && strcmp (name, ".opd") == 0) |
| 98 | { |
| 99 | eh->fd_addr = opd_shdr->sh_addr; |
| 100 | eh->fd_data = elf_getdata (scn, NULL); |
| 101 | break; |
| 102 | } |
Mark Wielaard | 159ac52 | 2013-12-18 11:05:54 +0100 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | } |
| 106 | } |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 107 | |
| 108 | return MODVERSION; |
| 109 | } |