From: Anton Blanchard <anton@samba.org>
To: Simon Horman <horms@verge.net.au>, Matt Evans <matt@ozlabs.org>,
Michael Neuling <mikey@neuling.org>,
Milton Miller <miltonm@bga.com>,
amodra@gmail.com
Cc: kexec@lists.infradead.org
Subject: [PATCH 2/3] kexec-tools: powerpc: Add more 64bit relocations
Date: Mon, 14 Nov 2011 18:54:33 +1100 [thread overview]
Message-ID: <20111114185433.0297c2c8@kryten> (raw)
In-Reply-To: <20111114185329.19ddc2b4@kryten>
Add all the TOC16 relocations. These were hit when building kexec
with a recent toolchain.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
Index: kexec-tools/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
===================================================================
--- kexec-tools.orig/kexec/arch/ppc64/kexec-elf-rel-ppc64.c 2011-11-14 18:02:44.933276441 +1100
+++ kexec-tools/kexec/arch/ppc64/kexec-elf-rel-ppc64.c 2011-11-14 18:06:07.492903716 +1100
@@ -46,6 +46,19 @@ unsigned long my_r2(const struct mem_ehd
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)
@@ -70,15 +83,30 @@ void machine_apply_elf_rel(struct mem_eh
*(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:
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2011-11-14 8:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 7:53 [PATCH 1/3] kexec-tools: powerpc: Fix 64bit optimize for size (gcc -Os) build Anton Blanchard
2011-11-14 7:54 ` Anton Blanchard [this message]
2011-11-14 7:56 ` [PATCH 3/3] kexec-tools: powerpc: Cleanup relocation code Anton Blanchard
2011-11-14 8:46 ` [PATCH 1/3] kexec-tools: powerpc: Fix 64bit optimize for size (gcc -Os) build Simon Horman
2011-11-14 22:14 ` Alan Modra
2011-11-14 22:24 ` Anton Blanchard
2011-11-14 22:30 ` Alan Modra
2011-11-17 23:48 ` Simon Horman
2011-11-28 11:49 ` Anton Blanchard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111114185433.0297c2c8@kryten \
--to=anton@samba.org \
--cc=amodra@gmail.com \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=matt@ozlabs.org \
--cc=mikey@neuling.org \
--cc=miltonm@bga.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox