Commit 3f6f586d authored by Paul Mackerras's avatar Paul Mackerras

PPC32: in loading modules, make sure PLT start address is aligned.

parent 356f833b
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/cache.h>
#if 0 #if 0
#define DEBUGP printk #define DEBUGP printk
...@@ -105,8 +106,9 @@ long module_core_size(const Elf32_Ehdr *hdr, ...@@ -105,8 +106,9 @@ long module_core_size(const Elf32_Ehdr *hdr,
const char *secstrings, const char *secstrings,
struct module *module) struct module *module)
{ {
module->arch.core_plt_offset = module->core_size; module->arch.core_plt_offset = ALIGN(module->core_size, 4);
return module->core_size + get_plt_size(hdr, sechdrs, secstrings, 0); return module->arch.core_plt_offset
+ get_plt_size(hdr, sechdrs, secstrings, 0);
} }
long module_init_size(const Elf32_Ehdr *hdr, long module_init_size(const Elf32_Ehdr *hdr,
...@@ -114,8 +116,9 @@ long module_init_size(const Elf32_Ehdr *hdr, ...@@ -114,8 +116,9 @@ long module_init_size(const Elf32_Ehdr *hdr,
const char *secstrings, const char *secstrings,
struct module *module) struct module *module)
{ {
module->arch.init_plt_offset = module->init_size; module->arch.init_plt_offset = ALIGN(module->init_size, 4);
return module->init_size + get_plt_size(hdr, sechdrs, secstrings, 1); return module->arch.init_plt_offset
+ get_plt_size(hdr, sechdrs, secstrings, 1);
} }
int apply_relocate(Elf32_Shdr *sechdrs, int apply_relocate(Elf32_Shdr *sechdrs,
...@@ -142,7 +145,7 @@ static uint32_t do_plt_call(void *location, Elf32_Addr val, struct module *mod) ...@@ -142,7 +145,7 @@ static uint32_t do_plt_call(void *location, Elf32_Addr val, struct module *mod)
{ {
struct ppc_plt_entry *entry; struct ppc_plt_entry *entry;
DEBUGP("Doing plt for %u\n", (unsigned int)location); DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
/* Init, or core PLT? */ /* Init, or core PLT? */
if (location >= mod->module_core if (location >= mod->module_core
&& location < mod->module_core + mod->arch.core_plt_offset) && location < mod->module_core + mod->arch.core_plt_offset)
...@@ -162,6 +165,7 @@ static uint32_t do_plt_call(void *location, Elf32_Addr val, struct module *mod) ...@@ -162,6 +165,7 @@ static uint32_t do_plt_call(void *location, Elf32_Addr val, struct module *mod)
entry->jump[2] = 0x7d6903a6; /* mtctr r11 */ entry->jump[2] = 0x7d6903a6; /* mtctr r11 */
entry->jump[3] = 0x4e800420; /* bctr */ entry->jump[3] = 0x4e800420; /* bctr */
DEBUGP("Initialized plt for 0x%x at %p\n", val, entry);
return (uint32_t)entry; return (uint32_t)entry;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment