Skip to content

Commit

Permalink
Merge branch 'module' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/rusty/linux-2.6-for-linus

* 'module' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
  modpost: fix segfault with short symbol names
  module: handle ppc64 relocating kcrctabs when CONFIG_RELOCATABLE=y
  Kbuild: clear marker out of modpost
  module: make MODULE_SYMBOL_PREFIX into a CONFIG option
  ARM: unexport symbols used to implement floating point emulation
  ARM: use unified discard definition in linker script
  x86: don't export inline function
  sparc64: don't export static inline pci_ functions
  • Loading branch information
Linus Torvalds committed Dec 16, 2009
2 parents d8bef0b + 8d99513 commit 74f3ae7
Show file tree
Hide file tree
Showing 21 changed files with 75 additions and 236 deletions.
20 changes: 0 additions & 20 deletions arch/arm/kernel/armksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,7 @@ extern void __aeabi_uidivmod(void);
extern void __aeabi_ulcmp(void);

extern void fpundefinstr(void);
extern void fp_enter(void);

/*
* This has a special calling convention; it doesn't
* modify any of the usual registers, except for LR.
*/
#define EXPORT_CRC_ALIAS(sym) __CRC_SYMBOL(sym, "")

#define EXPORT_SYMBOL_ALIAS(sym,orig) \
EXPORT_CRC_ALIAS(sym) \
static const struct kernel_symbol __ksymtab_##sym \
__used __attribute__((section("__ksymtab"))) = \
{ (unsigned long)&orig, #sym };

/*
* floating point math emulator support.
* These symbols will never change their calling convention...
*/
EXPORT_SYMBOL_ALIAS(kern_fp_enter,fp_enter);
EXPORT_SYMBOL_ALIAS(fp_printk,printk);
EXPORT_SYMBOL_ALIAS(fp_send_sig,send_sig);

EXPORT_SYMBOL(__backtrace);

Expand Down
13 changes: 8 additions & 5 deletions arch/arm/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ SECTIONS
__init_end = .;
#endif

/DISCARD/ : { /* Exit code and data */
EXIT_TEXT
EXIT_DATA
*(.exitcall.exit)
*(.discard)
/*
* unwind exit sections must be discarded before the rest of the
* unwind sections get included.
*/
/DISCARD/ : {
*(.ARM.exidx.exit.text)
*(.ARM.extab.exit.text)
#ifndef CONFIG_HOTPLUG_CPU
Expand Down Expand Up @@ -238,6 +238,9 @@ SECTIONS

STABS_DEBUG
.comment 0 : { *(.comment) }

/* Default discards */
DISCARDS
}

/*
Expand Down
4 changes: 4 additions & 0 deletions arch/blackfin/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

mainmenu "Blackfin Kernel Configuration"

config SYMBOL_PREFIX
string
default "_"

config MMU
def_bool n

Expand Down
2 changes: 0 additions & 2 deletions arch/blackfin/include/asm/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#ifndef _ASM_BFIN_MODULE_H
#define _ASM_BFIN_MODULE_H

#define MODULE_SYMBOL_PREFIX "_"

#define Elf_Shdr Elf32_Shdr
#define Elf_Sym Elf32_Sym
#define Elf_Ehdr Elf32_Ehdr
Expand Down
2 changes: 0 additions & 2 deletions arch/blackfin/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* Licensed under the GPL-2 or later
*/

#define VMLINUX_SYMBOL(_sym_) _##_sym_

#include <asm-generic/vmlinux.lds.h>
#include <asm/mem_map.h>
#include <asm/page.h>
Expand Down
4 changes: 4 additions & 0 deletions arch/h8300/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ config H8300
default y
select HAVE_IDE

config SYMBOL_PREFIX
string
default "_"

config MMU
bool
default n
Expand Down
2 changes: 0 additions & 2 deletions arch/h8300/include/asm/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ struct mod_arch_specific { };
#define Elf_Sym Elf32_Sym
#define Elf_Ehdr Elf32_Ehdr

#define MODULE_SYMBOL_PREFIX "_"

#endif /* _ASM_H8/300_MODULE_H */
1 change: 0 additions & 1 deletion arch/h8300/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define VMLINUX_SYMBOL(_sym_) _##_sym_
#include <asm-generic/vmlinux.lds.h>
#include <asm/page.h>

Expand Down
5 changes: 5 additions & 0 deletions arch/powerpc/include/asm/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,10 @@ struct exception_table_entry;
void sort_ex_table(struct exception_table_entry *start,
struct exception_table_entry *finish);

#ifdef CONFIG_MODVERSIONS
#define ARCH_RELOCATES_KCRCTAB

extern const unsigned long reloc_start[];
#endif
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_MODULE_H */
3 changes: 3 additions & 0 deletions arch/powerpc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jiffies = jiffies_64 + 4;
#endif
SECTIONS
{
. = 0;
reloc_start = .;

. = KERNELBASE;

/*
Expand Down
1 change: 0 additions & 1 deletion arch/sparc/kernel/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,6 @@ int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask)

return (device_mask & dma_addr_mask) == dma_addr_mask;
}
EXPORT_SYMBOL(pci_dma_supported);

void pci_resource_to_user(const struct pci_dev *pdev, int bar,
const struct resource *rp, resource_size_t *start,
Expand Down
12 changes: 0 additions & 12 deletions arch/sparc/kernel/sparc_ksyms_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,5 @@ EXPORT_SYMBOL(sun4v_niagara_setperf);
EXPORT_SYMBOL(sun4v_niagara2_getperf);
EXPORT_SYMBOL(sun4v_niagara2_setperf);

#ifdef CONFIG_PCI
/* inline functions in asm/pci_64.h */
EXPORT_SYMBOL(pci_alloc_consistent);
EXPORT_SYMBOL(pci_free_consistent);
EXPORT_SYMBOL(pci_map_single);
EXPORT_SYMBOL(pci_unmap_single);
EXPORT_SYMBOL(pci_map_sg);
EXPORT_SYMBOL(pci_unmap_sg);
EXPORT_SYMBOL(pci_dma_sync_single_for_cpu);
EXPORT_SYMBOL(pci_dma_sync_sg_for_cpu);
#endif

/* Exporting a symbol from /init/main.c */
EXPORT_SYMBOL(saved_command_line);
4 changes: 3 additions & 1 deletion arch/x86/kernel/x8664_ksyms_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ EXPORT_SYMBOL(__memcpy);

EXPORT_SYMBOL(empty_zero_page);
EXPORT_SYMBOL(init_level4_pgt);
EXPORT_SYMBOL(load_gs_index);
#ifndef CONFIG_PARAVIRT
EXPORT_SYMBOL(native_load_gs_index);
#endif
8 changes: 6 additions & 2 deletions include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@
#define LOAD_OFFSET 0
#endif

#ifndef VMLINUX_SYMBOL
#define VMLINUX_SYMBOL(_sym_) _sym_
#ifndef SYMBOL_PREFIX
#define VMLINUX_SYMBOL(sym) sym
#else
#define PASTE2(x,y) x##y
#define PASTE(x,y) PASTE2(x,y)
#define VMLINUX_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym)
#endif

/* Align . to a 8 byte boundary equals to maximum function alignment. */
Expand Down
6 changes: 4 additions & 2 deletions include/linux/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
/* Not Yet Implemented */
#define MODULE_SUPPORTED_DEVICE(name)

/* some toolchains uses a `_' prefix for all user symbols */
#ifndef MODULE_SYMBOL_PREFIX
/* Some toolchains use a `_' prefix for all user symbols. */
#ifdef CONFIG_SYMBOL_PREFIX
#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
#else
#define MODULE_SYMBOL_PREFIX ""
#endif

Expand Down
28 changes: 21 additions & 7 deletions kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,11 +880,23 @@ static int try_to_force_load(struct module *mod, const char *reason)
}

#ifdef CONFIG_MODVERSIONS
/* If the arch applies (non-zero) relocations to kernel kcrctab, unapply it. */
static unsigned long maybe_relocated(unsigned long crc,
const struct module *crc_owner)
{
#ifdef ARCH_RELOCATES_KCRCTAB
if (crc_owner == NULL)
return crc - (unsigned long)reloc_start;
#endif
return crc;
}

static int check_version(Elf_Shdr *sechdrs,
unsigned int versindex,
const char *symname,
struct module *mod,
const unsigned long *crc)
const unsigned long *crc,
const struct module *crc_owner)
{
unsigned int i, num_versions;
struct modversion_info *versions;
Expand All @@ -905,10 +917,10 @@ static int check_version(Elf_Shdr *sechdrs,
if (strcmp(versions[i].name, symname) != 0)
continue;

if (versions[i].crc == *crc)
if (versions[i].crc == maybe_relocated(*crc, crc_owner))
return 1;
DEBUGP("Found checksum %lX vs module %lX\n",
*crc, versions[i].crc);
maybe_relocated(*crc, crc_owner), versions[i].crc);
goto bad_version;
}

Expand All @@ -931,7 +943,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
&crc, true, false))
BUG();
return check_version(sechdrs, versindex, "module_layout", mod, crc);
return check_version(sechdrs, versindex, "module_layout", mod, crc,
NULL);
}

/* First part is kernel version, which we ignore if module has crcs. */
Expand All @@ -949,7 +962,8 @@ static inline int check_version(Elf_Shdr *sechdrs,
unsigned int versindex,
const char *symname,
struct module *mod,
const unsigned long *crc)
const unsigned long *crc,
const struct module *crc_owner)
{
return 1;
}
Expand Down Expand Up @@ -984,8 +998,8 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs,
/* use_module can fail due to OOM,
or module initialization or unloading */
if (sym) {
if (!check_version(sechdrs, versindex, name, mod, crc) ||
!use_module(mod, owner))
if (!check_version(sechdrs, versindex, name, mod, crc, owner)
|| !use_module(mod, owner))
sym = NULL;
}
return sym;
Expand Down
5 changes: 5 additions & 0 deletions scripts/Makefile.lib
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ _c_flags += $(if $(patsubst n%,, \
$(CFLAGS_GCOV))
endif

ifdef CONFIG_SYMBOL_PREFIX
_cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
endif


# If building the kernel in a separate objtree expand all occurrences
# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').

Expand Down
2 changes: 1 addition & 1 deletion scripts/mod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ modpost-objs := modpost.o file2alias.o sumversion.o
$(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h

quiet_cmd_elfconfig = MKELF $@
cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@
cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@

$(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
$(call if_changed,elfconfig)
Expand Down
9 changes: 0 additions & 9 deletions scripts/mod/mk_elfconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ main(int argc, char **argv)
unsigned char ei[EI_NIDENT];
union { short s; char c[2]; } endian_test;

if (argc != 2) {
fprintf(stderr, "Error: no arch\n");
}
if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
fprintf(stderr, "Error: input truncated\n");
return 1;
Expand Down Expand Up @@ -55,12 +52,6 @@ main(int argc, char **argv)
else
exit(1);

if ((strcmp(argv[1], "h8300") == 0)
|| (strcmp(argv[1], "blackfin") == 0))
printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
else
printf("#define MODULE_SYMBOL_PREFIX \"\"\n");

return 0;
}

Loading

0 comments on commit 74f3ae7

Please sign in to comment.