[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 18/23] .TOC. symbol is special in ppc64le
From: |
Ram Pai |
Subject: |
[RFC PATCH 18/23] .TOC. symbol is special in ppc64le |
Date: |
Wed, 26 Feb 2014 10:31:17 -0800 |
.TOC. symbol is special in ppc64le . It maps to the
address of the .toc section.
Signed-off-by: Ram Pai <address@hidden>
---
grub-core/kern/dl.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index de2d0ed..ce2ff38 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -343,6 +343,26 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
return GRUB_ERR_NONE;
}
+#ifdef __powerpc64le__
+static int
+grub_dl_find_section_index (Elf_Ehdr *e, const char *name)
+{
+ Elf_Shdr *s;
+ const char *str;
+ unsigned i;
+
+ s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
+ str = (char *) e + s->sh_offset;
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ if (grub_strcmp (str + s->sh_name, name) == 0)
+ return i;
+ return -1;
+}
+#endif
+
static grub_err_t
grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
{
@@ -392,7 +412,19 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
/* Resolve a global symbol. */
if (sym->st_name != 0 && sym->st_shndx == 0)
{
- grub_symbol_t nsym = grub_dl_resolve_symbol (name);
+ grub_symbol_t nsym;
+
+#ifdef __powerpc64le__
+ if (grub_strcmp(name, ".TOC.") == 0) {
+ int j = grub_dl_find_section_index (e, ".toc");
+ if (j < 0)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ N_("section '.toc' not found"), name);
+ sym->st_value = (Elf_Addr) grub_dl_get_section_addr (mod, j);
+ break;
+ }
+#endif
+ nsym = grub_dl_resolve_symbol (name);
if (! nsym)
return grub_error (GRUB_ERR_BAD_MODULE,
N_("symbol `%s' not found"), name);
--
1.8.5.3
- [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit, (continued)
- [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit, Ram Pai, 2014/02/26
- [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues, Ram Pai, 2014/02/26
- [RFC PATCH 10/23] GRUB_ELF_R_PPC_* processing is applicable only for 32 bit bootloader., Ram Pai, 2014/02/26
- [RFC PATCH 12/23] Add powerpc64 ieee1275 trampoline, Ram Pai, 2014/02/26
- [RFC PATCH 13/23] Add 64bit support to powerpc startup code, Ram Pai, 2014/02/26
- [RFC PATCH 14/23] Add grub_dl_find_section_addr, Ram Pai, 2014/02/26
- [RFC PATCH 15/23] Add ppc64 relocations, Ram Pai, 2014/02/26
- [RFC PATCH 17/23] Use FUNC_START/FUNC_END for powerpc function definitions, Ram Pai, 2014/02/26
- [RFC PATCH 16/23] ppc64 doesn't need libgcc routines, Ram Pai, 2014/02/26
- [RFC PATCH 19/23] align .toc section on 4byte boundary., Ram Pai, 2014/02/26
- [RFC PATCH 18/23] .TOC. symbol is special in ppc64le,
Ram Pai <=
- [RFC PATCH 20/23] fix parameter to firmware calls, Ram Pai, 2014/02/26
- [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :), Ram Pai, 2014/02/26
- [RFC PATCH 22/23] fix segfaults if initrd, Ram Pai, 2014/02/26
- [RFC PATCH 23/23] Optional: Power7 VSX instructions workaround., Ram Pai, 2014/02/26