Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: Simon Horman <horms@verge.net.au>,
	Bill Schmidt <wschmidt@us.ibm.com>, Alan Modra <amodra@gmail.com>,
	Tony Breeds <tony@bakeyournoodle.com>
Cc: kexec@lists.infradead.org
Subject: [PATCH 2/3] ppc64: purgatory: Handle local symbols in ELF ABIv2
Date: Fri, 26 Feb 2016 18:04:16 +1100	[thread overview]
Message-ID: <20160226180416.0748cb9f@kryten> (raw)
In-Reply-To: <20160226180311.2938d804@kryten>

The PowerPC64 ELF ABIv2 has the concept of global and local symbols
and information on this is encoded in sym->st_other. When doing a
R_PPC64_REL24 branch we want to hit the local entry point, so adjust
it as necessary.

Signed-off-by: Anton Blanchard <anton@samba.org>
---
 kexec/arch/ppc64/kexec-elf-rel-ppc64.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

v2: In local_entry_offset() mark sym as unused when compiling ABIv1.

diff --git a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
index 8604c4f..43851f6 100644
--- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
@@ -5,6 +5,24 @@
 #include "../../kexec-elf.h"
 #include "kexec-ppc64.h"
 
+#if defined(_CALL_ELF) && _CALL_ELF == 2
+#define STO_PPC64_LOCAL_BIT	5
+#define STO_PPC64_LOCAL_MASK	(7 << STO_PPC64_LOCAL_BIT)
+#define PPC64_LOCAL_ENTRY_OFFSET(other) \
+ (((1 << (((other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2)
+
+static unsigned int local_entry_offset(struct mem_sym *sym)
+{
+	/* If this symbol has a local entry point, use it. */
+	return PPC64_LOCAL_ENTRY_OFFSET(sym->st_other);
+}
+#else
+static unsigned int local_entry_offset(struct mem_sym *UNUSED(sym))
+{
+	return 0;
+}
+#endif
+
 int machine_verify_elf_rel(struct mem_ehdr *ehdr)
 {
 	if (ehdr->ei_class != ELFCLASS64) {
@@ -114,6 +132,7 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *sym,
 		break;
 
 	case R_PPC64_REL24:
+		value += local_entry_offset(sym);
 		/* Convert value to relative */
 		value -= address;
 		if (value + 0x2000000 > 0x3ffffff || (value & 3) != 0) {
-- 
2.5.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2016-02-26  7:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26  7:03 [PATCH 1/3] Pass struct mem_sym into machine_apply_elf_rel() Anton Blanchard
2016-02-26  7:04 ` Anton Blanchard [this message]
2016-02-26  7:06 ` [PATCH 3/3] Properly align powerpc64 .toc Anton Blanchard
2016-02-26 11:53 ` [PATCH 1/3] Pass struct mem_sym into machine_apply_elf_rel() Dave Young
2016-03-04  8:12   ` Dave Young
2016-03-23  4:10 ` Tony Breeds
2016-03-24  0:49   ` Michael Ellerman
2016-03-24  5:00     ` Simon Horman

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=20160226180416.0748cb9f@kryten \
    --to=anton@samba.org \
    --cc=amodra@gmail.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=tony@bakeyournoodle.com \
    --cc=wschmidt@us.ibm.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