X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/a9dafde4e393e0067043a5adb7cf37d3a4a6f3d2..19b9e51722f249a7e208c127de810afdfe07833f:/target/linux/generic-2.6/patches-2.6.28/026-mips_module_reloc.patch diff --git a/target/linux/generic-2.6/patches-2.6.28/026-mips_module_reloc.patch b/target/linux/generic-2.6/patches-2.6.28/026-mips_module_reloc.patch index 49978ee38..dd035b945 100644 --- a/target/linux/generic-2.6/patches-2.6.28/026-mips_module_reloc.patch +++ b/target/linux/generic-2.6/patches-2.6.28/026-mips_module_reloc.patch @@ -209,13 +209,13 @@ return 0; } -@@ -97,45 +248,73 @@ static int apply_r_mips_32_rela(struct m +@@ -97,27 +248,41 @@ static int apply_r_mips_32_rela(struct m return 0; } -static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v) +static Elf_Addr add_plt_entry_to(unsigned *plt_offset, -+ void *start, unsigned size, Elf_Addr v) ++ void *start, Elf_Addr v) { - if (v % 4) { - printk(KERN_ERR "module %s: dangerous relocation\n", me->name); @@ -229,9 +229,6 @@ - me->name); - return -ENOEXEC; - } -+ if (*plt_offset == size) -+ return 0; -+ + *plt_offset += 4 * sizeof(int); + + /* adjust carry for addiu */ @@ -253,12 +250,12 @@ + if (location >= me->module_core && + location < me->module_core + me->core_size) + return add_plt_entry_to(&me->arch.core_plt_offset, -+ me->module_core, me->core_size, v); ++ me->arch.plt_tbl, v); + + if (location >= me->module_init && + location < me->module_init + me->init_size) + return add_plt_entry_to(&me->arch.init_plt_offset, -+ me->module_init, me->init_size, v); ++ me->arch.plt_tbl, v); return 0; } @@ -268,16 +265,20 @@ { if (v % 4) { printk(KERN_ERR "module %s: dangerous relocation\n", me->name); - return -ENOEXEC; +@@ -125,17 +290,31 @@ static int apply_r_mips_26_rela(struct m } -- if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { -+ if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000) && -+ ((v = add_plt_entry(me, location, v + (ofs << 2))) == 0)) { - printk(KERN_ERR + if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { +- printk(KERN_ERR ++ v = add_plt_entry(me, location, v + (ofs << 2)); ++ if (!v) { ++ printk(KERN_ERR "module %s: relocation overflow\n", me->name); - return -ENOEXEC; +- return -ENOEXEC; ++ return -ENOEXEC; ++ } ++ ofs = 0; } - *location = (*location & ~0x03ffffff) | ((v >> 2) & 0x03ffffff);