summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2011-11-14 18:54:33 +1100
committerSimon Horman <horms@verge.net.au>2011-11-14 17:45:14 +0900
commit920f4ededd9627add3ca1cdea965d204f2ca43a7 (patch)
tree40c2efa7a8e722a04370bed29b4239e5f396fa2d
parent38930d5eb16807f6de7f412eceefc3f6a7723797 (diff)
kexec-tools: powerpc: Add more 64bit relocations
Add all the TOC16 relocations. These were hit when building kexec with a recent toolchain. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/arch/ppc64/kexec-elf-rel-ppc64.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
index d293f6d..54d506a 100644
--- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
@@ -52,6 +52,19 @@ unsigned long my_r2(const struct mem_ehdr *ehdr)
return shdr->sh_addr + 0x8000;
}
+static void do_relative_toc(unsigned long value, uint16_t *location,
+ unsigned long mask, int complain_signed)
+{
+ if (complain_signed && (value + 0x8000 > 0xffff)) {
+ die("TOC16 relocation overflows (%lu)\n", value);
+ }
+
+ if ((~mask & 0xffff) & value) {
+ die("bad TOC16 relocation (%lu)\n", value);
+ }
+
+ *location = (*location & ~mask) | (value & mask);
+}
void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
void *location, unsigned long address, unsigned long value)
@@ -76,15 +89,30 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
*(uint64_t *)location = my_r2(ehdr);
break;
+ case R_PPC64_TOC16:
+ do_relative_toc(value - my_r2(ehdr), location, 0xffff, 1);
+ break;
+
case R_PPC64_TOC16_DS:
- /* Subtact TOC pointer */
- value -= my_r2(ehdr);
- if ((value & 3) != 0 || value + 0x8000 > 0xffff) {
- die("bad TOC16_DS relocation (%lu)\n", value);
- }
- *((uint16_t *) location)
- = (*((uint16_t *) location) & ~0xfffc)
- | (value & 0xfffc);
+ do_relative_toc(value - my_r2(ehdr), location, 0xfffc, 1);
+ break;
+
+ case R_PPC64_TOC16_LO:
+ do_relative_toc(value - my_r2(ehdr), location, 0xffff, 0);
+ break;
+
+ case R_PPC64_TOC16_LO_DS:
+ do_relative_toc(value - my_r2(ehdr), location, 0xfffc, 0);
+ break;
+
+ case R_PPC64_TOC16_HI:
+ do_relative_toc((value - my_r2(ehdr)) >> 16, location,
+ 0xffff, 0);
+ break;
+
+ case R_PPC64_TOC16_HA:
+ do_relative_toc((value - my_r2(ehdr) + 0x8000) >> 16, location,
+ 0xffff, 0);
break;
case R_PPC64_REL24: