2 * reloc_arm.c - position-independent ARM ELF shared object relocator
4 * Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
5 * Copyright (C) 1999 Hewlett-Packard Co.
6 * Contributed by David Mosberger <davidm@hpl.hp.com>.
10 * SPDX-License-Identifier: BSD-3-Clause
12 * This file is taken and modified from the gnu-efi project.
18 efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn, efi_handle_t image,
19 struct efi_system_table *systab)
21 long relsz = 0, relent = 0;
26 for (i = 0; dyn[i].d_tag != DT_NULL; ++i) {
27 switch (dyn[i].d_tag) {
29 rel = (Elf32_Rel *)((ulong)dyn[i].d_un.d_ptr
33 relsz = dyn[i].d_un.d_val;
36 relent = dyn[i].d_un.d_val;
43 if (!rel && relent == 0)
46 if (!rel || relent == 0)
47 return EFI_LOAD_ERROR;
50 /* apply the relocs */
51 switch (ELF32_R_TYPE(rel->r_info)) {
55 addr = (ulong *)(ldbase + rel->r_offset);
61 rel = (Elf32_Rel *)((char *)rel + relent);