2006-02-17 21:49:07

by Sam Ravnborg

[permalink] [raw]
Subject: kbuild:

I have moved the functionality of reference_init + reference_discarded
to modpost to secure a much wider use of this check.
Patch is included below.
Advantage is that the check is runn for each and every kernel build.

The check may still pont at false positive - I will let time decide.
So far the warnings I have chased was all positives so I am pretty
confident that keeping the checks in modpost is good.

Compared to the perl scripts more issues are catched since
single file modules are checked too.

This is tested only on x86_64 - I expect a few suprises when tried on
other architectures but hopefully -mm exposure will soon fix those.

In a follow-up mail I will post the result of a run with this patch.

Note - patch not yet pushed to the kbuild tree - will see any feedback
first.

Sam


diff-tree 5b07cab879c1f94f0217ec0f69bc88c8a42c5943 (from 275074573ca9ebffed3ce16817782279afbcfe08)
Author: Sam Ravnborg <[email protected]>
Date: Fri Feb 17 22:42:02 2006 +0100

kbuild: check for section mismatch during modpost stage

Section mismatch is identified as references to .init*
sections from non .init sections. And likewise references
to .exit.* sections outside .exit sections.

.init.* sections are discarded after a module is initialized
and references to .init.* sections are oops candidates.
.exit.* sections are discarded when a module is built-in and
thus references to .exit are also oops candidates.

The checks were possible to do using 'make buildcheck' which
called the two perl scripts: reference_discarded.pl and
reference_init.pl. This patch just moves the same functionality
inside modpost and the scripts are then obsoleted.
They will though be kept for a while so users can do double
checks - but note that some .o files are skipped by the perl scripts
so result is not 1:1.
All credit for the concept goes to Keith Owens who implemented
the original perl scrips - this patch just moves it to modpost.

Compared to the perl script the implmentation in modpost will be run
for each kernel build - thus catching the error much sooner, but
the downside is that the individual .o file are not always identified.

Signed-off-by: Sam Ravnborg <[email protected]>

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index d901095..a7360c3 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -449,10 +449,266 @@ static char *get_modinfo(void *modinfo,
return p + taglen + 1;
}
return NULL;
}

+/*
+ * Find symbols before or equal addr and after addr - in the section sec
+ **/
+static void find_symbols_between(struct elf_info *elf, Elf_Addr addr,
+ const char *sec,
+ Elf_Sym **before, Elf_Sym **after)
+{
+ Elf_Sym *sym;
+ Elf_Ehdr *hdr = elf->hdr;
+ Elf_Addr beforediff = ~0;
+ Elf_Addr afterdiff = ~0;
+ const char *secstrings = (void *)hdr +
+ elf->sechdrs[hdr->e_shstrndx].sh_offset;
+
+ *before = NULL;
+ *after = NULL;
+
+ for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
+ const char *symsec;
+
+ if (sym->st_shndx >= SHN_LORESERVE)
+ continue;
+ symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name;
+ if (strcmp(symsec, sec) != 0)
+ continue;
+ if (sym->st_value <= addr) {
+ if ((addr - sym->st_value) < beforediff) {
+ beforediff = addr - sym->st_value;
+ *before = sym;
+ }
+ }
+ else
+ {
+ if ((sym->st_value - addr) < afterdiff) {
+ afterdiff = sym->st_value - addr;
+ *after = sym;
+ }
+ }
+ }
+}
+
+/**
+ * Print a warning about a section mismatch.
+ * Try to find symbols near it so user can find it.
+ **/
+static void warn_sec_mismatch(const char *modname, const char *fromsec,
+ struct elf_info *elf, Elf_Sym *sym, Elf_Rela r)
+{
+ Elf_Sym *before;
+ Elf_Sym *after;
+ Elf_Ehdr *hdr = elf->hdr;
+ Elf_Shdr *sechdrs = elf->sechdrs;
+ const char *secstrings = (void *)hdr +
+ sechdrs[hdr->e_shstrndx].sh_offset;
+ const char *secname = secstrings + sechdrs[sym->st_shndx].sh_name;
+
+ find_symbols_between(elf, r.r_offset, fromsec, &before, &after);
+
+ if (before && after) {
+ warn("%s - Section mismatch: reference to %s from %s "
+ "between '%s' (at offset 0x%lx) and '%s'\n",
+ modname, secname, fromsec,
+ elf->strtab + before->st_name,
+ (long)(r.r_offset - before->st_value),
+ elf->strtab + after->st_name);
+ } else if (before) {
+ warn("%s - Section mismatch: reference to %s from %s "
+ "after '%s' (at offset 0x%lx)\n",
+ modname, secname, fromsec,
+ elf->strtab + before->st_name,
+ (long)(r.r_offset - before->st_value));
+ } else if (after) {
+ warn("%s - Section mismatch: reference to %s from %s "
+ "before '%s' (at offset -0x%lx)\n",
+ modname, secname, fromsec,
+ elf->strtab + before->st_name,
+ (long)(before->st_value - r.r_offset));
+ } else {
+ warn("%s - Section mismatch: reference to %s from %s "
+ "(offset 0x%lx)\n",
+ modname, secname, fromsec, (long)r.r_offset);
+ }
+}
+
+/**
+ * A module includes a number of sections that are discarded
+ * either when loaded or when used as built-in.
+ * For loaded modules all functions marked __init and all data
+ * marked __initdata will be discarded when the module has been intialized.
+ * Likewise for modules used built-in the sections marked __exit
+ * are discarded because __exit marked function are supposed to be called
+ * only when a moduel is unloaded which never happes for built-in modules.
+ * The check_sec_ref() function traverses all relocation records
+ * to find all references to a section that reference a section that will
+ * be discarded and warns about it.
+ **/
+static void check_sec_ref(struct module *mod, const char *modname,
+ struct elf_info *elf,
+ int section(const char*),
+ int section_ref_ok(const char *))
+{
+ int i;
+ Elf_Sym *sym;
+ Elf_Ehdr *hdr = elf->hdr;
+ Elf_Shdr *sechdrs = elf->sechdrs;
+ const char *secstrings = (void *)hdr +
+ sechdrs[hdr->e_shstrndx].sh_offset;
+
+ /* Walk through all sections */
+ for (i = 0; i < hdr->e_shnum; i++) {
+ const char *name = secstrings + sechdrs[i].sh_name +
+ strlen(".rela");
+ /* We want to process only relocation sections and not .init */
+ if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA))
+ continue;
+ Elf_Rela *rela;
+ Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
+ Elf_Rela *stop = (void*)start + sechdrs[i].sh_size;
+
+ for (rela = start; rela < stop; rela++) {
+ Elf_Rela r;
+ const char *secname;
+ r.r_offset = TO_NATIVE(rela->r_offset);
+ r.r_info = TO_NATIVE(rela->r_info);
+ sym = elf->symtab_start + ELF_R_SYM(r.r_info);
+ secname = secstrings + sechdrs[sym->st_shndx].sh_name;
+ /* Skip special sections */
+ if (sym->st_shndx >= SHN_LORESERVE)
+ continue;
+
+ if (section(secname))
+ warn_sec_mismatch(modname, name, elf, sym, r);
+ }
+ }
+}
+
+/**
+ * Functions used only during module init is marked __init and is stored in
+ * a .init.text section. Likewise data is marked __initdata and stored in
+ * a .init.data section.
+ * If this section is one of these sections return 1
+ * See include/linux/init.h for the details
+ **/
+static int init_section(const char *name)
+{
+ if (strcmp(name, ".init") == 0)
+ return 1;
+ if (strncmp(name, ".init.", strlen(".init.")) == 0)
+ return 1;
+ return 0;
+}
+
+/**
+ * Identify sections from which references to a .init section is OK.
+ *
+ * Unfortunately references to read only data that referenced .init
+ * sections had to be excluded. Almost all of these are false
+ * positives, they are created by gcc. The downside of excluding rodata
+ * is that there really are some user references from rodata to
+ * init code, e.g. drivers/video/vgacon.c:
+ *
+ * const struct consw vga_con = {
+ * con_startup: vgacon_startup,
+ *
+ * where vgacon_startup is __init. If you want to wade through the false
+ * positives, take out the check for rodata.
+ **/
+static int init_section_ref_ok(const char *name)
+{
+ const char **s;
+ /* Absolute section names */
+ const char *namelist1[] = {
+ ".init",
+ ".stab",
+ ".rodata",
+ ".text.lock",
+ ".pci_fixup_header",
+ ".pci_fixup_final",
+ ".pdr",
+ "__param",
+ NULL
+ };
+ /* Start of section names */
+ const char *namelist2[] = {
+ ".init.",
+ ".altinstructions",
+ ".eh_frame",
+ ".debug",
+ NULL
+ };
+
+ for (s = namelist1; *s; s++)
+ if (strcmp(*s, name) == 0)
+ return 1;
+ for (s = namelist2; *s; s++)
+ if (strncmp(*s, name, strlen(*s)) == 0)
+ return 1;
+ return 0;
+}
+
+/*
+ * Functions used only during module exit is marked __exit and is stored in
+ * a .exit.text section. Likewise data is marked __exitdata and stored in
+ * a .exit.data section.
+ * If this section is one of these sections return 1
+ * See include/linux/init.h for the details
+ **/
+static int exit_section(const char *name)
+{
+ if (strcmp(name, ".exit.text") == 0)
+ return 1;
+ if (strcmp(name, ".exit.data") == 0)
+ return 1;
+ return 0;
+
+}
+
+/*
+ * Identify sections from which references to a .exit section is OK.
+ *
+ * [OPD] Keith Ownes <[email protected]> commented:
+ * For our future {in}sanity, add a comment that this is the ppc .opd
+ * section, not the ia64 .opd section.
+ * ia64 .opd should not point to discarded sections.
+ **/
+static int exit_section_ref_ok(const char *name)
+{
+ const char **s;
+ /* Absolute section names */
+ const char *namelist1[] = {
+ ".exit.text",
+ ".exit.data",
+ ".init.text",
+ ".opd", /* See comment [OPD] */
+ ".altinstructions",
+ ".pdr",
+ ".exitcall.exit",
+ ".eh_frame",
+ ".stab",
+ NULL
+ };
+ /* Start of section names */
+ const char *namelist2[] = {
+ ".debug",
+ NULL
+ };
+
+ for (s = namelist1; *s; s++)
+ if (strcmp(*s, name) == 0)
+ return 1;
+ for (s = namelist2; *s; s++)
+ if (strncmp(*s, name, strlen(*s)) == 0)
+ return 1;
+ return 0;
+}
+
static void read_symbols(char *modname)
{
const char *symname;
char *version;
struct module *mod;
@@ -474,10 +730,12 @@ static void read_symbols(char *modname)
symname = info.strtab + sym->st_name;

handle_modversions(mod, &info, sym, symname);
handle_moddevtable(mod, &info, sym, symname);
}
+ check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok);
+ check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok);

version = get_modinfo(info.modinfo, info.modinfo_len, "version");
if (version)
maybe_frob_rcs_version(modname, version, info.modinfo,
version - (char *)info.hdr);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index c0de7b9..3b5319d 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -14,21 +14,31 @@
#if KERNEL_ELFCLASS == ELFCLASS32

#define Elf_Ehdr Elf32_Ehdr
#define Elf_Shdr Elf32_Shdr
#define Elf_Sym Elf32_Sym
+#define Elf_Addr Elf32_Addr
+#define Elf_Section Elf32_Section
#define ELF_ST_BIND ELF32_ST_BIND
#define ELF_ST_TYPE ELF32_ST_TYPE

+#define Elf_Rela Elf32_Rela
+#define ELF_R_SYM ELF32_R_SYM
+#define ELF_R_TYPE ELF32_R_TYPE
#else

#define Elf_Ehdr Elf64_Ehdr
#define Elf_Shdr Elf64_Shdr
#define Elf_Sym Elf64_Sym
+#define Elf_Addr Elf64_Addr
+#define Elf_Section Elf64_Section
#define ELF_ST_BIND ELF64_ST_BIND
#define ELF_ST_TYPE ELF64_ST_TYPE

+#define Elf_Rela Elf64_Rela
+#define ELF_R_SYM ELF64_R_SYM
+#define ELF_R_TYPE ELF64_R_TYPE
#endif

#if KERNEL_ELFDATA != HOST_ELFDATA

static inline void __endian(const void *src, void *dest, unsigned int size)


2006-02-17 22:47:30

by Sam Ravnborg

[permalink] [raw]
Subject: kbuild: Section mismatch warnings

Background:
I have introduced a build-time check for section mismatch and it showed
up a great number of warnings.
Below is the result of the run on a 2.6.16-rc1 tree (which my kbuild
tree is based upon) based on a 'make allmodconfig'

159 warnings in 49 different modules

I have included the obvious candidates for the modules in to: but some
are for sure missing and some may be wrong.

Syntax:
The offset refer to the relative offset from the referenced symbol.
So
WARNING: drivers/acpi/asus_acpi.o - Section mismatch: reference to .init.text from .data between 'asus_hotk_driver' (at offset 0xc0) and 'model_conf'
should be read as:

At 0xc0 bytes after asus_hotk_driver there is a reference to a symbol
placed in the section .init.text.

I did not find a way to look up the offending symbol but maybe some elf
expert can help?

In the warning are included both symbol before and after to help when
dealing with one of the many duplicated static symbols.


Several warnings are refereces to module parameters - sound/oss/mad16.o
as the most visible one. I have not yet figured out if this is a false
positive or not. Removing __initdata on the moduleparam variable solves
it, but then this may be the wrong approach.

Sam


WARNING: drivers/acpi/asus_acpi.o - Section mismatch: reference to .init.text from .data between 'asus_hotk_driver' (at offset 0xc0) and 'model_conf'
WARNING: drivers/acpi/processor.o - Section mismatch: reference to .init.data from .text between 'acpi_processor_power_init' (at offset 0x3a) and 'acpi_processor_power_exit'
WARNING: drivers/atm/fore_200e.o - Section mismatch: reference to .init.text from .text between 'fore200e_pca_detect' (at offset 0xd3) and 'fore200e_pca_remove_one'
WARNING: drivers/block/cpqarray.o - Section mismatch: reference to .init.text from .data between 'cpqarray_pci_driver' (at offset 0x20) and 'products'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0x8b) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0xaa) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0xb1) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0xbd) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0xcd) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0xf6) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0x12e) and 'cleanup_module'
WARNING: drivers/char/hw_random.o - Section mismatch: reference to .init.text from .data between 'rng_vendor_ops' (at offset 0x28) and 'rng_lock.0'
WARNING: drivers/char/hw_random.o - Section mismatch: reference to .init.text from .data between 'rng_vendor_ops' (at offset 0x50) and 'rng_lock.0'
WARNING: drivers/char/hw_random.o - Section mismatch: reference to .init.text from .data between 'rng_vendor_ops' (at offset 0x78) and 'rng_lock.0'
WARNING: drivers/char/ip2main.o - Section mismatch: reference to .init.text from .text between 'cleanup_module' (at offset 0xb9) and 'set_irq'
WARNING: drivers/char/ip2main.o - Section mismatch: reference to .init.text from .text between 'ip2_loadmain' (at offset 0x359) and 'ip2_interrupt'
WARNING: drivers/char/ip2main.o - Section mismatch: reference to .init.text from .text between 'ip2_loadmain' (at offset 0x4a0) and 'ip2_interrupt'
WARNING: drivers/char/ip2main.o - Section mismatch: reference to .init.text from .text between 'ip2_loadmain' (at offset 0x7a9) and 'ip2_interrupt'
WARNING: drivers/char/ip2main.o - Section mismatch: reference to .init.text from .text between 'ip2_ipl_ioctl' (at offset 0x26f) and 'ip2_ipl_open'
WARNING: drivers/char/ip2main.o - Section mismatch: reference to .init.text from .text between 'ip2_ipl_ioctl' (at offset 0x285) and 'ip2_ipl_open'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0xe2) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x20d) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x35b) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x3c8) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0x3ea) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0x40d) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0x425) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x665) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x68f) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x694) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x699) and 'cleanup_module'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data from .data between '' (at offset 0x8) and '__param_str_dev3'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data from .data between '' (at offset 0x28) and '__param_str_dev3'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data from .data between '__param_arr_dev2' (at offset 0x8) and '__param_str_dev2'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data from .data between '__param_arr_dev2' (at offset 0x28) and '__param_str_dev2'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data from .data between '__param_arr_dev' (at offset 0x8) and '__param_str_dev'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data from .data between '__param_arr_dev' (at offset 0x28) and '__param_str_dev'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data from .data between '__param_arr_map3' (at offset 0x8) and '__param_str_map3'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data from .data between '__param_arr_map3' (at offset 0x28) and '__param_str_map3'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data from .data between '__param_arr_map2' (at offset 0x8) and '__param_str_map2'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data from .data between '__param_arr_map2' (at offset 0x28) and '__param_str_map2'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data from .data between '__param_arr_map' (at offset 0x8) and '__param_str_map'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data from .data between '__param_arr_map' (at offset 0x28) and '__param_str_map'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data from .data between '' (at offset 0x8) and '__param_str_map3'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data from .data between '' (at offset 0x28) and '__param_str_map3'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data from .data between '__param_arr_map2' (at offset 0x8) and '__param_str_map2'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data from .data between '__param_arr_map2' (at offset 0x28) and '__param_str_map2'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data from .data between '__param_arr_map' (at offset 0x8) and '__param_str_map'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data from .data between '__param_arr_map' (at offset 0x28) and '__param_str_map'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x2ed) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x2fa) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x314) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x32e) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x348) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x352) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x366) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x370) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x37a) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x384) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x38e) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x398) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'checkcard' (at offset 0x3a2) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'Diva_card_msg' (at offset 0xd2) and 'ph_command'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'NETjet_S_card_msg' (at offset 0x4a) and 'NETjet_ReadIC'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'NETjet_U_card_msg' (at offset 0x4d) and 'ph_command'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'NETjet_U_card_msg' (at offset 0x5d) and 'ph_command'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'NETjet_U_card_msg' (at offset 0x65) and 'ph_command'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'BKM_card_msg' (at offset 0x9b) and 'jade_write_indirect'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'BKM_card_msg' (at offset 0xab) and 'jade_write_indirect'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text from .text between 'enpci_card_msg' (at offset 0xc9) and 'enpci_interrupt'
WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .init.text from .text between 'av7110_attach' (at offset 0x1240) and 'av7110_detach'
WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .exit.text from .text between 'av7110_detach' (at offset 0x44) and 'av7110_irq'
WARNING: drivers/net/acenic.o - Section mismatch: reference to .init.data from .text after 'acenic_probe_one' (at offset 0xa03)
WARNING: drivers/net/acenic.o - Section mismatch: reference to .init.data from .text after 'acenic_probe_one' (at offset 0xa1c)
WARNING: drivers/net/acenic.o - Section mismatch: reference to .init.data from .text after 'acenic_probe_one' (at offset 0xa35)
WARNING: drivers/net/de620.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x8) and 'cleanup_module'
WARNING: drivers/net/dgrs.o - Section mismatch: reference to .init.text from .data between 'dgrs_pci_driver' (at offset 0x20) and 'dgrs_ipxnet'
WARNING: drivers/net/tulip/de2104x.o - Section mismatch: reference to .init.text from .data between 'de_driver' (at offset 0x20) and 'de_ethtool_ops'
WARNING: drivers/net/tulip/de2104x.o - Section mismatch: reference to .exit.text from .data between 'de_driver' (at offset 0x28) and 'de_ethtool_ops'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0x8) and 'cleanup_module'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x12) and 'cleanup_module'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data from .text between 'init_module' (at offset 0x31) and 'cleanup_module'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.text from .text between 'init_module' (at offset 0x4a) and 'cleanup_module'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data from .data between '__param_arr_mac' (at offset 0x28) and '__param_str_mac'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data from .data between '__param_arr_rxl' (at offset 0x28) and '__param_str_rxl'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data from .data between '__param_arr_baud' (at offset 0x28) and '__param_str_baud'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data from .data between '__param_arr_irq' (at offset 0x28) and '__param_str_irq'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data from .data between '__param_arr_io' (at offset 0x28) and '__param_str_io'
WARNING: drivers/parport/parport_pc.o - Section mismatch: reference to .init.data from .data between '__param_arr_io_hi' (at offset 0x28) and '__param_str_io_hi'
WARNING: drivers/parport/parport_pc.o - Section mismatch: reference to .init.data from .data between '__param_arr_io' (at offset 0x28) and '__param_str_io'
WARNING: drivers/scsi/gdth.o - Section mismatch: reference to .init.data from .data between '__param_arr_irq' (at offset 0x28) and '__param_str_irq'
WARNING: drivers/scsi/gdth.o - Section mismatch: reference to .init.text from .data between 'driver_template' (at offset 0x10) and 'async_cache_tab'
WARNING: drivers/usb/gadget/g_ether.o - Section mismatch: reference to .init.text from .data between 'eth_driver' (at offset 0x10) and 'stringtab'
WARNING: drivers/usb/gadget/g_file_storage.o - Section mismatch: reference to .init.text from .data between 'fsg_driver' (at offset 0x10) and 'stringtab'
WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text from .text between 'gs_bind' (at offset 0x50) and '.text.lock.serial'
WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text from .text between 'gs_bind' (at offset 0x5f) and '.text.lock.serial'
WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text from .text between 'gs_bind' (at offset 0x88) and '.text.lock.serial'
WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text from .text between 'gs_bind' (at offset 0xba) and '.text.lock.serial'
WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text from .text between 'zero_bind' (at offset 0x11) and 'zero_suspend'
WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text from .text between 'zero_bind' (at offset 0x20) and 'zero_suspend'
WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text from .text between 'zero_bind' (at offset 0x68) and 'zero_suspend'
WARNING: drivers/usb/host/isp116x-hcd.o - Section mismatch: reference to .init.text from .data between '' (at offset 0x0) and 'isp116x_hc_driver'
WARNING: drivers/video/arcfb.o - Section mismatch: reference to .init.text from .data between 'arcfb_driver' (at offset 0x0) and 'arcfb_ops'
WARNING: drivers/video/aty/aty128fb.o - Section mismatch: reference to .init.text from .data between 'aty128fb_driver' (at offset 0x20) and 'aty128fb_ops'
WARNING: drivers/video/aty/atyfb.o - Section mismatch: reference to .init.data from .text between 'atyfb_pci_probe' (at offset 0xe8b) and 'atyfb_pci_remove'
WARNING: drivers/video/aty/atyfb.o - Section mismatch: reference to .init.text from .text between 'atyfb_pci_probe' (at offset 0xf24) and 'atyfb_pci_remove'
WARNING: drivers/video/geode/gx1fb.o - Section mismatch: reference to .init.text from .data between 'gx1fb_driver' (at offset 0x20) and 'gx1fb_ops'
WARNING: drivers/video/hgafb.o - Section mismatch: reference to .init.text from .data between 'hgafb_driver' (at offset 0x120) and 'hgafb_device'
WARNING: drivers/video/macmodes.o - Section mismatch: reference to .init.text from __ksymtab between '' (at offset 0x0) and '__ksymtab_mac_map_monitor_sense'
WARNING: drivers/video/nvidia/nvidiafb.o - Section mismatch: reference to .exit.text from .data between 'nvidiafb_driver' (at offset 0x28) and 'nvidia_fb_ops'
WARNING: drivers/video/riva/rivafb.o - Section mismatch: reference to .exit.text from .data between 'rivafb_driver' (at offset 0x28) and 'riva_fb_ops'
WARNING: drivers/video/savage/savagefb.o - Section mismatch: reference to .init.data from .text between 'savagefb_probe' (at offset 0x584) and 'savagefb_remove'
WARNING: drivers/video/vfb.o - Section mismatch: reference to .init.text from .data between 'vfb_driver' (at offset 0x0) and 'vfb_device'
WARNING: drivers/video/vga16fb.o - Section mismatch: reference to .init.text from .data between '' (at offset 0x120) and 'vga16fb_device'
WARNING: fs/jffs2/jffs2.o - Section mismatch: reference to .init.text from .text between 'jffs2_compressors_init' (at offset 0x5) and 'jffs2_compressors_exit'
WARNING: net/decnet/decnet.o - Section mismatch: reference to .init.data from .data between '__param_arr_addr' (at offset 0x28) and '__param_str_addr'
WARNING: net/ipv4/netfilter/ip_conntrack.o - Section mismatch: reference to .init.text from .text between 'init_or_cleanup' (at offset 0x12) and 'ip_conntrack_protocol_register'
WARNING: net/ipv4/netfilter/iptable_nat.o - Section mismatch: reference to .init.text from .text after 'init_or_cleanup' (at offset 0x39)
WARNING: sound/drivers/snd-dummy.o - Section mismatch: reference to .init.text from .data between 'snd_dummy_driver' (at offset 0x0) and 'snd_card_dummy_capture_ops'
WARNING: sound/drivers/snd-mtpav.o - Section mismatch: reference to .init.text from .data between 'snd_mtpav_driver' (at offset 0x0) and 'snd_mtpav_output'
WARNING: sound/drivers/snd-serial-u16550.o - Section mismatch: reference to .init.text from .data between 'snd_serial_driver' (at offset 0x0) and 'adaptor_names'
WARNING: sound/drivers/snd-virmidi.o - Section mismatch: reference to .init.text from .data after 'snd_virmidi_driver' (at offset 0x0)
WARNING: sound/oss/cs4232.o - Section mismatch: reference to .init.text from .text between 'cs4232_pnp_probe' (at offset 0x5c) and 'cs4232_pnp_remove'
WARNING: sound/oss/forte.o - Section mismatch: reference to .init.text from .data between 'forte_pci_driver' (at offset 0x20) and 'forte_dsp_fops'
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x31)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x57)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x8b)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x94)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0xb9)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0xc2)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0xe8)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0xee)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0xfe)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x121)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x137)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x17c)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x19f)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x1b6)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x1d1)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x1dc)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x1e8)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x1f7)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x247)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x24e)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x268)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x26e)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x274)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0x27a)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text from .text after 'init_mad16' (at offset 0x3d8)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text from .text after 'init_mad16' (at offset 0x404)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text from .text after 'init_mad16' (at offset 0x488)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text from .text after 'init_mad16' (at offset 0x517)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text from .text after 'init_mad16' (at offset 0x561)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text from .text after 'init_mad16' (at offset 0x58f)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0xb1d)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0xb30)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data from .text after 'init_mad16' (at offset 0xd3d)
WARNING: sound/oss/maestro.o - Section mismatch: reference to .init.text from .data between 'maestro_pci_driver' (at offset 0x20) and 'acpi_state_mask'
WARNING: sound/oss/msnd.o - Section mismatch: reference to .init.text from __ksymtab after '__ksymtab_msnd_register' (at offset 0x0)

2006-02-17 23:32:55

by Adrian Bunk

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Fri, Feb 17, 2006 at 11:47:02PM +0100, Sam Ravnborg wrote:
>...
> Syntax:
> The offset refer to the relative offset from the referenced symbol.
> So
> WARNING: drivers/acpi/asus_acpi.o - Section mismatch: reference to .init.text from .data between 'asus_hotk_driver' (at offset 0xc0) and 'model_conf'
> should be read as:
>
> At 0xc0 bytes after asus_hotk_driver there is a reference to a symbol
> placed in the section .init.text.
>
> I did not find a way to look up the offending symbol but maybe some elf
> expert can help?
>...

I'm not an ELF expert, but simply checking all __init functions in this
files finds that this seems to be the following:

<-- snip -->

...
static struct acpi_driver asus_hotk_driver = {
.name = ACPI_HOTK_NAME,
.class = ACPI_HOTK_CLASS,
.ids = ACPI_HOTK_HID,
.ops = {
.add = asus_hotk_add,
.remove = asus_hotk_remove,
},
};
...
static int __init asus_hotk_add(struct acpi_device *device)
...

<-- snip -->

> Sam
>...

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2006-02-17 23:39:07

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

Hi Adrian

> > I did not find a way to look up the offending symbol but maybe some elf
> > expert can help?
> >...
>
> I'm not an ELF expert, but simply checking all __init functions in this
> files finds that this seems to be the following:
>
> <-- snip -->
>
> ...
> static struct acpi_driver asus_hotk_driver = {
> .name = ACPI_HOTK_NAME,
> .class = ACPI_HOTK_CLASS,
> .ids = ACPI_HOTK_HID,
> .ops = {
> .add = asus_hotk_add,
> .remove = asus_hotk_remove,
> },
> };
> ...
> static int __init asus_hotk_add(struct acpi_device *device)
> ...
>
Correct.
What I wanted was modpost to tell that the symbol being referenced in
the .data section was 'asus_hotk_add' and not just an offset after
asus_hotk_driver.

What is needed is a link from the RELOCATION RECORD to the symbol table.


Sam

2006-02-17 23:56:34

by Adrian Bunk

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Sat, Feb 18, 2006 at 12:38:48AM +0100, Sam Ravnborg wrote:
> Hi Adrian
>
> > > I did not find a way to look up the offending symbol but maybe some elf
> > > expert can help?
> > >...
> >
> > I'm not an ELF expert, but simply checking all __init functions in this
> > files finds that this seems to be the following:
> >
> > <-- snip -->
> >
> > ...
> > static struct acpi_driver asus_hotk_driver = {
> > .name = ACPI_HOTK_NAME,
> > .class = ACPI_HOTK_CLASS,
> > .ids = ACPI_HOTK_HID,
> > .ops = {
> > .add = asus_hotk_add,
> > .remove = asus_hotk_remove,
> > },
> > };
> > ...
> > static int __init asus_hotk_add(struct acpi_device *device)
> > ...
> >
> Correct.
> What I wanted was modpost to tell that the symbol being referenced in
> the .data section was 'asus_hotk_add' and not just an offset after
> asus_hotk_driver.
>
> What is needed is a link from the RELOCATION RECORD to the symbol table.

Ah sorry, I misunderstood your question.

> Sam

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2006-02-18 00:09:41

by Greg KH

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Fri, Feb 17, 2006 at 11:47:02PM +0100, Sam Ravnborg wrote:
> Background:
> I have introduced a build-time check for section mismatch and it showed
> up a great number of warnings.
> Below is the result of the run on a 2.6.16-rc1 tree (which my kbuild
> tree is based upon) based on a 'make allmodconfig'
>
> 159 warnings in 49 different modules
>
> I have included the obvious candidates for the modules in to: but some
> are for sure missing and some may be wrong.
>
> WARNING: drivers/usb/gadget/g_ether.o - Section mismatch: reference to .init.text from .data between 'eth_driver' (at offset 0x10) and 'stringtab'
> WARNING: drivers/usb/gadget/g_file_storage.o - Section mismatch: reference to .init.text from .data between 'fsg_driver' (at offset 0x10) and 'stringtab'
> WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text from .text between 'gs_bind' (at offset 0x50) and '.text.lock.serial'
> WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text from .text between 'gs_bind' (at offset 0x5f) and '.text.lock.serial'
> WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text from .text between 'gs_bind' (at offset 0x88) and '.text.lock.serial'
> WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text from .text between 'gs_bind' (at offset 0xba) and '.text.lock.serial'
> WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text from .text between 'zero_bind' (at offset 0x11) and 'zero_suspend'
> WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text from .text between 'zero_bind' (at offset 0x20) and 'zero_suspend'
> WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text from .text between 'zero_bind' (at offset 0x68) and 'zero_suspend'

David, these all look like they are due to the calls in the
drivers/usb/gadget/epautoconf.c file from functions within the gadget
drivers. It looks like it's all safe, but can you verify that the bind
callback is finished before module_init() exits?

And if so, we should mark the bind functions __init also, to prevent
this from being flagged in the future.

> WARNING: drivers/usb/host/isp116x-hcd.o - Section mismatch: reference to .init.text from .data between '' (at offset 0x0) and 'isp116x_hc_driver'

This looks like the isp116x_remove function just needs to get the looney
__init_or_module marking of of it. Again, David, do you agree?

thanks,

greg k-h

2006-02-18 00:15:15

by Nicholas Miell

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Sat, 2006-02-18 at 00:38 +0100, Sam Ravnborg wrote:
> Hi Adrian
>
> > > I did not find a way to look up the offending symbol but maybe some elf
> > > expert can help?
> > >...
> >
> > I'm not an ELF expert, but simply checking all __init functions in this
> > files finds that this seems to be the following:
> >
> > <-- snip -->
> >
> > ...
> > static struct acpi_driver asus_hotk_driver = {
> > .name = ACPI_HOTK_NAME,
> > .class = ACPI_HOTK_CLASS,
> > .ids = ACPI_HOTK_HID,
> > .ops = {
> > .add = asus_hotk_add,
> > .remove = asus_hotk_remove,
> > },
> > };
> > ...
> > static int __init asus_hotk_add(struct acpi_device *device)
> > ...
> >
> Correct.
> What I wanted was modpost to tell that the symbol being referenced in
> the .data section was 'asus_hotk_add' and not just an offset after
> asus_hotk_driver.
>
> What is needed is a link from the RELOCATION RECORD to the symbol table.

The r_info field of Elf{32,64}_Rel{,a} contains an index into the symbol
table which can be extracted using the ELF{32,64}_R_SYM() macro.

--
Nicholas Miell <[email protected]>

2006-02-18 00:48:47

by David Brownell

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Friday 17 February 2006 4:09 pm, Greg KH wrote:
> On Fri, Feb 17, 2006 at 11:47:02PM +0100, Sam Ravnborg wrote:

> > WARNING: drivers/usb/gadget/g_ether.o - Section mismatch: reference to .init.text from .data between 'eth_driver' (at offset 0x10) and 'stringtab'
> > WARNING: drivers/usb/gadget/g_file_storage.o - ... etc ...
>
> David, these all look like they are due to the calls in the
> drivers/usb/gadget/epautoconf.c file from functions within the gadget
> drivers. It looks like it's all safe, but can you verify that the bind
> callback is finished before module_init() exits?

If they just usb_gadget_register_driver(), that's how it's defined to
work yes. (Though a spec lawyer might want more explicit language ...)


> And if so, we should mark the bind functions __init also, to prevent
> this from being flagged in the future.

And the unbind functions __exit/__exit_p()? Smaller runtime footprints
are good. I don't like leaving the driver->init() method invalid, which
is I think why I didn't do that before, but saving space is the right
thing to do.


> > WARNING: drivers/usb/host/isp116x-hcd.o - Section mismatch: reference to .init.text from .data between '' (at offset 0x0) and 'isp116x_hc_driver'
>
> This looks like the isp116x_remove function just needs to get the looney
> __init_or_module marking of of it. Again, David, do you agree?

Right; that marking is for infrastructure, not drivers.

- Dave

2006-02-18 00:49:30

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Friday 17 February 2006 17:47, Sam Ravnborg wrote:
> Several warnings are refereces to module parameters - sound/oss/mad16.o
> as the most visible one. I have not yet figured out if this is a false
> positive or not. Removing __initdata on the moduleparam variable solves
> it, but then this may be the wrong approach.
>

It looks like your check does not like when data associated with a module
parameter is marked __initdata. But I think it is allowed as long as
module parameter access mode is 0 so we don't create sysfs entry for it.

--
Dmitry

2006-02-18 01:04:53

by Greg KH

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Fri, Feb 17, 2006 at 04:48:37PM -0800, David Brownell wrote:
> On Friday 17 February 2006 4:09 pm, Greg KH wrote:
> > On Fri, Feb 17, 2006 at 11:47:02PM +0100, Sam Ravnborg wrote:
>
> > > WARNING: drivers/usb/gadget/g_ether.o - Section mismatch: reference to .init.text from .data between 'eth_driver' (at offset 0x10) and 'stringtab'
> > > WARNING: drivers/usb/gadget/g_file_storage.o - ... etc ...
> >
> > David, these all look like they are due to the calls in the
> > drivers/usb/gadget/epautoconf.c file from functions within the gadget
> > drivers. It looks like it's all safe, but can you verify that the bind
> > callback is finished before module_init() exits?
>
> If they just usb_gadget_register_driver(), that's how it's defined to
> work yes. (Though a spec lawyer might want more explicit language ...)
>
>
> > And if so, we should mark the bind functions __init also, to prevent
> > this from being flagged in the future.
>
> And the unbind functions __exit/__exit_p()? Smaller runtime footprints
> are good. I don't like leaving the driver->init() method invalid, which
> is I think why I didn't do that before, but saving space is the right
> thing to do.

Ok, care to create a patch for these?

> > > WARNING: drivers/usb/host/isp116x-hcd.o - Section mismatch: reference to .init.text from .data between '' (at offset 0x0) and 'isp116x_hc_driver'
> >
> > This looks like the isp116x_remove function just needs to get the looney
> > __init_or_module marking of of it. Again, David, do you agree?
>
> Right; that marking is for infrastructure, not drivers.

Ok, I'll take care of this, thanks for verifying it.

greg k-h

2006-02-18 12:14:57

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Fri, Feb 17, 2006 at 07:49:26PM -0500, Dmitry Torokhov wrote:
> On Friday 17 February 2006 17:47, Sam Ravnborg wrote:
> > Several warnings are refereces to module parameters - sound/oss/mad16.o
> > as the most visible one. I have not yet figured out if this is a false
> > positive or not. Removing __initdata on the moduleparam variable solves
> > it, but then this may be the wrong approach.
> >
>
> It looks like your check does not like when data associated with a module
> parameter is marked __initdata. But I think it is allowed as long as
> module parameter access mode is 0 so we don't create sysfs entry for it.

It hits only arrays - so I took a look into moduleparam.h.
Looks like an __initdata tag is missing?

diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index b5c98c4..e67eafd 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -147,6 +147,7 @@ extern int param_get_invbool(char *buffe
/* Comma-separated array: *nump is set to number they actually specified. */
#define module_param_array_named(name, array, type, nump, perm) \
static struct kparam_array __param_arr_##name \
+ __initdata \
= { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type,\
sizeof(array[0]), array }; \
module_param_call(name, param_array_set, param_array_get, \


With this change static struct kparam_array __param_arr_##name is placed
in .init.data.
This made the warnings in drivers/input/joystick/db9 disappear.

And with db9 marked __initdata there should be nothing wrong in
using __initdata for __param_arr_##name as I see it.

Rusty - any comments on this?

Sam

2006-02-18 13:35:17

by Russell King

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Sat, Feb 18, 2006 at 01:14:14PM +0100, Sam Ravnborg wrote:
> It hits only arrays - so I took a look into moduleparam.h.
> Looks like an __initdata tag is missing?
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index b5c98c4..e67eafd 100644
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -147,6 +147,7 @@ extern int param_get_invbool(char *buffe
> /* Comma-separated array: *nump is set to number they actually specified. */
> #define module_param_array_named(name, array, type, nump, perm) \
> static struct kparam_array __param_arr_##name \
> + __initdata \
> = { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type,\
> sizeof(array[0]), array }; \
> module_param_call(name, param_array_set, param_array_get, \
>
>
> With this change static struct kparam_array __param_arr_##name is placed
> in .init.data.
> This made the warnings in drivers/input/joystick/db9 disappear.
>
> And with db9 marked __initdata there should be nothing wrong in
> using __initdata for __param_arr_##name as I see it.

What happens to /sys/module/*/parameters/foo if you read/write it?
Probably worth checking to ensure there isn't an oops lurking as a
result of this change.

(Maybe we need to poison the free'd init sections at boot time just
to make sure we catch possible errors like this.)

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2006-02-18 20:51:17

by David Brownell

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Friday 17 February 2006 4:57 pm, Greg KH wrote:

> > > And if so, we should mark the bind functions __init also, to prevent
> > > this from being flagged in the future.
> >
> > And the unbind functions __exit/__exit_p()? Smaller runtime footprints
> > are good. I don't like leaving the driver->init() method invalid, which
> > is I think why I didn't do that before, but saving space is the right
> > thing to do.
>
> Ok, care to create a patch for these?

Done; the Ethernet driver had another patch pending in that area, which
I've also forwarded to you.

- Dave

2006-02-18 21:26:36

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Fri, Feb 17, 2006 at 04:14:59PM -0800, Nicholas Miell wrote:
> > Correct.
> > What I wanted was modpost to tell that the symbol being referenced in
> > the .data section was 'asus_hotk_add' and not just an offset after
> > asus_hotk_driver.
> >
> > What is needed is a link from the RELOCATION RECORD to the symbol table.
>
> The r_info field of Elf{32,64}_Rel{,a} contains an index into the symbol
> table which can be extracted using the ELF{32,64}_R_SYM() macro.

What I found here is that the symbol pointed out by ELF_R_SYM(r_info)
only contain one valid entry, namely the section where the symbol that
requires relocation is present. At least for amd64 all RELOCATION
RECORDS are of type RELA so they had an r_addent that pointed out
the offset within that section. So traversing the symbol table I could
find the symbol by looking up the symbol where shndx equals the section
in the symbol table and st_value equal the value of r_addent in the
relocation record.

I cooked up the following:
static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
Elf_Section sec)
{
Elf_Sym *sym;

for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
if (sym->st_shndx != sec)
continue;
if (sym->st_value == addr)
return sym;
}
return NULL;
}

This was with binutils version: 2.16.1 and gcc 3.4.4

So far I have only support for RELA records, not REL records.
That may prove required for other platforms.

Sam

2006-02-18 22:12:32

by Andi Kleen

[permalink] [raw]
Subject: Re: kbuild:

Sam Ravnborg <[email protected]> writes:

> I have moved the functionality of reference_init + reference_discarded
> to modpost to secure a much wider use of this check.

How much does that slow the build down?

-Andi

2006-02-18 22:38:48

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild:

On Sat, Feb 18, 2006 at 11:12:28PM +0100, Andi Kleen wrote:
> Sam Ravnborg <[email protected]> writes:
>
> > I have moved the functionality of reference_init + reference_discarded
> > to modpost to secure a much wider use of this check.
>
> How much does that slow the build down?
It obviously depends on number of modules / size of vmlinux.
With x86_64 and defconfig + all oss drivers configured as modules the
modpost stage takes around 0.2 sec in total. So this is down in the
noise level. Building allmodconfig kernel atm and if I see > 2 sec
difference with and without the check I will do a follow-up post.

Obviously the more modules with problems the longer time. So I will
skip the warning messages in the measurements since I assume they will
be taken care of.

Sam

2006-02-18 23:41:21

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild:

On Sat, Feb 18, 2006 at 11:38:36PM +0100, Sam Ravnborg wrote:
> On Sat, Feb 18, 2006 at 11:12:28PM +0100, Andi Kleen wrote:
> > Sam Ravnborg <[email protected]> writes:
> >
> > > I have moved the functionality of reference_init + reference_discarded
> > > to modpost to secure a much wider use of this check.
> >
> > How much does that slow the build down?
> It obviously depends on number of modules / size of vmlinux.
> With x86_64 and defconfig + all oss drivers configured as modules the
> modpost stage takes around 0.2 sec in total. So this is down in the
> noise level. Building allmodconfig kernel atm and if I see > 2 sec
> difference with and without the check I will do a follow-up post.
>
> Obviously the more modules with problems the longer time. So I will
> skip the warning messages in the measurements since I assume they will
> be taken care of.

Have figures for an allmodconfig now - this is a bit more than 1500
modules.
Running modpost alone takes 8,1 seconds without the checks and 8,9
seconds with the checks enabled (output disabled).

Considering that a a make allmodconfig with no updates takes
roughly 33 seconds the added overhead of 0,8 seconds is acceptable.

Sam

2006-02-19 00:22:19

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Fri, Feb 17, 2006 at 04:09:21PM -0800, Greg KH wrote:
> On Fri, Feb 17, 2006 at 11:47:02PM +0100, Sam Ravnborg wrote:
> > Background:
> > I have introduced a build-time check for section mismatch and it showed
> > up a great number of warnings.
> > Below is the result of the run on a 2.6.16-rc1 tree (which my kbuild
> > tree is based upon) based on a 'make allmodconfig'

Greg - related to this I have thought a bit on __devinit versus __init.
With HOTPLUG enabled __devinit becomes empty and thus violate any checks
for illegal references to .init.text.

Would it make sense to create a specific set of sections for __devinit
and frinds so we could check that __devinit sections are not referenced from .text.
This is another way to do the current __init checks but with HOTPLUG
enabled and I like the result to be consistent with and without HOTPLUG
enabled.

Also I see __devinit being used in different ways. See sound/oss/mad16
for instance.
Only a few functions are marked __devinit nad I wonder if any should be
marked __devinit at all in that file. But due to references to
__initdata current checks discovered a potential bug here already today.

Sam

2006-02-19 11:37:10

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Fri, Feb 17, 2006 at 11:47:02PM +0100, Sam Ravnborg wrote:
> Background:
> I have introduced a build-time check for section mismatch and it showed
> up a great number of warnings.
> Below is the result of the run on a 2.6.16-rc1 tree (which my kbuild
> tree is based upon) based on a 'make allmodconfig'

Updated list of warnings below. This time on a rc4 tree and with
referenced symbol included in warning (when possible).
This is with my latest kbuild tree which will show up in next -mm.

Question: Several modules contains init_module() cleanup_module() -
for example floppy.o. I cannot see they are used anymore and subject for
deletion - correct?

The module parameter warning are still pending - I hope Rusty will
comment on yhe suggested patch to use __initdata in the moduleparam
macro.

Sam

WARNING: drivers/acpi/asus_acpi.o - Section mismatch: reference to .init.text:asus_hotk_add from .data between 'asus_hotk_driver' (at offset 0xe0) and 'model_conf'
WARNING: drivers/atm/fore_200e.o - Section mismatch: reference to .init.text: from .text between 'fore200e_pca_detect' (at offset 0x21bf) and 'fore200e_pca_remove_one'
WARNING: drivers/block/cpqarray.o - Section mismatch: reference to .init.text:cpqarray_init_one from .data between 'cpqarray_pci_driver' (at offset 0x60) and 'products'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x69b7) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x69d6) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x69dd) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x69e9) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x69f9) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x6a22) and 'cleanup_module'
WARNING: drivers/block/floppy.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x6a5a) and 'cleanup_module'
WARNING: drivers/char/hw_random.o - Section mismatch: reference to .init.text:intel_init from .data between 'rng_vendor_ops' (at offset 0x2c8) and 'rng_lock.0'
WARNING: drivers/char/hw_random.o - Section mismatch: reference to .init.text:amd_init from .data between 'rng_vendor_ops' (at offset 0x2f0) and 'rng_lock.0'
WARNING: drivers/char/hw_random.o - Section mismatch: reference to .init.text:geode_init from .data between 'rng_vendor_ops' (at offset 0x318) and 'rng_lock.0'
WARNING: drivers/char/ip2main.o - Section mismatch: reference to .init.text: from .text between 'cleanup_module' (at offset 0x1fa4) and 'ip2_loadmain'
WARNING: drivers/char/ip2main.o - Section mismatch: reference to .init.text: from .text between 'ip2_loadmain' (at offset 0x32d5) and 'ip2_interrupt'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text: from .text between 'init_module' (at offset 0x1f97) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text: from .text between 'init_module' (at offset 0x20c2) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text: from .text between 'init_module' (at offset 0x2210) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text: from .text between 'init_module' (at offset 0x227d) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x229f) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x22c2) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x22da) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text: from .text between 'init_module' (at offset 0x251a) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text:ide_scan_pcibus from .text between 'init_module' (at offset 0x2544) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text:ide_probe_for_cmd640x from .text between 'init_module' (at offset 0x2549) and 'cleanup_module'
WARNING: drivers/ide/ide-core.o - Section mismatch: reference to .init.text:pnpide_init from .text between 'init_module' (at offset 0x254e) and 'cleanup_module'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data: from .data between '' (at offset 0x8) and '__param_str_dev3'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data: from .data between '' (at offset 0x28) and '__param_str_dev3'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data: from .data between '__param_arr_dev2' (at offset 0x48) and '__param_str_dev2'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data: from .data between '__param_arr_dev2' (at offset 0x68) and '__param_str_dev2'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data: from .data between '__param_arr_dev' (at offset 0x88) and '__param_str_dev'
WARNING: drivers/input/joystick/db9.o - Section mismatch: reference to .init.data:db9 from .data between '__param_arr_dev' (at offset 0xa8) and '__param_str_dev'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data: from .data between '__param_arr_map3' (at offset 0x28) and '__param_str_map3'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data: from .data between '__param_arr_map3' (at offset 0x48) and '__param_str_map3'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data: from .data between '__param_arr_map2' (at offset 0x68) and '__param_str_map2'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data: from .data between '__param_arr_map2' (at offset 0x88) and '__param_str_map2'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data: from .data between '__param_arr_map' (at offset 0xa8) and '__param_str_map'
WARNING: drivers/input/joystick/gamecon.o - Section mismatch: reference to .init.data:gc from .data between '__param_arr_map' (at offset 0xc8) and '__param_str_map'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data: from .data between '' (at offset 0x8) and '__param_str_map3'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data: from .data between '' (at offset 0x28) and '__param_str_map3'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data: from .data between '__param_arr_map2' (at offset 0x48) and '__param_str_map2'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data: from .data between '__param_arr_map2' (at offset 0x68) and '__param_str_map2'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data: from .data between '__param_arr_map' (at offset 0x88) and '__param_str_map'
WARNING: drivers/input/joystick/turbografx.o - Section mismatch: reference to .init.data:tgfx from .data between '__param_arr_map' (at offset 0xa8) and '__param_str_map'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_s0box from .text between 'checkcard' (at offset 0x8db) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_telespci from .text between 'checkcard' (at offset 0x8e8) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_avm_pcipnp from .text between 'checkcard' (at offset 0x902) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_diva from .text between 'checkcard' (at offset 0x91c) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_netjet_s from .text between 'checkcard' (at offset 0x936) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_hfcpci from .text between 'checkcard' (at offset 0x940) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_niccy from .text between 'checkcard' (at offset 0x954) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_bkm_a4t from .text between 'checkcard' (at offset 0x95e) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_sct_quadro from .text between 'checkcard' (at offset 0x968) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_gazel from .text between 'checkcard' (at offset 0x972) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_w6692 from .text between 'checkcard' (at offset 0x97c) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_netjet_u from .text between 'checkcard' (at offset 0x986) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:setup_enternow_pci from .text between 'checkcard' (at offset 0x990) and 'HiSax_closecard'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:init_ipacx from .text between 'Diva_card_msg' (at offset 0x282e1) and 'ph_command'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:inittiger from .text between 'NETjet_S_card_msg' (at offset 0x302fc) and 'NETjet_ReadIC'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:inittiger from .text between 'NETjet_U_card_msg' (at offset 0x32011) and 'ph_command'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:clear_pending_icc_ints from .text between 'NETjet_U_card_msg' (at offset 0x32021) and 'ph_command'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:initicc from .text between 'NETjet_U_card_msg' (at offset 0x32029) and 'ph_command'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:clear_pending_jade_ints from .text between 'BKM_card_msg' (at offset 0x3a5a4) and 'jade_write_indirect'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:initjade from .text between 'BKM_card_msg' (at offset 0x3a5b4) and 'jade_write_indirect'
WARNING: drivers/isdn/hisax/hisax.o - Section mismatch: reference to .init.text:inittiger from .text between 'enpci_card_msg' (at offset 0x3f471) and 'enpci_interrupt'
WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .init.text:av7110_ir_init from .text between 'av7110_attach' (at offset 0xcaa6) and 'av7110_detach'
WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .exit.text:av7110_ir_exit from .text between 'av7110_detach' (at offset 0xcbc5) and 'av7110_irq'
WARNING: drivers/net/acenic.o - Section mismatch: reference to .init.data:tigon2FwText from .text after 'acenic_probe_one' (at offset 0x3409)
WARNING: drivers/net/acenic.o - Section mismatch: reference to .init.data:tigon2FwRodata from .text after 'acenic_probe_one' (at offset 0x3422)
WARNING: drivers/net/acenic.o - Section mismatch: reference to .init.data: from .text after 'acenic_probe_one' (at offset 0x343b)
WARNING: drivers/net/de620.o - Section mismatch: reference to .init.text:de620_probe from .text between 'init_module' (at offset 0x1681) and 'cleanup_module'
WARNING: drivers/net/dgrs.o - Section mismatch: reference to .init.text:dgrs_pci_probe from .data between 'dgrs_pci_driver' (at offset 0x160) and 'dgrs_ipxnet'
WARNING: drivers/net/tulip/de2104x.o - Section mismatch: reference to .init.text:de_init_one from .data between 'de_driver' (at offset 0xa0) and 'de_ethtool_ops'
WARNING: drivers/net/tulip/de2104x.o - Section mismatch: reference to .exit.text:de_remove_one from .data between 'de_driver' (at offset 0xa8) and 'de_ethtool_ops'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x14ef) and 'cleanup_module'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.text: from .text between 'init_module' (at offset 0x14f9) and 'cleanup_module'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data: from .text between 'init_module' (at offset 0x1518) and 'cleanup_module'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.text: from .text between 'init_module' (at offset 0x1531) and 'cleanup_module'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data:mac from .data between '__param_arr_mac' (at offset 0x48) and '__param_str_mac'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data:rxl from .data between '__param_arr_rxl' (at offset 0x88) and '__param_str_rxl'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data:baud from .data between '__param_arr_baud' (at offset 0xc8) and '__param_str_baud'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data:irq from .data between '__param_arr_irq' (at offset 0x108) and '__param_str_irq'
WARNING: drivers/net/wan/sbni.o - Section mismatch: reference to .init.data:io from .data between '__param_arr_io' (at offset 0x148) and '__param_str_io'
WARNING: drivers/parport/parport_pc.o - Section mismatch: reference to .init.data: from .data between '__param_arr_io_hi' (at offset 0xc8) and '__param_str_io_hi'
WARNING: drivers/parport/parport_pc.o - Section mismatch: reference to .init.data:io from .data between '__param_arr_io' (at offset 0x108) and '__param_str_io'
WARNING: drivers/scsi/gdth.o - Section mismatch: reference to .init.data:irq from .data between '__param_arr_irq' (at offset 0x248) and '__param_str_irq'
WARNING: drivers/scsi/gdth.o - Section mismatch: reference to .init.text:gdth_detect from .data between 'driver_template' (at offset 0x270) and 'async_cache_tab'
WARNING: drivers/usb/gadget/g_ether.o - Section mismatch: reference to .init.text:eth_bind from .data between 'eth_driver' (at offset 0x70) and 'stringtab'
WARNING: drivers/usb/gadget/g_file_storage.o - Section mismatch: reference to .init.text:fsg_bind from .data between 'fsg_driver' (at offset 0x130) and 'stringtab'
WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text:usb_ep_autoconfig_reset from .text between 'gs_bind' (at offset 0x1d2c) and '.text.lock.serial'
WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text:usb_ep_autoconfig from .text between 'gs_bind' (at offset 0x1d3b) and '.text.lock.serial'
WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text:usb_ep_autoconfig from .text between 'gs_bind' (at offset 0x1d64) and '.text.lock.serial'
WARNING: drivers/usb/gadget/g_serial.o - Section mismatch: reference to .init.text:usb_ep_autoconfig from .text between 'gs_bind' (at offset 0x1d96) and '.text.lock.serial'
WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text:usb_ep_autoconfig_reset from .text between 'zero_bind' (at offset 0x11c1) and 'zero_suspend'
WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text:usb_ep_autoconfig from .text between 'zero_bind' (at offset 0x11d0) and 'zero_suspend'
WARNING: drivers/usb/gadget/g_zero.o - Section mismatch: reference to .init.text:usb_ep_autoconfig from .text between 'zero_bind' (at offset 0x1218) and 'zero_suspend'
WARNING: drivers/usb/host/isp116x-hcd.o - Section mismatch: reference to .init.text:isp116x_probe from .data between '' (at offset 0x0) and 'isp116x_hc_driver'
WARNING: drivers/video/arcfb.o - Section mismatch: reference to .init.text:arcfb_probe from .data between 'arcfb_driver' (at offset 0x60) and 'arcfb_ops'
WARNING: drivers/video/aty/aty128fb.o - Section mismatch: reference to .init.text:aty128_probe from .data between 'aty128fb_driver' (at offset 0x640) and 'aty128fb_ops'
WARNING: drivers/video/aty/atyfb.o - Section mismatch: reference to .init.data: from .text between 'atyfb_pci_probe' (at offset 0x2ac9) and 'atyfb_pci_remove'
WARNING: drivers/video/aty/atyfb.o - Section mismatch: reference to .init.text:aty_init_cursor from .text between 'atyfb_pci_probe' (at offset 0x2b62) and 'atyfb_pci_remove'
WARNING: drivers/video/geode/gx1fb.o - Section mismatch: reference to .init.text: from .data between 'gx1fb_driver' (at offset 0x100) and 'gx1fb_ops'
WARNING: drivers/video/hgafb.o - Section mismatch: reference to .init.text:hgafb_probe from .data between 'hgafb_driver' (at offset 0x140) and 'hgafb_device'
WARNING: drivers/video/macmodes.o - Section mismatch: reference to .init.text:mac_find_mode from __ksymtab between '' (at offset 0x0) and '__ksymtab_mac_map_monitor_sense'
WARNING: drivers/video/nvidia/nvidiafb.o - Section mismatch: reference to .exit.text: from .data between 'nvidiafb_driver' (at offset 0x1688) and 'nvidia_fb_ops'
WARNING: drivers/video/riva/rivafb.o - Section mismatch: reference to .exit.text: from .data between 'rivafb_driver' (at offset 0x5c8) and 'riva_fb_ops'
WARNING: drivers/video/savage/savagefb.o - Section mismatch: reference to .init.data: from .text between 'savagefb_probe' (at offset 0x34c3) and 'savagefb_remove'
WARNING: drivers/video/vfb.o - Section mismatch: reference to .init.text:vfb_probe from .data between 'vfb_driver' (at offset 0x40) and 'vfb_device'
WARNING: drivers/video/vga16fb.o - Section mismatch: reference to .init.text:vga16fb_probe from .data between '' (at offset 0x120) and 'vga16fb_device'
WARNING: fs/jffs2/jffs2.o - Section mismatch: reference to .init.text:jffs2_zlib_init from .text between 'jffs2_compressors_init' (at offset 0x5d3) and 'jffs2_compressors_exit'
WARNING: net/decnet/decnet.o - Section mismatch: reference to .init.data:addr from .data between '__param_arr_addr' (at offset 0x7e8) and '__param_str_addr'
WARNING: net/ipv4/netfilter/ip_conntrack.o - Section mismatch: reference to .init.text:ip_conntrack_init from .text between 'init_or_cleanup' (at offset 0x783) and 'ip_conntrack_protocol_register'
WARNING: net/ipv4/netfilter/iptable_nat.o - Section mismatch: reference to .init.text:ip_nat_rule_init from .text after 'init_or_cleanup' (at offset 0xab5)
WARNING: sound/drivers/snd-dummy.o - Section mismatch: reference to .init.text: from .data between 'snd_dummy_driver' (at offset 0x3c0) and 'snd_card_dummy_capture_ops'
WARNING: sound/drivers/snd-mtpav.o - Section mismatch: reference to .init.text:snd_mtpav_probe from .data between 'snd_mtpav_driver' (at offset 0x40) and 'snd_mtpav_output'
WARNING: sound/drivers/snd-serial-u16550.o - Section mismatch: reference to .init.text:snd_serial_probe from .data between 'snd_serial_driver' (at offset 0x840) and 'adaptor_names'
WARNING: sound/drivers/snd-virmidi.o - Section mismatch: reference to .init.text: from .data after 'snd_virmidi_driver' (at offset 0x2e0)
WARNING: sound/oss/cs4232.o - Section mismatch: reference to .init.text: from .text between 'cs4232_pnp_probe' (at offset 0x13b) and 'cs4232_pnp_remove'
WARNING: sound/oss/forte.o - Section mismatch: reference to .init.text:forte_probe from .data between 'forte_pci_driver' (at offset 0x60) and 'forte_dsp_fops'
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:cdirq from .text after 'init_mad16' (at offset 0x172)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:cddma from .text after 'init_mad16' (at offset 0x198)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data: from .text after 'init_mad16' (at offset 0x1cc)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:joystick from .text after 'init_mad16' (at offset 0x1d5)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data: from .text after 'init_mad16' (at offset 0x1fa)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:joystick from .text after 'init_mad16' (at offset 0x203)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data: from .text after 'init_mad16' (at offset 0x229)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:cdirq from .text after 'init_mad16' (at offset 0x22f)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data: from .text after 'init_mad16' (at offset 0x23f)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:opl4 from .text after 'init_mad16' (at offset 0x262)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:dma_map from .text after 'init_mad16' (at offset 0x278)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:cdport from .text after 'init_mad16' (at offset 0x2bd)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:irq_map from .text after 'init_mad16' (at offset 0x2e0)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:cddma from .text after 'init_mad16' (at offset 0x2f7)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:opl4 from .text after 'init_mad16' (at offset 0x312)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:dma_map from .text after 'init_mad16' (at offset 0x31d)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data: from .text after 'init_mad16' (at offset 0x329)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:cddma from .text after 'init_mad16' (at offset 0x338)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:cdport from .text after 'init_mad16' (at offset 0x388)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:irq_map from .text after 'init_mad16' (at offset 0x38f)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:dma from .text after 'init_mad16' (at offset 0x3a9)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:cdtype from .text after 'init_mad16' (at offset 0x3af)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:dma16 from .text after 'init_mad16' (at offset 0x3b5)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:irq from .text after 'init_mad16' (at offset 0x3bb)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text: from .text after 'init_mad16' (at offset 0x519)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text: from .text after 'init_mad16' (at offset 0x545)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text: from .text after 'init_mad16' (at offset 0x5c9)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text: from .text after 'init_mad16' (at offset 0x658)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text: from .text after 'init_mad16' (at offset 0x6a2)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.text: from .text after 'init_mad16' (at offset 0x6d0)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:mpu_irq from .text after 'init_mad16' (at offset 0xc5e)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data:io from .text after 'init_mad16' (at offset 0xc71)
WARNING: sound/oss/mad16.o - Section mismatch: reference to .init.data: from .text after 'init_mad16' (at offset 0xe7e)
WARNING: sound/oss/maestro.o - Section mismatch: reference to .init.text:maestro_probe from .data between 'maestro_pci_driver' (at offset 0x100) and 'acpi_state_mask'
WARNING: sound/oss/msnd.o - Section mismatch: reference to .init.text:msnd_register from __ksymtab after '__ksymtab_msnd_register' (at offset 0xf0)

2006-02-19 12:59:31

by Johannes Stezenbach

[permalink] [raw]
Subject: Re: [v4l-dvb-maintainer] Re: kbuild: Section mismatch warnings

On Sun, Feb 19, 2006, Sam Ravnborg wrote:
> On Fri, Feb 17, 2006 at 11:47:02PM +0100, Sam Ravnborg wrote:
> > Background:
> > I have introduced a build-time check for section mismatch and it showed
> > up a great number of warnings.
> > Below is the result of the run on a 2.6.16-rc1 tree (which my kbuild
> > tree is based upon) based on a 'make allmodconfig'
>
> Updated list of warnings below. This time on a rc4 tree and with
> referenced symbol included in warning (when possible).
> This is with my latest kbuild tree which will show up in next -mm.
...
> WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .init.text:av7110_ir_init from .text between 'av7110_attach' (at offset 0xcaa6) and 'av7110_detach'
> WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .exit.text:av7110_ir_exit from .text between 'av7110_detach' (at offset 0xcbc5) and 'av7110_irq'

These seem to be legitimate and point to the right place.
Patch attached.

Thanks,
Johannes

---
dvb: fix __init/__exit section references in av7110 driver

Signed-off-by: Johannes Stezenbach <[email protected]>

diff -r 24e38b947b8a linux/drivers/media/dvb/ttpci/av7110.c
--- a/linux/drivers/media/dvb/ttpci/av7110.c Sat Feb 18 10:41:07 2006 -0200
+++ b/linux/drivers/media/dvb/ttpci/av7110.c Sun Feb 19 13:54:37 2006 +0100
@@ -2476,7 +2476,8 @@ static int frontend_init(struct av7110 *
* The same behaviour of missing VSYNC can be duplicated on budget
* cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
*/
-static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data *pci_ext)
+static int __devinit av7110_attach(struct saa7146_dev* dev,
+ struct saa7146_pci_extension_data *pci_ext)
{
const int length = TS_WIDTH * TS_HEIGHT;
struct pci_dev *pdev = dev->pci;
@@ -2826,7 +2827,7 @@ err_kfree_0:
goto out;
}

-static int av7110_detach(struct saa7146_dev* saa)
+static int __devexit av7110_detach(struct saa7146_dev* saa)
{
struct av7110 *av7110 = saa->ext_priv;
dprintk(4, "%p\n", av7110);
@@ -2973,7 +2974,7 @@ static struct saa7146_extension av7110_e
.module = THIS_MODULE,
.pci_tbl = &pci_tbl[0],
.attach = av7110_attach,
- .detach = av7110_detach,
+ .detach = __devexit_p(av7110_detach),

.irq_mask = MASK_19 | MASK_03 | MASK_10,
.irq_func = av7110_irq,
diff -r 24e38b947b8a linux/drivers/media/dvb/ttpci/av7110_ir.c
--- a/linux/drivers/media/dvb/ttpci/av7110_ir.c Sat Feb 18 10:41:07 2006 -0200
+++ b/linux/drivers/media/dvb/ttpci/av7110_ir.c Sun Feb 19 13:54:37 2006 +0100
@@ -208,7 +208,7 @@ static void ir_handler(struct av7110 *av
}


-int __init av7110_ir_init(struct av7110 *av7110)
+int __devexit av7110_ir_init(struct av7110 *av7110)
{
static struct proc_dir_entry *e;

@@ -248,7 +248,7 @@ int __init av7110_ir_init(struct av7110
}


-void __exit av7110_ir_exit(struct av7110 *av7110)
+void __devexit av7110_ir_exit(struct av7110 *av7110)
{
int i;

2006-02-19 13:20:36

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [v4l-dvb-maintainer] Re: kbuild: Section mismatch warnings

On Sun, Feb 19, 2006 at 01:59:24PM +0100, Johannes Stezenbach wrote:
> ...
> > WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .init.text:av7110_ir_init from .text between 'av7110_attach' (at offset 0xcaa6) and 'av7110_detach'
> > WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .exit.text:av7110_ir_exit from .text between 'av7110_detach' (at offset 0xcbc5) and 'av7110_irq'
>
> These seem to be legitimate and point to the right place.
> Patch attached.

Thanks Johannes.
I assume you will carry the patch in the dvb tree and push to linus.

Sam

2006-02-19 13:30:32

by Johannes Stezenbach

[permalink] [raw]
Subject: Re: [v4l-dvb-maintainer] Re: kbuild: Section mismatch warnings

On Sun, Feb 19, 2006 at 02:19:53PM +0100, Sam Ravnborg wrote:
> On Sun, Feb 19, 2006 at 01:59:24PM +0100, Johannes Stezenbach wrote:
> > ...
> > > WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .init.text:av7110_ir_init from .text between 'av7110_attach' (at offset 0xcaa6) and 'av7110_detach'
> > > WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .exit.text:av7110_ir_exit from .text between 'av7110_detach' (at offset 0xcbc5) and 'av7110_irq'
> >
> > These seem to be legitimate and point to the right place.
> > Patch attached.
>
> Thanks Johannes.
> I assume you will carry the patch in the dvb tree and push to linus.

Sure, after I corrected it (av7110_ir_init shouldn't be __devexit)

Johannes

2006-02-19 14:18:42

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Sun, Feb 19, 2006 at 12:36:30PM +0100, Sam Ravnborg wrote:
>
> Question: Several modules contains init_module() cleanup_module() -
> for example floppy.o. I cannot see they are used anymore and subject for
> deletion - correct?

Digged a bit further into this.
In init.h the module_init() / module_exit() macros are defined.
They define an alias from the supplied function to
init_module() / cleanup_module().

Users of init_module() / cleanup_module() do have a ifdef section like
this:

#ifdef MODULE
init_module() ...
cleanup_module() ...
#else
module_init(modulename_init);
module_exit(modulename_exit);
#endif

So this seems to be modules that just needs a bit more
porting to the new module structure if I get it right.

What I missed when I asked the question was the #ifdef MODULE part.

Sam

2006-02-19 22:38:36

by Rusty Russell

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Sun, 2006-02-19 at 12:36 +0100, Sam Ravnborg wrote:
> The module parameter warning are still pending - I hope Rusty will
> comment on yhe suggested patch to use __initdata in the moduleparam
> macro.

kernel/params.c's param_sysfs_setup will have to make a copy if you do
this. At the moment it keeps the original structure around.

Hope that helps!
Rusty.
--
ccontrol: http://ozlabs.org/~rusty/ccontrol

2006-02-19 22:44:30

by Sam Ravnborg

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Mon, Feb 20, 2006 at 09:38:35AM +1100, Rusty Russell wrote:
> On Sun, 2006-02-19 at 12:36 +0100, Sam Ravnborg wrote:
> > The module parameter warning are still pending - I hope Rusty will
> > comment on yhe suggested patch to use __initdata in the moduleparam
> > macro.
>
> kernel/params.c's param_sysfs_setup will have to make a copy if you do
> this. At the moment it keeps the original structure around.
Was afraid something like this was needed. Will take a look what to do.
I will drop you a copy of any potential patch for review.

Sam

2006-02-22 05:20:48

by Greg KH

[permalink] [raw]
Subject: Re: kbuild: Section mismatch warnings

On Sun, Feb 19, 2006 at 01:21:33AM +0100, Sam Ravnborg wrote:
> On Fri, Feb 17, 2006 at 04:09:21PM -0800, Greg KH wrote:
> > On Fri, Feb 17, 2006 at 11:47:02PM +0100, Sam Ravnborg wrote:
> > > Background:
> > > I have introduced a build-time check for section mismatch and it showed
> > > up a great number of warnings.
> > > Below is the result of the run on a 2.6.16-rc1 tree (which my kbuild
> > > tree is based upon) based on a 'make allmodconfig'
>
> Greg - related to this I have thought a bit on __devinit versus __init.
> With HOTPLUG enabled __devinit becomes empty and thus violate any checks
> for illegal references to .init.text.

I _really_ hate __devinit. Almost everyone who uses it gets it wrong
the first time (like pci hotplug drivers using it, which is just
pointless...) Now that CONFIG_HOTPLUG is always enabled (well, it's a
lot harder to disable it now), hopefully when people get it wrong it
will not cause problems.

> Would it make sense to create a specific set of sections for __devinit
> and frinds so we could check that __devinit sections are not referenced from .text.
> This is another way to do the current __init checks but with HOTPLUG
> enabled and I like the result to be consistent with and without HOTPLUG
> enabled.

That's not a bad idea.

> Also I see __devinit being used in different ways. See sound/oss/mad16
> for instance.
> Only a few functions are marked __devinit nad I wonder if any should be
> marked __devinit at all in that file. But due to references to
> __initdata current checks discovered a potential bug here already today.

Like I said above, almost everyone uses it incorrectly. I went through
the whole tree sometime late 2.5 and fixed up everything. It's probably
time for another audit...

thanks,

greg k-h

2006-02-25 15:31:25

by Adrian Bunk

[permalink] [raw]
Subject: Re: [v4l-dvb-maintainer] Re: kbuild: Section mismatch warnings

On Sun, Feb 19, 2006 at 02:30:39PM +0100, Johannes Stezenbach wrote:
> On Sun, Feb 19, 2006 at 02:19:53PM +0100, Sam Ravnborg wrote:
> > On Sun, Feb 19, 2006 at 01:59:24PM +0100, Johannes Stezenbach wrote:
> > > ...
> > > > WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .init.text:av7110_ir_init from .text between 'av7110_attach' (at offset 0xcaa6) and 'av7110_detach'
> > > > WARNING: drivers/media/dvb/ttpci/dvb-ttpci.o - Section mismatch: reference to .exit.text:av7110_ir_exit from .text between 'av7110_detach' (at offset 0xcbc5) and 'av7110_irq'
> > >
> > > These seem to be legitimate and point to the right place.
> > > Patch attached.
> >
> > Thanks Johannes.
> > I assume you will carry the patch in the dvb tree and push to linus.
>
> Sure, after I corrected it (av7110_ir_init shouldn't be __devexit)

Could you submit this patch for 2.6.16.?

> Johannes

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed