Commit 74f3ae743427b87e43b5cb9f4257021ae8ad4267

Authored by Linus Torvalds

Merge branch 'module' of git://git.kernel.org/pub/scm/linux/kernel/git/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

Showing 21 changed files Side-by-side Diff

arch/arm/kernel/armksyms.c
... ... @@ -48,27 +48,7 @@
48 48 extern void __aeabi_ulcmp(void);
49 49  
50 50 extern void fpundefinstr(void);
51   -extern void fp_enter(void);
52 51  
53   -/*
54   - * This has a special calling convention; it doesn't
55   - * modify any of the usual registers, except for LR.
56   - */
57   -#define EXPORT_CRC_ALIAS(sym) __CRC_SYMBOL(sym, "")
58   -
59   -#define EXPORT_SYMBOL_ALIAS(sym,orig) \
60   - EXPORT_CRC_ALIAS(sym) \
61   - static const struct kernel_symbol __ksymtab_##sym \
62   - __used __attribute__((section("__ksymtab"))) = \
63   - { (unsigned long)&orig, #sym };
64   -
65   -/*
66   - * floating point math emulator support.
67   - * These symbols will never change their calling convention...
68   - */
69   -EXPORT_SYMBOL_ALIAS(kern_fp_enter,fp_enter);
70   -EXPORT_SYMBOL_ALIAS(fp_printk,printk);
71   -EXPORT_SYMBOL_ALIAS(fp_send_sig,send_sig);
72 52  
73 53 EXPORT_SYMBOL(__backtrace);
74 54  
arch/arm/kernel/vmlinux.lds.S
... ... @@ -65,11 +65,11 @@
65 65 __init_end = .;
66 66 #endif
67 67  
68   - /DISCARD/ : { /* Exit code and data */
69   - EXIT_TEXT
70   - EXIT_DATA
71   - *(.exitcall.exit)
72   - *(.discard)
  68 + /*
  69 + * unwind exit sections must be discarded before the rest of the
  70 + * unwind sections get included.
  71 + */
  72 + /DISCARD/ : {
73 73 *(.ARM.exidx.exit.text)
74 74 *(.ARM.extab.exit.text)
75 75 #ifndef CONFIG_HOTPLUG_CPU
... ... @@ -238,6 +238,9 @@
238 238  
239 239 STABS_DEBUG
240 240 .comment 0 : { *(.comment) }
  241 +
  242 + /* Default discards */
  243 + DISCARDS
241 244 }
242 245  
243 246 /*
arch/blackfin/Kconfig
... ... @@ -5,6 +5,10 @@
5 5  
6 6 mainmenu "Blackfin Kernel Configuration"
7 7  
  8 +config SYMBOL_PREFIX
  9 + string
  10 + default "_"
  11 +
8 12 config MMU
9 13 def_bool n
10 14  
arch/blackfin/include/asm/module.h
... ... @@ -7,8 +7,6 @@
7 7 #ifndef _ASM_BFIN_MODULE_H
8 8 #define _ASM_BFIN_MODULE_H
9 9  
10   -#define MODULE_SYMBOL_PREFIX "_"
11   -
12 10 #define Elf_Shdr Elf32_Shdr
13 11 #define Elf_Sym Elf32_Sym
14 12 #define Elf_Ehdr Elf32_Ehdr
arch/blackfin/kernel/vmlinux.lds.S
... ... @@ -4,8 +4,6 @@
4 4 * Licensed under the GPL-2 or later
5 5 */
6 6  
7   -#define VMLINUX_SYMBOL(_sym_) _##_sym_
8   -
9 7 #include <asm-generic/vmlinux.lds.h>
10 8 #include <asm/mem_map.h>
11 9 #include <asm/page.h>
... ... @@ -10,6 +10,10 @@
10 10 default y
11 11 select HAVE_IDE
12 12  
  13 +config SYMBOL_PREFIX
  14 + string
  15 + default "_"
  16 +
13 17 config MMU
14 18 bool
15 19 default n
arch/h8300/include/asm/module.h
... ... @@ -8,7 +8,5 @@
8 8 #define Elf_Sym Elf32_Sym
9 9 #define Elf_Ehdr Elf32_Ehdr
10 10  
11   -#define MODULE_SYMBOL_PREFIX "_"
12   -
13 11 #endif /* _ASM_H8/300_MODULE_H */
arch/h8300/kernel/vmlinux.lds.S
1   -#define VMLINUX_SYMBOL(_sym_) _##_sym_
2 1 #include <asm-generic/vmlinux.lds.h>
3 2 #include <asm/page.h>
4 3  
arch/powerpc/include/asm/module.h
... ... @@ -87,6 +87,11 @@
87 87 void sort_ex_table(struct exception_table_entry *start,
88 88 struct exception_table_entry *finish);
89 89  
  90 +#ifdef CONFIG_MODVERSIONS
  91 +#define ARCH_RELOCATES_KCRCTAB
  92 +
  93 +extern const unsigned long reloc_start[];
  94 +#endif
90 95 #endif /* __KERNEL__ */
91 96 #endif /* _ASM_POWERPC_MODULE_H */
arch/powerpc/kernel/vmlinux.lds.S
... ... @@ -38,6 +38,9 @@
38 38 #endif
39 39 SECTIONS
40 40 {
  41 + . = 0;
  42 + reloc_start = .;
  43 +
41 44 . = KERNELBASE;
42 45  
43 46 /*
arch/sparc/kernel/pci.c
... ... @@ -1064,7 +1064,6 @@
1064 1064  
1065 1065 return (device_mask & dma_addr_mask) == dma_addr_mask;
1066 1066 }
1067   -EXPORT_SYMBOL(pci_dma_supported);
1068 1067  
1069 1068 void pci_resource_to_user(const struct pci_dev *pdev, int bar,
1070 1069 const struct resource *rp, resource_size_t *start,
arch/sparc/kernel/sparc_ksyms_64.c
... ... @@ -38,18 +38,6 @@
38 38 EXPORT_SYMBOL(sun4v_niagara2_getperf);
39 39 EXPORT_SYMBOL(sun4v_niagara2_setperf);
40 40  
41   -#ifdef CONFIG_PCI
42   -/* inline functions in asm/pci_64.h */
43   -EXPORT_SYMBOL(pci_alloc_consistent);
44   -EXPORT_SYMBOL(pci_free_consistent);
45   -EXPORT_SYMBOL(pci_map_single);
46   -EXPORT_SYMBOL(pci_unmap_single);
47   -EXPORT_SYMBOL(pci_map_sg);
48   -EXPORT_SYMBOL(pci_unmap_sg);
49   -EXPORT_SYMBOL(pci_dma_sync_single_for_cpu);
50   -EXPORT_SYMBOL(pci_dma_sync_sg_for_cpu);
51   -#endif
52   -
53 41 /* Exporting a symbol from /init/main.c */
54 42 EXPORT_SYMBOL(saved_command_line);
arch/x86/kernel/x8664_ksyms_64.c
... ... @@ -56,5 +56,7 @@
56 56  
57 57 EXPORT_SYMBOL(empty_zero_page);
58 58 EXPORT_SYMBOL(init_level4_pgt);
59   -EXPORT_SYMBOL(load_gs_index);
  59 +#ifndef CONFIG_PARAVIRT
  60 +EXPORT_SYMBOL(native_load_gs_index);
  61 +#endif
include/asm-generic/vmlinux.lds.h
... ... @@ -52,8 +52,12 @@
52 52 #define LOAD_OFFSET 0
53 53 #endif
54 54  
55   -#ifndef VMLINUX_SYMBOL
56   -#define VMLINUX_SYMBOL(_sym_) _sym_
  55 +#ifndef SYMBOL_PREFIX
  56 +#define VMLINUX_SYMBOL(sym) sym
  57 +#else
  58 +#define PASTE2(x,y) x##y
  59 +#define PASTE(x,y) PASTE2(x,y)
  60 +#define VMLINUX_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym)
57 61 #endif
58 62  
59 63 /* Align . to a 8 byte boundary equals to maximum function alignment. */
include/linux/module.h
... ... @@ -25,8 +25,10 @@
25 25 /* Not Yet Implemented */
26 26 #define MODULE_SUPPORTED_DEVICE(name)
27 27  
28   -/* some toolchains uses a `_' prefix for all user symbols */
29   -#ifndef MODULE_SYMBOL_PREFIX
  28 +/* Some toolchains use a `_' prefix for all user symbols. */
  29 +#ifdef CONFIG_SYMBOL_PREFIX
  30 +#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
  31 +#else
30 32 #define MODULE_SYMBOL_PREFIX ""
31 33 #endif
32 34  
... ... @@ -880,11 +880,23 @@
880 880 }
881 881  
882 882 #ifdef CONFIG_MODVERSIONS
  883 +/* If the arch applies (non-zero) relocations to kernel kcrctab, unapply it. */
  884 +static unsigned long maybe_relocated(unsigned long crc,
  885 + const struct module *crc_owner)
  886 +{
  887 +#ifdef ARCH_RELOCATES_KCRCTAB
  888 + if (crc_owner == NULL)
  889 + return crc - (unsigned long)reloc_start;
  890 +#endif
  891 + return crc;
  892 +}
  893 +
883 894 static int check_version(Elf_Shdr *sechdrs,
884 895 unsigned int versindex,
885 896 const char *symname,
886 897 struct module *mod,
887   - const unsigned long *crc)
  898 + const unsigned long *crc,
  899 + const struct module *crc_owner)
888 900 {
889 901 unsigned int i, num_versions;
890 902 struct modversion_info *versions;
891 903  
... ... @@ -905,10 +917,10 @@
905 917 if (strcmp(versions[i].name, symname) != 0)
906 918 continue;
907 919  
908   - if (versions[i].crc == *crc)
  920 + if (versions[i].crc == maybe_relocated(*crc, crc_owner))
909 921 return 1;
910 922 DEBUGP("Found checksum %lX vs module %lX\n",
911   - *crc, versions[i].crc);
  923 + maybe_relocated(*crc, crc_owner), versions[i].crc);
912 924 goto bad_version;
913 925 }
914 926  
... ... @@ -931,7 +943,8 @@
931 943 if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
932 944 &crc, true, false))
933 945 BUG();
934   - return check_version(sechdrs, versindex, "module_layout", mod, crc);
  946 + return check_version(sechdrs, versindex, "module_layout", mod, crc,
  947 + NULL);
935 948 }
936 949  
937 950 /* First part is kernel version, which we ignore if module has crcs. */
... ... @@ -949,7 +962,8 @@
949 962 unsigned int versindex,
950 963 const char *symname,
951 964 struct module *mod,
952   - const unsigned long *crc)
  965 + const unsigned long *crc,
  966 + const struct module *crc_owner)
953 967 {
954 968 return 1;
955 969 }
... ... @@ -984,8 +998,8 @@
984 998 /* use_module can fail due to OOM,
985 999 or module initialization or unloading */
986 1000 if (sym) {
987   - if (!check_version(sechdrs, versindex, name, mod, crc) ||
988   - !use_module(mod, owner))
  1001 + if (!check_version(sechdrs, versindex, name, mod, crc, owner)
  1002 + || !use_module(mod, owner))
989 1003 sym = NULL;
990 1004 }
991 1005 return sym;
scripts/Makefile.lib
... ... @@ -127,6 +127,11 @@
127 127 $(CFLAGS_GCOV))
128 128 endif
129 129  
  130 +ifdef CONFIG_SYMBOL_PREFIX
  131 +_cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
  132 +endif
  133 +
  134 +
130 135 # If building the kernel in a separate objtree expand all occurrences
131 136 # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
132 137  
scripts/mod/Makefile
... ... @@ -8,7 +8,7 @@
8 8 $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
9 9  
10 10 quiet_cmd_elfconfig = MKELF $@
11   - cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@
  11 + cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@
12 12  
13 13 $(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
14 14 $(call if_changed,elfconfig)
scripts/mod/mk_elfconfig.c
... ... @@ -9,9 +9,6 @@
9 9 unsigned char ei[EI_NIDENT];
10 10 union { short s; char c[2]; } endian_test;
11 11  
12   - if (argc != 2) {
13   - fprintf(stderr, "Error: no arch\n");
14   - }
15 12 if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
16 13 fprintf(stderr, "Error: input truncated\n");
17 14 return 1;
... ... @@ -54,12 +51,6 @@
54 51 printf("#define HOST_ELFDATA ELFDATA2LSB\n");
55 52 else
56 53 exit(1);
57   -
58   - if ((strcmp(argv[1], "h8300") == 0)
59   - || (strcmp(argv[1], "blackfin") == 0))
60   - printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
61   - else
62   - printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
63 54  
64 55 return 0;
65 56 }
scripts/mod/modpost.c
... ... @@ -15,8 +15,17 @@
15 15 #include <stdio.h>
16 16 #include <ctype.h>
17 17 #include "modpost.h"
  18 +#include "../../include/linux/autoconf.h"
18 19 #include "../../include/linux/license.h"
19 20  
  21 +/* Some toolchains use a `_' prefix for all user symbols. */
  22 +#ifdef CONFIG_SYMBOL_PREFIX
  23 +#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
  24 +#else
  25 +#define MODULE_SYMBOL_PREFIX ""
  26 +#endif
  27 +
  28 +
20 29 /* Are we using CONFIG_MODVERSIONS? */
21 30 int modversions = 0;
22 31 /* Warn about undefined symbols? (do so if we have vmlinux) */
... ... @@ -451,8 +460,6 @@
451 460 info->export_unused_gpl_sec = i;
452 461 else if (strcmp(secname, "__ksymtab_gpl_future") == 0)
453 462 info->export_gpl_future_sec = i;
454   - else if (strcmp(secname, "__markers_strings") == 0)
455   - info->markers_strings_sec = i;
456 463  
457 464 if (sechdrs[i].sh_type != SHT_SYMTAB)
458 465 continue;
... ... @@ -515,7 +522,7 @@
515 522 break;
516 523 case SHN_ABS:
517 524 /* CRC'd symbol */
518   - if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
  525 + if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
519 526 crc = (unsigned int) sym->st_value;
520 527 sym_update_crc(symname + strlen(CRC_PFX), mod, crc,
521 528 export);
... ... @@ -559,7 +566,7 @@
559 566 break;
560 567 default:
561 568 /* All exported symbols */
562   - if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
  569 + if (strncmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
563 570 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod,
564 571 export);
565 572 }
... ... @@ -1509,62 +1516,6 @@
1509 1516 }
1510 1517 }
1511 1518  
1512   -static void get_markers(struct elf_info *info, struct module *mod)
1513   -{
1514   - const Elf_Shdr *sh = &info->sechdrs[info->markers_strings_sec];
1515   - const char *strings = (const char *) info->hdr + sh->sh_offset;
1516   - const Elf_Sym *sym, *first_sym, *last_sym;
1517   - size_t n;
1518   -
1519   - if (!info->markers_strings_sec)
1520   - return;
1521   -
1522   - /*
1523   - * First count the strings. We look for all the symbols defined
1524   - * in the __markers_strings section named __mstrtab_*. For
1525   - * these local names, the compiler puts a random .NNN suffix on,
1526   - * so the names don't correspond exactly.
1527   - */
1528   - first_sym = last_sym = NULL;
1529   - n = 0;
1530   - for (sym = info->symtab_start; sym < info->symtab_stop; sym++)
1531   - if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT &&
1532   - sym->st_shndx == info->markers_strings_sec &&
1533   - !strncmp(info->strtab + sym->st_name,
1534   - "__mstrtab_", sizeof "__mstrtab_" - 1)) {
1535   - if (first_sym == NULL)
1536   - first_sym = sym;
1537   - last_sym = sym;
1538   - ++n;
1539   - }
1540   -
1541   - if (n == 0)
1542   - return;
1543   -
1544   - /*
1545   - * Now collect each name and format into a line for the output.
1546   - * Lines look like:
1547   - * marker_name vmlinux marker %s format %d
1548   - * The format string after the second \t can use whitespace.
1549   - */
1550   - mod->markers = NOFAIL(malloc(sizeof mod->markers[0] * n));
1551   - mod->nmarkers = n;
1552   -
1553   - n = 0;
1554   - for (sym = first_sym; sym <= last_sym; sym++)
1555   - if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT &&
1556   - sym->st_shndx == info->markers_strings_sec &&
1557   - !strncmp(info->strtab + sym->st_name,
1558   - "__mstrtab_", sizeof "__mstrtab_" - 1)) {
1559   - const char *name = strings + sym->st_value;
1560   - const char *fmt = strchr(name, '\0') + 1;
1561   - char *line = NULL;
1562   - asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
1563   - NOFAIL(line);
1564   - mod->markers[n++] = line;
1565   - }
1566   -}
1567   -
1568 1519 static void read_symbols(char *modname)
1569 1520 {
1570 1521 const char *symname;
... ... @@ -1620,8 +1571,6 @@
1620 1571 get_src_version(modname, mod->srcversion,
1621 1572 sizeof(mod->srcversion)-1);
1622 1573  
1623   - get_markers(&info, mod);
1624   -
1625 1574 parse_elf_finish(&info);
1626 1575  
1627 1576 /* Our trick to get versioning for module struct etc. - it's
... ... @@ -1976,96 +1925,6 @@
1976 1925 write_if_changed(&buf, fname);
1977 1926 }
1978 1927  
1979   -static void add_marker(struct module *mod, const char *name, const char *fmt)
1980   -{
1981   - char *line = NULL;
1982   - asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
1983   - NOFAIL(line);
1984   -
1985   - mod->markers = NOFAIL(realloc(mod->markers, ((mod->nmarkers + 1) *
1986   - sizeof mod->markers[0])));
1987   - mod->markers[mod->nmarkers++] = line;
1988   -}
1989   -
1990   -static void read_markers(const char *fname)
1991   -{
1992   - unsigned long size, pos = 0;
1993   - void *file = grab_file(fname, &size);
1994   - char *line;
1995   -
1996   - if (!file) /* No old markers, silently ignore */
1997   - return;
1998   -
1999   - while ((line = get_next_line(&pos, file, size))) {
2000   - char *marker, *modname, *fmt;
2001   - struct module *mod;
2002   -
2003   - marker = line;
2004   - modname = strchr(marker, '\t');
2005   - if (!modname)
2006   - goto fail;
2007   - *modname++ = '\0';
2008   - fmt = strchr(modname, '\t');
2009   - if (!fmt)
2010   - goto fail;
2011   - *fmt++ = '\0';
2012   - if (*marker == '\0' || *modname == '\0')
2013   - goto fail;
2014   -
2015   - mod = find_module(modname);
2016   - if (!mod) {
2017   - mod = new_module(modname);
2018   - mod->skip = 1;
2019   - }
2020   - if (is_vmlinux(modname)) {
2021   - have_vmlinux = 1;
2022   - mod->skip = 0;
2023   - }
2024   -
2025   - if (!mod->skip)
2026   - add_marker(mod, marker, fmt);
2027   - }
2028   - release_file(file, size);
2029   - return;
2030   -fail:
2031   - fatal("parse error in markers list file\n");
2032   -}
2033   -
2034   -static int compare_strings(const void *a, const void *b)
2035   -{
2036   - return strcmp(*(const char **) a, *(const char **) b);
2037   -}
2038   -
2039   -static void write_markers(const char *fname)
2040   -{
2041   - struct buffer buf = { };
2042   - struct module *mod;
2043   - size_t i;
2044   -
2045   - for (mod = modules; mod; mod = mod->next)
2046   - if ((!external_module || !mod->skip) && mod->markers != NULL) {
2047   - /*
2048   - * Sort the strings so we can skip duplicates when
2049   - * we write them out.
2050   - */
2051   - qsort(mod->markers, mod->nmarkers,
2052   - sizeof mod->markers[0], &compare_strings);
2053   - for (i = 0; i < mod->nmarkers; ++i) {
2054   - char *line = mod->markers[i];
2055   - buf_write(&buf, line, strlen(line));
2056   - while (i + 1 < mod->nmarkers &&
2057   - !strcmp(mod->markers[i],
2058   - mod->markers[i + 1]))
2059   - free(mod->markers[i++]);
2060   - free(mod->markers[i]);
2061   - }
2062   - free(mod->markers);
2063   - mod->markers = NULL;
2064   - }
2065   -
2066   - write_if_changed(&buf, fname);
2067   -}
2068   -
2069 1928 struct ext_sym_list {
2070 1929 struct ext_sym_list *next;
2071 1930 const char *file;
... ... @@ -2077,8 +1936,6 @@
2077 1936 struct buffer buf = { };
2078 1937 char *kernel_read = NULL, *module_read = NULL;
2079 1938 char *dump_write = NULL;
2080   - char *markers_read = NULL;
2081   - char *markers_write = NULL;
2082 1939 int opt;
2083 1940 int err;
2084 1941 struct ext_sym_list *extsym_iter;
... ... @@ -2122,12 +1979,6 @@
2122 1979 case 'w':
2123 1980 warn_unresolved = 1;
2124 1981 break;
2125   - case 'M':
2126   - markers_write = optarg;
2127   - break;
2128   - case 'K':
2129   - markers_read = optarg;
2130   - break;
2131 1982 default:
2132 1983 exit(1);
2133 1984 }
... ... @@ -2181,12 +2032,6 @@
2181 2032 "To see full details build your kernel with:\n"
2182 2033 "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n",
2183 2034 sec_mismatch_count);
2184   -
2185   - if (markers_read)
2186   - read_markers(markers_read);
2187   -
2188   - if (markers_write)
2189   - write_markers(markers_write);
2190 2035  
2191 2036 return err;
2192 2037 }
scripts/mod/modpost.h
... ... @@ -112,8 +112,6 @@
112 112 int has_init;
113 113 int has_cleanup;
114 114 struct buffer dev_table_buf;
115   - char **markers;
116   - size_t nmarkers;
117 115 char srcversion[25];
118 116 };
119 117  
... ... @@ -128,7 +126,6 @@
128 126 Elf_Section export_gpl_sec;
129 127 Elf_Section export_unused_gpl_sec;
130 128 Elf_Section export_gpl_future_sec;
131   - Elf_Section markers_strings_sec;
132 129 const char *strtab;
133 130 char *modinfo;
134 131 unsigned int modinfo_len;