1 /* Alpha specific symbolic name handling.
2 Copyright (C) 2002-2011 Red Hat, Inc.
3 This file is part of elfutils.
4 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
6 This file is free software; you can redistribute it and/or modify
7 it under the terms of either
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
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
19 or both in parallel, as here.
21 elfutils is distributed in the hope that it will be useful, but
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.
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/>. */
38 #define BACKEND alpha_
39 #include "libebl_CPU.h"
43 alpha_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)),
44 size_t len __attribute__ ((unused)))
57 alpha_dynamic_tag_check (int64_t tag)
59 return tag == DT_ALPHA_PLTRO;
62 /* Check for the simple reloc types. */
64 alpha_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
65 int *addsub __attribute__ ((unused)))
79 /* Check whether SHF_MASKPROC flags are valid. */
81 alpha_machine_section_flag_check (GElf_Xword sh_flags)
83 return (sh_flags &~ (SHF_ALPHA_GPREL)) == 0;
87 alpha_check_special_section (Ebl *ebl,
88 int ndx __attribute__ ((unused)),
89 const GElf_Shdr *shdr,
90 const char *sname __attribute__ ((unused)))
93 & (SHF_WRITE | SHF_EXECINSTR)) == (SHF_WRITE | SHF_EXECINSTR)
94 && shdr->sh_addr != 0)
96 /* This is ordinarily flagged, but is valid for an old-style PLT.
98 Look for the SHT_DYNAMIC section and the DT_PLTGOT tag in it.
99 Its d_ptr should match the .plt section's sh_addr. */
102 while ((scn = elf_nextscn (ebl->elf, scn)) != NULL)
105 if (likely (gelf_getshdr (scn, &scn_shdr) != NULL)
106 && scn_shdr.sh_type == SHT_DYNAMIC
107 && scn_shdr.sh_entsize != 0)
109 GElf_Addr pltgot = 0;
110 Elf_Data *data = elf_getdata (scn, NULL);
112 for (size_t i = 0; i < data->d_size / scn_shdr.sh_entsize; ++i)
115 if (unlikely (gelf_getdyn (data, i, &dyn) == NULL))
117 if (dyn.d_tag == DT_PLTGOT)
118 pltgot = dyn.d_un.d_ptr;
119 else if (dyn.d_tag == DT_ALPHA_PLTRO && dyn.d_un.d_val != 0)
120 return false; /* This PLT should not be writable. */
122 return pltgot == shdr->sh_addr;
130 /* Check whether given symbol's st_value and st_size are OK despite failing
133 alpha_check_special_symbol (Elf *elf __attribute__ ((unused)),
134 const GElf_Sym *sym __attribute__ ((unused)),
136 const GElf_Shdr *destshdr __attribute__ ((unused)))
141 if (strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
142 /* On Alpha any place in the section is valid. */
148 /* Check whether only valid bits are set on the st_other symbol flag.
149 Standard ST_VISIBILITY have already been masked off. */
151 alpha_check_st_other_bits (unsigned char st_other)
153 return ((((st_other & STO_ALPHA_STD_GPLOAD) == STO_ALPHA_NOPV)
154 || ((st_other & STO_ALPHA_STD_GPLOAD) == STO_ALPHA_STD_GPLOAD))
155 && (st_other &~ STO_ALPHA_STD_GPLOAD) == 0);