Imported Upstream version 0.153
[platform/upstream/elfutils.git] / backends / ppc64_symbol.c
1 /* PPC64 specific symbolic name handling.
2    Copyright (C) 2004, 2005 Red Hat, Inc.
3    This file is part of Red Hat elfutils.
4    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
5
6    Red Hat elfutils is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by the
8    Free Software Foundation; version 2 of the License.
9
10    Red Hat elfutils is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License along
16    with Red Hat elfutils; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
18
19    Red Hat elfutils is an included package of the Open Invention Network.
20    An included package of the Open Invention Network is a package for which
21    Open Invention Network licensees cross-license their patents.  No patent
22    license is granted, either expressly or impliedly, by designation as an
23    included package.  Should you wish to participate in the Open Invention
24    Network licensing program, please visit www.openinventionnetwork.com
25    <http://www.openinventionnetwork.com>.  */
26
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30
31 #include <assert.h>
32 #include <elf.h>
33 #include <stddef.h>
34 #include <string.h>
35
36 #define BACKEND         ppc64_
37 #include "libebl_CPU.h"
38
39
40 /* Check for the simple reloc types.  */
41 Elf_Type
42 ppc64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
43 {
44   switch (type)
45     {
46     case R_PPC64_ADDR64:
47     case R_PPC64_UADDR64:
48       return ELF_T_XWORD;
49     case R_PPC64_ADDR32:
50     case R_PPC64_UADDR32:
51       return ELF_T_WORD;
52     case R_PPC64_UADDR16:
53       return ELF_T_HALF;
54     default:
55       return ELF_T_NUM;
56     }
57 }
58
59
60 const char *
61 ppc64_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)),
62                         size_t len __attribute__ ((unused)))
63 {
64   switch (tag)
65     {
66     case DT_PPC64_GLINK:
67       return "PPC64_GLINK";
68     case DT_PPC64_OPD:
69       return "PPC64_OPD";
70     case DT_PPC64_OPDSZ:
71       return "PPC64_OPDSZ";
72     default:
73       break;
74     }
75   return NULL;
76 }
77
78
79 bool
80 ppc64_dynamic_tag_check (int64_t tag)
81 {
82   return (tag == DT_PPC64_GLINK
83           || tag == DT_PPC64_OPD
84           || tag == DT_PPC64_OPDSZ);
85 }
86
87
88 /* Check whether given symbol's st_value and st_size are OK despite failing
89    normal checks.  */
90 bool
91 ppc64_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr,
92                             const GElf_Sym *sym __attribute__ ((unused)),
93                             const char *name __attribute__ ((unused)),
94                             const GElf_Shdr *destshdr)
95 {
96   const char *sname = elf_strptr (elf, ehdr->e_shstrndx, destshdr->sh_name);
97   if (sname == NULL)
98     return false;
99   return strcmp (sname, ".opd") == 0;
100 }
101
102
103 /* Check if backend uses a bss PLT in this file.  */
104 bool
105 ppc64_bss_plt_p (Elf *elf __attribute__ ((unused)),
106                  GElf_Ehdr *ehdr __attribute__ ((unused)))
107 {
108   return true;
109 }