1 /* RISC-V specific symbolic name handling.
2 This file is part of elfutils.
4 This file is free software; you can redistribute it and/or modify
5 it under the terms of either
7 * the GNU Lesser General Public License as published by the Free
8 Software Foundation; either version 3 of the License, or (at
9 your option) any later version
13 * the GNU General Public License as published by the Free
14 Software Foundation; either version 2 of the License, or (at
15 your option) any later version
17 or both in parallel, as here.
19 elfutils is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received copies of the GNU General Public License and
25 the GNU Lesser General Public License along with this program. If
26 not, see <http://www.gnu.org/licenses/>. */
37 #define BACKEND riscv_
38 #include "libebl_CPU.h"
41 /* Check for the simple reloc types. */
43 riscv_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
80 /* Check whether machine flags are valid. */
82 riscv_machine_flag_check (GElf_Word flags)
84 return ((flags &~ (EF_RISCV_RVC
85 | EF_RISCV_FLOAT_ABI)) == 0);
88 /* Check whether given symbol's st_value and st_size are OK despite failing
91 riscv_check_special_symbol (Elf *elf, const GElf_Sym *sym,
92 const char *name, const GElf_Shdr *destshdr)
98 if (elf_getshdrstrndx (elf, &shstrndx) != 0)
100 const char *sname = elf_strptr (elf, shstrndx, destshdr->sh_name);
104 /* _GLOBAL_OFFSET_TABLE_ points to the start of the .got section, but it
105 is preceded by the .got.plt section in the output .got section. */
106 if (strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
107 return (strcmp (sname, ".got") == 0
108 && sym->st_value >= destshdr->sh_addr
109 && sym->st_value < destshdr->sh_addr + destshdr->sh_size);
111 /* __global_pointer$ points to the .sdata section with an offset of
112 0x800. It might however fall in the .got section, in which case we
113 cannot check the offset. The size always should be zero. */
114 if (strcmp (name, "__global_pointer$") == 0)
115 return (((strcmp (sname, ".sdata") == 0
116 && sym->st_value == destshdr->sh_addr + 0x800)
117 || strcmp (sname, ".got") == 0)
118 && sym->st_size == 0);