Lines Matching +full:invert +full:- +full:x

4  * SPDX-License-Identifier: Apache-2.0
91 * @brief Function computing a relocation (X in AArch64 ELF).
98 * @return Result of the relocation operation (X in AArch64 ELF)
107 return sym_base_addr + addend - loc; in reloc()
109 return AARCH64_PAGE(sym_base_addr + addend) - AARCH64_PAGE(loc); in reloc()
125 * @retval -ERANGE Relocation value overflow
131 int64_t x; in data_reloc_handler() local
135 *(int64_t *)loc = reloc(AARCH64_RELOC_TYPE_ABS, loc, sym_base_addr, rel->r_addend); in data_reloc_handler()
139 x = reloc(AARCH64_RELOC_TYPE_ABS, loc, sym_base_addr, rel->r_addend); in data_reloc_handler()
140 if (x < 0 || x > UINT32_MAX) { in data_reloc_handler()
141 return -ERANGE; in data_reloc_handler()
143 *(uint32_t *)loc = (uint32_t)x; in data_reloc_handler()
147 x = reloc(AARCH64_RELOC_TYPE_ABS, loc, sym_base_addr, rel->r_addend); in data_reloc_handler()
148 if (x < 0 || x > UINT16_MAX) { in data_reloc_handler()
149 return -ERANGE; in data_reloc_handler()
151 *(uint16_t *)loc = (uint16_t)x; in data_reloc_handler()
155 *(int64_t *)loc = reloc(AARCH64_RELOC_TYPE_PREL, loc, sym_base_addr, rel->r_addend); in data_reloc_handler()
159 x = reloc(AARCH64_RELOC_TYPE_PREL, loc, sym_base_addr, rel->r_addend); in data_reloc_handler()
160 if (x < INT32_MIN || x > INT32_MAX) { in data_reloc_handler()
161 return -ERANGE; in data_reloc_handler()
163 *(int32_t *)loc = (int32_t)x; in data_reloc_handler()
167 x = reloc(AARCH64_RELOC_TYPE_PREL, loc, sym_base_addr, rel->r_addend); in data_reloc_handler()
168 if (x < INT16_MIN || x > INT16_MAX) { in data_reloc_handler()
169 return -ERANGE; in data_reloc_handler()
171 *(int16_t *)loc = (int16_t)x; in data_reloc_handler()
189 * @retval -ERANGE Relocation value overflow
195 int64_t x; in movw_reloc_handler() local
197 int lsb = 0; /* LSB of X to be used */ in movw_reloc_handler()
257 x = reloc(type, loc, sym_base_addr, rel->r_addend); in movw_reloc_handler()
258 imm = x >> lsb; in movw_reloc_handler()
264 if (x >= 0) { in movw_reloc_handler()
268 /* Need to invert immediate value for MOVZ. */ in movw_reloc_handler()
279 return -ERANGE; in movw_reloc_handler()
293 * @retval -ERANGE Relocation value overflow
299 int lsb = 2; /* LSB of X to be used */ in imm_reloc_handler()
304 int64_t x; in imm_reloc_handler() local
377 x = reloc(type, loc, sym_base_addr, rel->r_addend); in imm_reloc_handler()
378 x >>= lsb; in imm_reloc_handler()
380 imm = x & BIT_MASK(len); in imm_reloc_handler()
401 /* Mask X sign bit and upper bits. */ in imm_reloc_handler()
402 x = (int64_t)(x & ~BIT_MASK(len - 1)) >> (len - 1); in imm_reloc_handler()
404 /* Incrementing X will either overflow and set it to 0 or in imm_reloc_handler()
407 if ((int64_t)x++ > 1) { in imm_reloc_handler()
408 return -ERANGE; in imm_reloc_handler()
422 * https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#relocation
430 * @retval -ENOTSUP Unsupported relocation
431 * @retval -ENOEXEC Invalid relocation
438 elf_word reloc_type = ELF_R_TYPE(rel->r_info); in arch_elf_relocate()
500 /* TODO Handle case when address exceeds +/- 128MB */ in arch_elf_relocate()
505 return -ENOEXEC; in arch_elf_relocate()
508 if (overflow_check && ret == -ERANGE) { in arch_elf_relocate()
509 LOG_ERR("sym '%s': relocation out of range (%#lx -> %#lx)\n", sym_name, loc, in arch_elf_relocate()
511 return -ENOEXEC; in arch_elf_relocate()