1 /* Alpha specific symbolic name handling.
2 Copyright (C) 2002-2011 Red Hat, Inc.
3 This file is part of Red Hat elfutils.
4 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
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.
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.
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.
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>. */
35 #define BACKEND alpha_
36 #include "libebl_CPU.h"
40 alpha_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)),
41 size_t len __attribute__ ((unused)))
54 alpha_dynamic_tag_check (int64_t tag)
56 return tag == DT_ALPHA_PLTRO;
59 /* Check for the simple reloc types. */
61 alpha_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
75 /* Check whether SHF_MASKPROC flags are valid. */
77 alpha_machine_section_flag_check (GElf_Xword sh_flags)
79 return (sh_flags &~ (SHF_ALPHA_GPREL)) == 0;
83 alpha_check_special_section (Ebl *ebl,
84 int ndx __attribute__ ((unused)),
85 const GElf_Shdr *shdr,
86 const char *sname __attribute__ ((unused)))
89 & (SHF_WRITE | SHF_EXECINSTR)) == (SHF_WRITE | SHF_EXECINSTR)
90 && shdr->sh_addr != 0)
92 /* This is ordinarily flagged, but is valid for an old-style PLT.
94 Look for the SHT_DYNAMIC section and the DT_PLTGOT tag in it.
95 Its d_ptr should match the .plt section's sh_addr. */
98 while ((scn = elf_nextscn (ebl->elf, scn)) != NULL)
101 if (likely (gelf_getshdr (scn, &scn_shdr) != NULL)
102 && scn_shdr.sh_type == SHT_DYNAMIC
103 && scn_shdr.sh_entsize != 0)
105 GElf_Addr pltgot = 0;
106 Elf_Data *data = elf_getdata (scn, NULL);
108 for (size_t i = 0; i < data->d_size / scn_shdr.sh_entsize; ++i)
111 if (unlikely (gelf_getdyn (data, i, &dyn) == NULL))
113 if (dyn.d_tag == DT_PLTGOT)
114 pltgot = dyn.d_un.d_ptr;
115 else if (dyn.d_tag == DT_ALPHA_PLTRO && dyn.d_un.d_val != 0)
116 return false; /* This PLT should not be writable. */
118 return pltgot == shdr->sh_addr;
126 /* Check whether given symbol's st_value and st_size are OK despite failing
129 alpha_check_special_symbol (Elf *elf __attribute__ ((unused)),
130 GElf_Ehdr *ehdr __attribute__ ((unused)),
131 const GElf_Sym *sym __attribute__ ((unused)),
133 const GElf_Shdr *destshdr __attribute__ ((unused)))
138 if (strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
139 /* On Alpha any place in the section is valid. */
145 /* Check whether only valid bits are set on the st_other symbol flag.
146 Standard ST_VISIBILITY have already been masked off. */
148 alpha_check_st_other_bits (unsigned char st_other)
150 return ((((st_other & STO_ALPHA_STD_GPLOAD) == STO_ALPHA_NOPV)
151 || ((st_other & STO_ALPHA_STD_GPLOAD) == STO_ALPHA_STD_GPLOAD))
152 && (st_other &~ STO_ALPHA_STD_GPLOAD) == 0);