module: fix module loading failure of large kernel modules for parisc

When creating the final layout of a kernel module in memory, allow the
module loader to reserve some additional memory in front of a given section.
This is currently only needed for the parisc port which needs to put the
stub entries there to fulfill the 17/22bit PCREL relocations with large
kernel modules like xfs.

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (renamed fn)

authored by

Helge Deller and committed by
Rusty Russell
088af9a6 d1e99d7a

+16 -3
+3
include/linux/moduleloader.h
··· 13 char *secstrings, 14 struct module *mod); 15 16 /* Allocator used for allocating struct module, core sections and init 17 sections. Returns NULL on failure. */ 18 void *module_alloc(unsigned long size);
··· 13 char *secstrings, 14 struct module *mod); 15 16 + /* Additional bytes needed by arch in front of individual sections */ 17 + unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section); 18 + 19 /* Allocator used for allocating struct module, core sections and init 20 sections. Returns NULL on failure. */ 21 void *module_alloc(unsigned long size);
+13 -3
kernel/module.c
··· 1578 return ret; 1579 } 1580 1581 /* Update size with this section: return offset. */ 1582 - static long get_offset(unsigned int *size, Elf_Shdr *sechdr) 1583 { 1584 long ret; 1585 1586 ret = ALIGN(*size, sechdr->sh_addralign ?: 1); 1587 *size = ret + sechdr->sh_size; 1588 return ret; ··· 1632 || strncmp(secstrings + s->sh_name, 1633 ".init", 5) == 0) 1634 continue; 1635 - s->sh_entsize = get_offset(&mod->core_size, s); 1636 DEBUGP("\t%s\n", secstrings + s->sh_name); 1637 } 1638 if (m == 0) ··· 1650 || strncmp(secstrings + s->sh_name, 1651 ".init", 5) != 0) 1652 continue; 1653 - s->sh_entsize = (get_offset(&mod->init_size, s) 1654 | INIT_OFFSET_MASK); 1655 DEBUGP("\t%s\n", secstrings + s->sh_name); 1656 }
··· 1578 return ret; 1579 } 1580 1581 + /* Additional bytes needed by arch in front of individual sections */ 1582 + unsigned int __weak arch_mod_section_prepend(struct module *mod, 1583 + unsigned int section) 1584 + { 1585 + /* default implementation just returns zero */ 1586 + return 0; 1587 + } 1588 + 1589 /* Update size with this section: return offset. */ 1590 + static long get_offset(struct module *mod, unsigned int *size, 1591 + Elf_Shdr *sechdr, unsigned int section) 1592 { 1593 long ret; 1594 1595 + *size += arch_mod_section_prepend(mod, section); 1596 ret = ALIGN(*size, sechdr->sh_addralign ?: 1); 1597 *size = ret + sechdr->sh_size; 1598 return ret; ··· 1622 || strncmp(secstrings + s->sh_name, 1623 ".init", 5) == 0) 1624 continue; 1625 + s->sh_entsize = get_offset(mod, &mod->core_size, s, i); 1626 DEBUGP("\t%s\n", secstrings + s->sh_name); 1627 } 1628 if (m == 0) ··· 1640 || strncmp(secstrings + s->sh_name, 1641 ".init", 5) != 0) 1642 continue; 1643 + s->sh_entsize = (get_offset(mod, &mod->init_size, s, i) 1644 | INIT_OFFSET_MASK); 1645 DEBUGP("\t%s\n", secstrings + s->sh_name); 1646 }