ramips: remove obsolete 'pcibios_fixups' from the rt288x pci code
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.30 / 027-mips_module_reloc.patch
index 912857b..ca87662 100644 (file)
@@ -25,7 +25,7 @@
  typedef uint8_t Elf64_Byte;           /* Type for a 8-bit quantity.  */
 --- a/arch/mips/kernel/module.c
 +++ b/arch/mips/kernel/module.c
-@@ -43,6 +43,114 @@ static struct mips_hi16 *mips_hi16_list;
+@@ -43,6 +43,116 @@ static struct mips_hi16 *mips_hi16_list;
  static LIST_HEAD(dbe_list);
  static DEFINE_SPINLOCK(dbe_lock);
  
@@ -35,7 +35,7 @@
 + * physically mapped memory to put the module into.
 + */
 +static unsigned int
-+get_plt_size(const Elf32_Ehdr *hdr, const Elf32_Shdr *sechdrs,
++get_plt_size(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
 +             const char *secstrings, unsigned int symindex, bool is_init)
 +{
 +      unsigned long ret = 0;
 +      return ret;
 +}
 +
++#ifndef MODULE_START
 +static void *alloc_phys(unsigned long size)
 +{
 +      unsigned order;
 +
 +      return page_address(page);
 +}
++#endif
 +
 +static void free_phys(void *ptr, unsigned long size)
 +{
  void *module_alloc(unsigned long size)
  {
  #ifdef MODULE_START
-@@ -58,16 +166,41 @@ void *module_alloc(unsigned long size)
+@@ -58,16 +168,45 @@ void *module_alloc(unsigned long size)
  
        return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL);
  #else
 +              return vmalloc(size);
 +
 +      return ptr;
- #endif
- }
++#endif
++}
++
 +static inline bool is_phys_addr(void *ptr)
 +{
++#ifdef CONFIG_64BIT
++      return (KSEGX((unsigned long)ptr) == CKSEG0);
++#else
 +      return (KSEGX(ptr) == KSEG0);
-+}
-+
+ #endif
+ }
  /* Free memory returned from module_alloc */
  void module_free(struct module *mod, void *module_region)
  {
        /* FIXME: If module_region == mod->init_region, trim exception
             table entries. */
  }
-@@ -75,6 +208,24 @@ void module_free(struct module *mod, voi
+@@ -75,6 +214,24 @@ void module_free(struct module *mod, voi
  int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
                              char *secstrings, struct module *mod)
  {
        return 0;
  }
  
-@@ -97,45 +248,73 @@ static int apply_r_mips_32_rela(struct m
+@@ -97,27 +254,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);
 -                     me->name);
 -              return -ENOEXEC;
 -      }
-+      if (*plt_offset == size)
-+              return 0;
-+
 +      *plt_offset += 4 * sizeof(int);
 +
 +      /* adjust carry for addiu */
 +      if (v & 0x00008000)
 +              v += 0x10000;
--      *location = (*location & ~0x03ffffff) |
--                  ((*location + (v >> 2)) & 0x03ffffff);
++
 +      tramp[0] = 0x3c190000 | (v >> 16);      /* lui t9, hi16 */
 +      tramp[1] = 0x27390000 | (v & 0xffff);   /* addiu t9, t9, lo16 */
 +      tramp[2] = 0x03200008;                  /* jr t9 */
 +      tramp[3] = 0x00000000;                  /* nop */
-+
+-      *location = (*location & ~0x03ffffff) |
+-                  ((*location + (v >> 2)) & 0x03ffffff);
 +      return (Elf_Addr) tramp;
 +}
 +
 +      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;
  }
  {
        if (v % 4) {
                printk(KERN_ERR "module %s: dangerous relocation\n", me->name);
-               return -ENOEXEC;
+@@ -125,17 +296,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);
  static int apply_r_mips_hi16_rel(struct module *me, u32 *location, Elf_Addr v)
  {
        struct mips_hi16 *n;
-@@ -400,11 +579,23 @@ int module_finalize(const Elf_Ehdr *hdr,
+@@ -400,11 +585,23 @@ int module_finalize(const Elf_Ehdr *hdr,
                list_add(&me->arch.dbe_list, &dbe_list);
                spin_unlock_irq(&dbe_lock);
        }
This page took 0.030959 seconds and 4 git commands to generate.