All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ppc64: Don't look for the TOC pointer all the time
@ 2015-05-19  9:19 Laurent Dufour
  0 siblings, 0 replies; only message in thread
From: Laurent Dufour @ 2015-05-19  9:19 UTC (permalink / raw)
  To: kexec, horms

When dealing with the purgatory's relocation, the TOC pointer is computed
by looking at the ".toc" section's address.

This should be done only once and the result kept back to avoid scanning
all the ELF section each time a TOC relative relocation is processed.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
---
 kexec/arch/ppc64/kexec-elf-rel-ppc64.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
index 9b191d0025a4..18d9f2f8e000 100644
--- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
@@ -1,4 +1,4 @@
-#include <stdio.h>
+ #include <stdio.h>
 #include <elf.h>
 #include <string.h>
 #include "../../kexec.h"
@@ -40,13 +40,17 @@ static struct mem_shdr *toc_section(const struct mem_ehdr *ehdr)
 unsigned long my_r2(const struct mem_ehdr *ehdr)
 {
 	struct mem_shdr *shdr;
+	static unsigned long r2 = 0;
 
-	shdr = toc_section(ehdr);
-	if (!shdr) {
-		die("TOC reloc without a toc section?");
+	if (!r2) {
+		shdr = toc_section(ehdr);
+		if (!shdr) {
+			die("TOC reloc without a toc section?");
+		}
+		r2 = shdr->sh_addr + 0x8000;
 	}
 
-	return shdr->sh_addr + 0x8000;
+	return r2;
 }
 
 static void do_relative_toc(unsigned long value, uint16_t *location,
-- 
1.9.1


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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-19  9:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19  9:19 [PATCH] ppc64: Don't look for the TOC pointer all the time Laurent Dufour

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.