| 1 | #include <stdio.h> |
| 2 | #include <elf.h> |
| 3 | #include "../../kexec.h" |
| 4 | #include "../../kexec-elf.h" |
| 5 | |
| 6 | int machine_verify_elf_rel(struct mem_ehdr *ehdr) |
| 7 | { |
| 8 | if (ehdr->ei_data != ELFDATA2MSB) { |
| 9 | return 0; |
| 10 | } |
| 11 | if (ehdr->ei_class != ELFCLASS32) { |
| 12 | return 0; |
| 13 | } |
| 14 | if (ehdr->e_machine != EM_ARM) |
| 15 | { |
| 16 | return 0; |
| 17 | } |
| 18 | return 1; |
| 19 | } |
| 20 | |
| 21 | void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), |
| 22 | struct mem_sym *UNUSED(sym), unsigned long r_type, void *location, |
| 23 | unsigned long address, unsigned long value) |
| 24 | { |
| 25 | switch(r_type) { |
| 26 | case R_ARM_ABS32: |
| 27 | *((uint32_t *)location) += value; |
| 28 | break; |
| 29 | case R_ARM_REL32: |
| 30 | *((uint32_t *)location) += value - address; |
| 31 | break; |
| 32 | default: |
| 33 | die("Unknown rel relocation: %lu\n", r_type); |
| 34 | break; |
| 35 | } |
| 36 | } |