kbuild: improved Section mismatch detection
Subsystems (16)
I have spent the last week (the time I can afford to Linux stuff anyway) to improve the Section mismatch warnings detected by modpost.
The problem until now has been that the Section mismatch warnings were dependent on the actual configuration of HOTPLUG, HOTPLUG_CPU and MEMORY_HOTPLUG. In the default configuration with HOTPLUG enbaled most of the remaining Section mismatch warnings were not seen and thus many of us thought that everything was great.
Adrian reminded us that KCFLAGS=-fno-inline told another story with more than 100 Section mismatch warnings on 64 bit x86 with an allyesconfig build.
As this was not acceptable I set out to make it less configuration dependent. To do so I quikly relaised that modpost had to be prepared before this was a feasible thing to implment.
This serie of patches is:
1) kbuild: fix so modpost can now check any .o file 2) kbuild: try harder to find symbol names in modpost 3) kbuild: code refactoring in modpost 4) kbuild: introduce blacklisting in modpost 5) kbuild: check section names consistently in modpost 6) all archs: consolidate init and exit sections in vmlinux.lds.h 7) compiler.h: introduce __section() 8) Use separate sections for __dev/__cpu/__mem code/data
Patch 6) makse a set of trivial changes in all arch vmlinux.lds.S files and the reason why I copid linux-arch on this mail.
Patch 4) is a major change in modpost where we no longer try to find all the good guys but instead look for the bad combinations. This should result in a lot less false warnings and for example got rid of an irritating warning on sparc64.
Patch 2) is important - previously modpost failed to find the correct symbol based on address lookup because it wanted an exact match. Allowing up to 20 bytes offset we now locate almost all symbols and the warnings are much easier to fix.
Randy and Adrian among others have done a great job fixing many Section mismatch warnngs over the last month.
But frankly much more people should do this and I can see people ignoring the warnings.
Therefore the plan is to turn the warnings into hard build errors at -rc1 time.
This should force people to actually fix the warnings they introduce.
But to do so we need the warnings we have today gettign fixed and the new improved modpost should help you here.
To further help the plans are to:
- add a config option to enable -fno-inline (or a similar option)
- make the warnings from modpost more descriptive but longer
- maybe to spend a few hours to fix some of the obvious candidates Less than half an hour for each warning for the trivial cases
- Maybe start using __INIT and friends in assembler code xen had two bugs in this area recently for example.
It has been questions if it is worth the effort to fix these warnings. Randy just fixed three oops candidates - do anyone need more facts?
And the cpu code looks rather fragile in the dead/removed CPU cases. I see several references that will oops and is easy to fix.
Sam
PATCH 1/1 kbuild: fix so modpost can now check any .o file
It is very convinient to say:scripts/mod/modpost mm/built-in.o
to check if any section mismatch errors occured
in mm/ (as an example).
Fix it so this is possible again.
--- scripts/mod/modpost.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
scripts/mod/modpost.c +2 -1
@@ -1299,7 +1299,8 @@ static void read_symbols(char *modname)handle_modversions (mod, &info, sym, symname);handle_moddevtable (mod, &info, sym, symname); } -if (is_vmlinux (modname) && vmlinux_section_warnings) { +if (!is_vmlinux (modname) || + (is_vmlinux (modname) && vmlinux_section_warnings)) {check_sec_ref (mod, modname, &info, init_section, init_section_ref_ok);check_sec_ref (mod, modname, &info, exit_section, exit_section_ref_ok); }
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 kbuild: try harder to find symbol names in modpost
The relocation record sometimes contained an address which was not an exactly match for a symbol.
Implment some simple logic such that if there is a symbol within 20 bytes of the address contained in the relocation record then print the name of this symbol.
With this change modpost could find symbol names for the remaining .init.text symbols in my allyesconfig build for x86_64.
--- scripts/mod/modpost.c | 19 +++++++++++++++++-- scripts/mod/modpost.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-)
scripts/mod/modpost.c +17 -2
@@ -776,10 +776,13 @@ static int secref_whitelist(const char *modname, const char *tosec,* In other cases the symbol needs to be looked up in the symbol table * based on section and address. * **/ -static Elf_Sym *find_elf_symbol (struct elf_info *elf,Elf_Addr addr, +static Elf_Sym *find_elf_symbol (struct elf_info *elf,Elf64_Sword addr,Elf_Sym *relsym) {Elf_Sym *sym; +Elf_Sym *near =NULL ; +Elf64_Sword distance =20 ; +Elf64_Sword d;if (relsym->st_name !=0 )return relsym;
@@ -790,8 +793,20 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,continue ;if (sym->st_value == addr)return sym; +/* Find a symbol nearby - addr are maybe negative */ + d = sym->st_value - addr; +if (d <0 ) + d = addr - sym->st_value; +if (d < distance) { + distance = d; + near = sym; + } } -return NULL ; +/* We need a close match */ +if (distance <20 ) +return near; +else +return NULL ; }static inline int is_arm_mapping_symbol (const char *str)
scripts/mod/modpost.h +2 -0
@@ -17,6 +17,7 @@#define Elf_Shdr Elf32_Shdr#define Elf_Sym Elf32_Sym#define Elf_Addr Elf32_Addr +#define Elf_Sword Elf64_Sword#define Elf_Section Elf32_Half#define ELF_ST_BIND ELF32_ST_BIND#define ELF_ST_TYPE ELF32_ST_TYPE
@@ -31,6 +32,7 @@#define Elf_Shdr Elf64_Shdr#define Elf_Sym Elf64_Sym#define Elf_Addr Elf64_Addr +#define Elf_Sword Elf64_Sxword#define Elf_Section Elf64_Half#define ELF_ST_BIND ELF64_ST_BIND#define ELF_ST_TYPE ELF64_ST_TYPE
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 kbuild: code refactoring in modpost
Split a too long function up in smaller bits to make prgram logic easier to follow.
A few related changes done due to parameter changes.
No functional changes.
--- scripts/mod/modpost.c | 242 ++++++++++++++++++++++++++++--------------------- 1 files changed, 137 insertions(+), 105 deletions(-)
scripts/mod/modpost.c +137 -105
@@ -937,19 +937,19 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, }static unsigned int *reloc_location (struct elf_info *elf, -int rsection,Elf_Rela *r) +Elf_Shdr *sechdr,Elf_Rela *r) {Elf_Shdr *sechdrs = elf->sechdrs; -int section = sechdrs[rsection].sh_info; +int section = sechdr->sh_info;return (void *)elf->hdr + sechdrs[section].sh_offset + (r->r_offset - sechdrs[section].sh_addr); } -static int addend_386_rel (struct elf_info *elf,int rsection,Elf_Rela *r) +static int addend_386_rel (struct elf_info *elf,Elf_Shdr *sechdr,Elf_Rela *r) {unsigned int r_typ =ELF_R_TYPE (r->r_info); -unsigned int *location =reloc_location (elf, rsection, r); +unsigned int *location =reloc_location (elf, sechdr, r);switch (r_typ) {case R_386_32 :
@@ -965,7 +965,7 @@ static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r)return 0 ; } -static int addend_arm_rel (struct elf_info *elf,int rsection,Elf_Rela *r) +static int addend_arm_rel (struct elf_info *elf,Elf_Shdr *sechdr,Elf_Rela *r) {unsigned int r_typ =ELF_R_TYPE (r->r_info);
@@ -978,8 +978,8 @@ static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r)case R_ARM_PC24 :/* From ARM ABI: ((S + A) | T) - P */ r->r_addend = (int )(long )(elf->hdr + - elf->sechdrs[rsection].sh_offset + - (r->r_offset - elf->sechdrs[rsection].sh_addr)); + sechdr->sh_offset + + (r->r_offset - sechdr->sh_addr));break ;default :return 1 ;
@@ -987,10 +987,10 @@ static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r)return 0 ; } -static int addend_mips_rel (struct elf_info *elf,int rsection,Elf_Rela *r) +static int addend_mips_rel (struct elf_info *elf,Elf_Shdr *sechdr,Elf_Rela *r) {unsigned int r_typ =ELF_R_TYPE (r->r_info); -unsigned int *location =reloc_location (elf, rsection, r); +unsigned int *location =reloc_location (elf, sechdr, r);unsigned int inst;if (r_typ ==R_MIPS_HI16 )
@@ -1010,6 +1010,128 @@ static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r)return 0 ; } +static void section_rela (const char *modname,struct elf_info *elf, +Elf_Shdr *sechdr,int section (const char *), +int section_ref_ok (const char *)) +{ +Elf_Sym *sym; +Elf_Rela *rela; +Elf_Rela r; +unsigned int r_sym; +const char *fromsec; +const char * tosec; + +Elf_Ehdr *hdr = elf->hdr; +Elf_Rela *start = (void *)hdr + sechdr->sh_offset; +Elf_Rela *stop = (void *)start + sechdr->sh_size; + +const char *secstrings = (void *)hdr + + elf->sechdrs[hdr->e_shstrndx].sh_offset; + + fromsec = secstrings + sechdr->sh_name; + fromsec +=strlen (".rela" ); +/* if from section (name) is know good then skip it */ +if (section_ref_ok (fromsec)) +return ; + +for (rela = start; rela < stop; rela++) { + r.r_offset =TO_NATIVE (rela->r_offset); +#if KERNEL_ELFCLASS ==ELFCLASS64 +if (hdr->e_machine ==EM_MIPS ) { +unsigned int r_typ; + r_sym =ELF64_MIPS_R_SYM (rela->r_info); + r_sym =TO_NATIVE (r_sym); + r_typ =ELF64_MIPS_R_TYPE (rela->r_info); + r.r_info =ELF64_R_INFO (r_sym, r_typ); + }else { + r.r_info =TO_NATIVE (rela->r_info); + r_sym =ELF_R_SYM (r.r_info); + } +#else + r.r_info =TO_NATIVE (rela->r_info); + r_sym =ELF_R_SYM (r.r_info); +#endif + r.r_addend =TO_NATIVE (rela->r_addend); + sym = elf->symtab_start + r_sym; +/* Skip special sections */ +if (sym->st_shndx >=SHN_LORESERVE ) +continue ; + + tosec = secstrings + + elf->sechdrs[sym->st_shndx].sh_name; +if (section (tosec)) +warn_sec_mismatch (modname, fromsec, elf, sym, r); + } +} + +static void section_rel (const char *modname,struct elf_info *elf, +Elf_Shdr *sechdr,int section (const char *), +int section_ref_ok (const char *)) +{ +Elf_Sym *sym; +Elf_Rel *rel; +Elf_Rela r; +unsigned int r_sym; +const char *fromsec; +const char * tosec; + +Elf_Ehdr *hdr = elf->hdr; +Elf_Rel *start = (void *)hdr + sechdr->sh_offset; +Elf_Rel *stop = (void *)start + sechdr->sh_size; + +const char *secstrings = (void *)hdr + + elf->sechdrs[hdr->e_shstrndx].sh_offset; + + fromsec = secstrings + sechdr->sh_name; + fromsec +=strlen (".rel" ); +/* if from section (name) is know good then skip it */ +if (section_ref_ok (fromsec)) +return ; + +for (rel = start; rel < stop; rel++) { + r.r_offset =TO_NATIVE (rel->r_offset); +#if KERNEL_ELFCLASS ==ELFCLASS64 +if (hdr->e_machine ==EM_MIPS ) { +unsigned int r_typ; + r_sym =ELF64_MIPS_R_SYM (rel->r_info); + r_sym =TO_NATIVE (r_sym); + r_typ =ELF64_MIPS_R_TYPE (rel->r_info); + r.r_info =ELF64_R_INFO (r_sym, r_typ); + }else { + r.r_info =TO_NATIVE (rel->r_info); + r_sym =ELF_R_SYM (r.r_info); + } +#else + r.r_info =TO_NATIVE (rel->r_info); + r_sym =ELF_R_SYM (r.r_info); +#endif + r.r_addend =0 ; +switch (hdr->e_machine) { +case EM_386 : +if (addend_386_rel (elf, sechdr, &r)) +continue ; +break ; +case EM_ARM : +if (addend_arm_rel (elf, sechdr, &r)) +continue ; +break ; +case EM_MIPS : +if (addend_mips_rel (elf, sechdr, &r)) +continue ; +break ; + } + sym = elf->symtab_start + r_sym; +/* Skip special sections */ +if (sym->st_shndx >=SHN_LORESERVE ) +continue ; + + tosec = secstrings + + elf->sechdrs[sym->st_shndx].sh_name; +if (section (tosec)) +warn_sec_mismatch (modname, fromsec, elf, sym, r); + } +} +/** * A module includes a number of sections that are discarded * either when loaded or when used as built-in.
@@ -1028,108 +1150,18 @@ static void check_sec_ref(struct module *mod, const char *modname, 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; -const char *secname; -Elf_Rela r; -unsigned int r_sym;/* We want to process only relocation sections and not .init */ -if (sechdrs[i].sh_type ==SHT_RELA ) { -Elf_Rela *rela; -Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset; -Elf_Rela *stop = (void *)start + sechdrs[i].sh_size; - name +=strlen (".rela" ); -if (section_ref_ok (name)) -continue ; - -for (rela = start; rela < stop; rela++) { - r.r_offset =TO_NATIVE (rela->r_offset); -#if KERNEL_ELFCLASS ==ELFCLASS64 -if (hdr->e_machine ==EM_MIPS ) { -unsigned int r_typ; - r_sym =ELF64_MIPS_R_SYM (rela->r_info); - r_sym =TO_NATIVE (r_sym); - r_typ =ELF64_MIPS_R_TYPE (rela->r_info); - r.r_info =ELF64_R_INFO (r_sym, r_typ); - }else { - r.r_info =TO_NATIVE (rela->r_info); - r_sym =ELF_R_SYM (r.r_info); - } -#else - r.r_info =TO_NATIVE (rela->r_info); - r_sym =ELF_R_SYM (r.r_info); -#endif - r.r_addend =TO_NATIVE (rela->r_addend); - sym = elf->symtab_start + r_sym; -/* Skip special sections */ -if (sym->st_shndx >=SHN_LORESERVE ) -continue ; - - secname = secstrings + - sechdrs[sym->st_shndx].sh_name; -if (section (secname)) -warn_sec_mismatch (modname, name, - elf, sym, r); - } - }else if (sechdrs[i].sh_type ==SHT_REL ) { -Elf_Rel *rel; -Elf_Rel *start = (void *)hdr + sechdrs[i].sh_offset; -Elf_Rel *stop = (void *)start + sechdrs[i].sh_size; - name +=strlen (".rel" ); -if (section_ref_ok (name)) -continue ; - -for (rel = start; rel < stop; rel++) { - r.r_offset =TO_NATIVE (rel->r_offset); -#if KERNEL_ELFCLASS ==ELFCLASS64 -if (hdr->e_machine ==EM_MIPS ) { -unsigned int r_typ; - r_sym =ELF64_MIPS_R_SYM (rel->r_info); - r_sym =TO_NATIVE (r_sym); - r_typ =ELF64_MIPS_R_TYPE (rel->r_info); - r.r_info =ELF64_R_INFO (r_sym, r_typ); - }else { - r.r_info =TO_NATIVE (rel->r_info); - r_sym =ELF_R_SYM (r.r_info); - } -#else - r.r_info =TO_NATIVE (rel->r_info); - r_sym =ELF_R_SYM (r.r_info); -#endif - r.r_addend =0 ; -switch (hdr->e_machine) { -case EM_386 : -if (addend_386_rel (elf, i, &r)) -continue ; -break ; -case EM_ARM : -if (addend_arm_rel (elf, i, &r)) -continue ; -break ; -case EM_MIPS : -if (addend_mips_rel (elf, i, &r)) -continue ; -break ; - } - sym = elf->symtab_start + r_sym; -/* Skip special sections */ -if (sym->st_shndx >=SHN_LORESERVE ) -continue ; - - secname = secstrings + - sechdrs[sym->st_shndx].sh_name; -if (section (secname)) -warn_sec_mismatch (modname, name, - elf, sym, r); - } - } +if (sechdrs[i].sh_type ==SHT_RELA ) +section_rela (modname, elf, &elf->sechdrs[i], + section, section_ref_ok); +else if (sechdrs[i].sh_type ==SHT_REL ) +section_rel (modname, elf, &elf->sechdrs[i], + section, section_ref_ok); } }
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 kbuild: introduce blacklisting in modpost
Change the logic in modpost so we identify all the bad combinations of sections that refer to other sections.
Compared to the previous approach we are much less dependent on knowledge of what additional sections the tool chain uses and thus we can keep the false positives low.
The implmentation is changed to use a table based lookup and we now check all combinations in first pass so we no longer need separate passes for init and exit sections.
Tested that the same warnings are generated for an allyesconfig build without CONFIG_HOTPLUG.
--- scripts/mod/modpost.c | 305 +++++++++++++++++++++---------------------------- 1 files changed, 128 insertions(+), 177 deletions(-)
scripts/mod/modpost.c +128 -177
@@ -605,6 +605,61 @@ static int strrcmp(const char *s, const char *sub)return memcmp (s + slen - sublen, sub, sublen); } +/* if sym is empty or point to a string +* like ".[0-9]+" then return 1. +* This is the optional prefix added by ld to some sections +*/ +static int number_prefix (const char *sym) +{ +if (*sym++ =='\0' ) +return 1 ; +if (*sym !='.' ) +return 0 ; +do { +char c = *sym++; +if (c <'0' || c >'9' ) +return 0 ; + }while (*sym); +return 1 ; +} + +/* The pattern is an array of simple patterns. +* "foo" will match an exact string equal to "foo" +* "foo*" will match a string that begins with "foo" +* "foo$" will match a string equal to "foo" or "foo.1" +* where the '1' can be any number including several digits. +* The $ syntax is for sections where ld append a dot number +* to make section name unique. +*/ +int match (const char *sym,const char *const pat[]) +{ +const char *p; +while (*pat) { + p = *pat++; +const char *endp = p +strlen (p) -1 ; + +/* "foo*" */ +if (*endp =='*' ) { +if (strncmp (sym, p,strlen (p) -1 ) ==0 ) +return 1 ; + } +/* "foo$" */ +else if (*endp =='$' ) { +if (strncmp (sym, p,strlen (p) -1 ) ==0 ) { +if (number_prefix (sym +strlen (p) -1 )) +return 1 ; + } + } +/* no wildcards */ +else { +if (strcmp (p, sym) ==0 ) +return 1 ; + } + } +/* no match */ +return 0 ; +} +/* * 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
@@ -653,6 +708,68 @@ static int data_section(const char *name)return 0 ; } +/* sections that we do not want to do full section mismatch check on */ +static const char *section_white_list[] = + {".debug*" ,".stab*" ,".note*" ,".got*" ,".toc*" ,NULL }; + +#define INIT_DATA_SECTIONS ".init.data$" +#define EXIT_DATA_SECTIONS ".exit.data$" + +#define INIT_TEXT_SECTIONS ".init.text$" +#define EXIT_TEXT_SECTIONS ".exit.text$" + +#define INIT_SECTIONS INIT_DATA_SECTIONS, INIT_TEXT_SECTIONS +#define EXIT_SECTIONS EXIT_DATA_SECTIONS, EXIT_TEXT_SECTIONS + +#define DATA_SECTIONS ".data$" +#define TEXT_SECTIONS ".text$" + +struct sectioncheck { +const char *fromsec[20 ]; +const char *tosec[20 ]; +}; + +const struct sectioncheck sectioncheck[] = { +/* Do not reference init/exit code/data from +* normal code and data +*/ +{ + .fromsec = {TEXT_SECTIONS ,DATA_SECTIONS ,NULL }, + .tosec = {INIT_SECTIONS ,EXIT_SECTIONS ,NULL } +}, +/* Do not use exit code/data from init code */ +{ + .fromsec = {INIT_SECTIONS ,NULL }, + .tosec = {EXIT_SECTIONS ,NULL }, +}, +/* Do not use init code/data from exit code */ +{ + .fromsec = {EXIT_SECTIONS ,NULL }, + .tosec = {INIT_SECTIONS ,NULL } +}, +/* Do not export init/exit functions or data */ +{ + .fromsec = {"__ksymtab*" ,NULL }, + .tosec = {INIT_SECTIONS ,EXIT_SECTIONS ,NULL } +} +}; + +static int section_mismatch (const char *fromsec,const char *tosec) +{ +int i; +int elems =sizeof (sectioncheck) /sizeof (struct sectioncheck ); +const struct sectioncheck *check = §ioncheck[0 ]; + +for (i =0 ; i < elems; i++) { +if (match (fromsec, check->fromsec) && +match (tosec, check->tosec)) +return 1 ; + check++; + } +return 0 ; +} + +/** * Whitelist to allow certain references to pass with no warning. *
@@ -695,18 +812,11 @@ static int data_section(const char *name)* This pattern is identified by * refsymname = __init_begin, _sinittext, _einittext * -* Pattern 5: -* Xtensa uses literal sections for constants that are accessed PC-relative. -* Literal sections may safely reference their text sections. -* (Note that the name for the literal section omits any trailing '.text') -* tosec = <section>[.text] -* fromsec = <section>.literal **/ static int secref_whitelist (const char *modname,const char *tosec,const char *fromsec,const char *atsym,const char *refsymname) { -int len;const char **s;const char *pat2sym[] = {"driver" ,
@@ -757,15 +867,6 @@ static int secref_whitelist(const char *modname, const char *tosec,if (strcmp (refsymname, *s) ==0 )return 1 ; -/* Check for pattern 5 */ -if (strrcmp (tosec,".text" ) ==0 ) - len =strlen (tosec) -strlen (".text" ); -else - len =strlen (tosec); -if ((strncmp (tosec, fromsec, len) ==0 ) && (strlen (fromsec) > len) && - (strcmp (fromsec + len,".literal" ) ==0 )) -return 1 ; -return 0 ; }
@@ -1011,8 +1112,7 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) }static void section_rela (const char *modname,struct elf_info *elf, -Elf_Shdr *sechdr,int section (const char *), -int section_ref_ok (const char *)) +Elf_Shdr *sechdr) {Elf_Sym *sym;Elf_Rela *rela;
@@ -1031,7 +1131,7 @@ static void section_rela(const char *modname, struct elf_info *elf, fromsec = secstrings + sechdr->sh_name; fromsec +=strlen (".rela" );/* if from section (name) is know good then skip it */ -if (section_ref_ok (fromsec)) +if (match (fromsec, section_white_list))return ;for (rela = start; rela < stop; rela++) {
@@ -1059,14 +1159,13 @@ static void section_rela(const char *modname, struct elf_info *elf, tosec = secstrings + elf->sechdrs[sym->st_shndx].sh_name; -if (section (tosec)) +if (section_mismatch (fromsec, tosec))warn_sec_mismatch (modname, fromsec, elf, sym, r); } }static void section_rel (const char *modname,struct elf_info *elf, -Elf_Shdr *sechdr,int section (const char *), -int section_ref_ok (const char *)) +Elf_Shdr *sechdr) {Elf_Sym *sym;Elf_Rel *rel;
@@ -1085,7 +1184,7 @@ static void section_rel(const char *modname, struct elf_info *elf, fromsec = secstrings + sechdr->sh_name; fromsec +=strlen (".rel" );/* if from section (name) is know good then skip it */ -if (section_ref_ok (fromsec)) +if (match (fromsec, section_white_list))return ;for (rel = start; rel < stop; rel++) {
@@ -1127,7 +1226,7 @@ static void section_rel(const char *modname, struct elf_info *elf, tosec = secstrings + elf->sechdrs[sym->st_shndx].sh_name; -if (section (tosec)) +if (section_mismatch (fromsec, tosec))warn_sec_mismatch (modname, fromsec, elf, sym, r); } }
@@ -1145,9 +1244,7 @@ static void section_rel(const char *modname, struct elf_info *elf,* 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 *)) +struct elf_info *elf) {int i;Elf_Ehdr *hdr = elf->hdr;
@@ -1157,156 +1254,12 @@ static void check_sec_ref(struct module *mod, const char *modname,for (i =0 ; i < hdr->e_shnum; i++) {/* We want to process only relocation sections and not .init */ if (sechdrs[i].sh_type ==SHT_RELA ) -section_rela (modname, elf, &elf->sechdrs[i], - section, section_ref_ok); +section_rela (modname, elf, &elf->sechdrs[i]);else if (sechdrs[i].sh_type ==SHT_REL ) -section_rel (modname, elf, &elf->sechdrs[i], - section, section_ref_ok); +section_rel (modname, elf, &elf->sechdrs[i]); } } -/* -* Identify sections from which references to either a -* .init or 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. -* [.rodata] like for .init.text we ignore .rodata references -same reason -*/ -static int initexit_section_ref_ok (const char *name) -{ -const char **s; -/* Absolute section names */ -const char *namelist1[] = { -"__bug_table" ,/* used by powerpc for BUG() */ -"__ex_table" , -".altinstructions" , -".cranges" ,/* used by sh64 */ -".fixup" , -".machvec" ,/* ia64 + powerpc uses these */ -".machine.desc" , -".opd" ,/* See comment [OPD] */ -"__dbe_table" , -".parainstructions" , -".pdr" , -".plt" ,/* seen on ARCH=um build on x86_64. Harmless */ -".smp_locks" , -".stab" , -".m68k_fixup" , -".xt.prop" ,/* xtensa informational section */ -".xt.lit" ,/* xtensa informational section */ -NULL - }; -/* Start of section names */ -const char *namelist2[] = { -".debug" , -".eh_frame" , -".note" ,/* ignore ELF notes - may contain anything */ -".got" ,/* powerpc - global offset table */ -".toc" ,/* powerpc - table of contents */ -NULL - }; -/* part of section name */ -const char *namelist3 [] = { -".unwind" ,/* Sample: IA_64.unwind.exit.text */ -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 ; -for (s = namelist3; *s; s++) -if (strstr (name, *s) !=NULL ) -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[] = { -"__dbe_table" ,/* MIPS generate these */ -"__ftr_fixup" ,/* powerpc cpu feature fixup */ -"__fw_ftr_fixup" ,/* powerpc firmware feature fixup */ -"__param" , -".data.rel.ro" ,/* used by parisc64 */ -".init" , -".text.lock" , -NULL - }; -/* Start of section names */ -const char *namelist2[] = { -".init." , -".pci_fixup" , -".rodata" , -NULL - }; - -if (initexit_section_ref_ok (name)) -return 1 ; - -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 ; - -/* If section name ends with ".init" we allow references -* as is the case with .initcallN.init, .early_param.init, -* .taglist.init etc -*/ -if (strrcmp (name,".init" ) ==0 ) -return 1 ; -return 0 ; -} - -/* -* Identify sections from which references to a .exit section is OK. -*/ -static int exit_section_ref_ok (const char *name) -{ -const char **s; -/* Absolute section names */ -const char *namelist1[] = { -".exit.data" , -".exit.text" , -".exitcall.exit" , -".rodata" , -NULL - }; - -if (initexit_section_ref_ok (name)) -return 1 ; - -for (s = namelist1; *s; s++) -if (strcmp (*s, name) ==0 ) -return 1 ; -return 0 ; -} -static void read_symbols (char *modname) {const char *symname;
@@ -1347,10 +1300,8 @@ static void read_symbols(char *modname)handle_moddevtable (mod, &info, sym, symname); }if (!is_vmlinux (modname) || - (is_vmlinux (modname) && vmlinux_section_warnings)) { -check_sec_ref (mod, modname, &info, init_section, init_section_ref_ok); -check_sec_ref (mod, modname, &info, exit_section, exit_section_ref_ok); - } + (is_vmlinux (modname) && vmlinux_section_warnings)) +check_sec_ref (mod, modname, &info); version =get_modinfo (info.modinfo, info.modinfo_len,"version" );if (version)
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 kbuild: check section names consistently in modpost
Now that match() is introduced use it consistently so we can share the section name definitions.
--- scripts/mod/modpost.c | 146 ++++++++++++++++++++----------------------------- 1 files changed, 60 insertions(+), 86 deletions(-)
scripts/mod/modpost.c +60 -86
@@ -625,6 +625,7 @@ static int number_prefix(const char *sym)/* The pattern is an array of simple patterns. * "foo" will match an exact string equal to "foo" +* "*foo" will match a string that ends with "foo" * "foo*" will match a string that begins with "foo" * "foo$" will match a string equal to "foo" or "foo.1" * where the '1' can be any number including several digits.
@@ -638,8 +639,13 @@ int match(const char *sym, const char * const pat[]) p = *pat++;const char *endp = p +strlen (p) -1 ; +/* "*foo" */ +if (*p =='*' ) { +if (strrcmp (sym, p +1 ) ==0 ) +return 1 ; + }/* "foo*" */ -if (*endp =='*' ) { +else if (*endp =='*' ) {if (strncmp (sym, p,strlen (p) -1 ) ==0 )return 1 ; }
@@ -660,54 +666,6 @@ int match(const char *sym, const char * const pat[])return 0 ; } -/* -* 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 ; -} - -/* -* 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 ; - -} - -/* -* Data sections are named like this: -* .data | .data.rel | .data.rel.* -* Return 1 if the specified section is a data section -*/ -static int data_section (const char *name) -{ -if ((strcmp (name,".data" ) ==0 ) || - (strcmp (name,".data.rel" ) ==0 ) || - (strncmp (name,".data.rel." ,strlen (".data.rel." )) ==0 )) -return 1 ; -else -return 0 ; -} -/* sections that we do not want to do full section mismatch check on */ static const char *section_white_list[] = {".debug*" ,".stab*" ,".note*" ,".got*" ,".toc*" ,NULL };
@@ -721,9 +679,50 @@ static const char *section_white_list[] =#define INIT_SECTIONS INIT_DATA_SECTIONS, INIT_TEXT_SECTIONS#define EXIT_SECTIONS EXIT_DATA_SECTIONS, EXIT_TEXT_SECTIONS -#define DATA_SECTIONS ".data$" +#define DATA_SECTIONS ".data$", ".data.rel$"#define TEXT_SECTIONS ".text$" +/* init data sections */ +static const char *init_data_sections[] = {INIT_DATA_SECTIONS ,NULL }; + +/* all init sections */ +static const char *init_sections[] = {INIT_SECTIONS ,NULL }; + +/* All init and exit sections (code + data) */ +static const char *init_exit_sections[] = + {INIT_SECTIONS ,EXIT_SECTIONS ,NULL }; + +/* data section */ +static const char *data_sections[] = {DATA_SECTIONS ,NULL }; + +/* sections that may refer to an init/exit section with no warning */ +static const char *initref_sections[] = +{ +".text.init.refok*" , +".exit.text.refok*" , +".data.init.refok*" , +NULL +}; + + +/* symbols in .data that may refer to init/exit sections */ +static const char *symbol_white_list[] = +{ +"*driver" , +"*_template" ,/* scsi uses *_template a lot */ +"*_timer" ,/* arm uses ops structures named _timer a lot */ +"*_sht" ,/* scsi also used *_sht to some extent */ +"*_ops" , +"*_probe" , +"*_probe_one" , +"*_console" , +NULL +}; + +static const char *head_sections[] = {".head.text*" ,NULL }; +static const char *linker_symbols[] = + {"__init_begin" ,"_sinittext" ,"_einittext" ,NULL }; +struct sectioncheck {const char *fromsec[20 ];const char *tosec[20 ];
@@ -817,55 +816,30 @@ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, const char *refsymname) { - const char **s; -const char *pat2sym[] = { -"driver" , -"_template" ,/* scsi uses *_template a lot */ -"_timer" ,/* arm uses ops structures named _timer a lot */ -"_sht" ,/* scsi also used *_sht to some extent */ -"_ops" , -"_probe" , -"_probe_one" , -"_console" , -NULL - }; - -const char *pat3refsym[] = { -"__init_begin" , -"_sinittext" , -"_einittext" , -NULL - }; - /* Check for pattern 0 */ -if ((strncmp (fromsec,".text.init.refok" ,strlen (".text.init.refok" )) ==0 ) || - (strncmp (fromsec,".exit.text.refok" ,strlen (".exit.text.refok" )) ==0 ) || - (strncmp (fromsec,".data.init.refok" ,strlen (".data.init.refok" )) ==0 )) + if (match(fromsec, initref_sections)) return 1; /* Check for pattern 1 */ -if ((strcmp (tosec,".init.data" ) ==0 ) && - (strncmp (fromsec,".data" ,strlen (".data" )) ==0 ) && + if (match(tosec, init_data_sections) && + match(fromsec, data_sections) && (strncmp(atsym, "__param", strlen("__param")) == 0)) return 1; /* Check for pattern 2 */ -if ((init_section (tosec) ||exit_section (tosec)) - &&data_section (fromsec)) -for (s = pat2sym; *s; s++) -if (strrcmp (atsym, *s) ==0 ) -return 1 ; + if (match(tosec, init_exit_sections) && + match(fromsec, data_sections) && + match(atsym, symbol_white_list)) + return 1; /* Check for pattern 3 */ -if ((strcmp (fromsec,".text.head" ) ==0 ) && - ((strcmp (tosec,".init.data" ) ==0 ) || - (strcmp (tosec,".init.text" ) ==0 ))) + if (match(fromsec, head_sections) && + match(tosec, init_sections)) return 1; /* Check for pattern 4 */ -for (s = pat3refsym; *s; s++) -if (strcmp (refsymname, *s) ==0 ) -return 1 ; + if (match(refsymname, linker_symbols)) + return 1; return 0; }
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 all archs: consolidate init and exit sections in vmlinux.lds.h
This patch consolidate all definitions of .init.text, .init.data and .exit.text, .exit.data section definitions in
the generic vmlinux.lds.h.
This is a preparational patch - alone it does not buy us much good.
--- arch/alpha/kernel/vmlinux.lds.S | 8 ++++---- arch/arm/kernel/vmlinux.lds.S | 10 +++++----- arch/avr32/kernel/vmlinux.lds.S | 8 ++++---- arch/blackfin/kernel/vmlinux.lds.S | 8 ++++---- arch/cris/arch-v10/vmlinux.lds.S | 8 ++++---- arch/cris/arch-v32/vmlinux.lds.S | 8 ++++---- arch/frv/kernel/vmlinux.lds.S | 14 +++++++------- arch/h8300/kernel/vmlinux.lds.S | 8 ++++---- arch/ia64/kernel/vmlinux.lds.S | 8 ++++---- arch/m32r/kernel/vmlinux.lds.S | 12 ++++++------ arch/m68k/kernel/vmlinux-std.lds | 8 ++++---- arch/m68k/kernel/vmlinux-sun3.lds | 8 ++++---- arch/m68knommu/kernel/vmlinux.lds.S | 8 ++++---- arch/mips/kernel/vmlinux.lds.S | 8 ++++---- arch/parisc/kernel/vmlinux.lds.S | 8 ++++---- arch/powerpc/kernel/vmlinux.lds.S | 10 ++++++---- arch/ppc/kernel/vmlinux.lds.S | 8 ++++---- arch/s390/kernel/vmlinux.lds.S | 8 ++++---- arch/sh/kernel/vmlinux.lds.S | 8 ++++---- arch/sh64/kernel/vmlinux.lds.S | 8 ++++---- arch/sparc/kernel/vmlinux.lds.S | 8 ++++---- arch/sparc64/kernel/vmlinux.lds.S | 8 ++++---- arch/um/kernel/dyn.lds.S | 4 ++-- arch/um/kernel/uml.lds.S | 4 ++-- arch/v850/kernel/vmlinux.lds.S | 10 +++++----- arch/x86/kernel/vmlinux_32.lds.S | 14 ++++++++++---- arch/x86/kernel/vmlinux_64.lds.S | 19 +++++++++++++------ arch/xtensa/kernel/vmlinux.lds.S | 9 +++++---- include/asm-generic/vmlinux.lds.h | 7 +++++++ 29 files changed, 140 insertions(+), 117 deletions(-)
arch/alpha/kernel/vmlinux.lds.S +4 -4
@@ -46,11 +46,11 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16);
@@ -136,8 +136,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/arm/kernel/vmlinux.lds.S +5 -5
@@ -30,7 +30,7 @@ SECTIONS } .init : { /* Init code and data */ - *(.init.text) + INIT_TEXT _einittext = .; __proc_info_begin = .; *(.proc.info.init)
@@ -70,15 +70,15 @@ SECTIONS __per_cpu_end = .; #ifndef CONFIG_XIP_KERNEL __init_begin = _stext; - *(.init.data) + INIT_DATA . = ALIGN(4096); __init_end = .; #endif } /DISCARD/ : { /* Exit code and data */ - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) #ifndef CONFIG_MMU *(.fixup)
@@ -129,7 +129,7 @@ SECTIONS #ifdef CONFIG_XIP_KERNEL . = ALIGN(4096); __init_begin = .; - *(.init.data) + INIT_DATA . = ALIGN(4096); __init_end = .; #endif
arch/avr32/kernel/vmlinux.lds.S +4 -4
@@ -27,19 +27,19 @@ SECTIONS __init_begin = .; _sinittext = .; *(.text.reset) - *(.init.text) + INIT_TEXT /* * .exit.text is discarded at runtime, not * link time, to deal with references from * __bug_table */ - *(.exit.text) + EXIT_TEXT _einittext = .; . = ALIGN(4); __tagtable_begin = .; *(.taglist.init) __tagtable_end = .; - *(.init.data) + INIT_DATA . = ALIGN(16); __setup_start = .; *(.init.setup)
@@ -135,7 +135,7 @@ SECTIONS * thrown away, as cleanup code is never called unless it's a module. */ /DISCARD/ : { - *(.exit.data) + EXIT_DATA *(.exitcall.exit) }
arch/blackfin/kernel/vmlinux.lds.S +4 -4
@@ -91,13 +91,13 @@ SECTIONS { . = ALIGN(PAGE_SIZE); __sinittext = .; - *(.init.text) + INIT_TEXT __einittext = .; } .init.data : { . = ALIGN(16); - *(.init.data) + INIT_DATA } .init.setup : {
@@ -198,8 +198,8 @@ SECTIONS /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } }
arch/cris/arch-v10/vmlinux.lds.S +4 -4
@@ -56,10 +56,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) }
@@ -112,8 +112,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.text.exit) - *(.data.exit) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/cris/arch-v32/vmlinux.lds.S +4 -4
@@ -61,10 +61,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) }
@@ -124,8 +124,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.text.exit) - *(.data.exit) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/frv/kernel/vmlinux.lds.S +7 -7
@@ -28,14 +28,14 @@ SECTIONS .init.text : { *(.text.head) #ifndef CONFIG_DEBUG_INFO - *(.init.text) - *(.exit.text) - *(.exit.data) + INIT_TEXT + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) #endif } _einittext = .; - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(8); __setup_start = .;
@@ -106,8 +106,8 @@ SECTIONS LOCK_TEXT #ifdef CONFIG_DEBUG_INFO *( - .init.text - .exit.text + INIT_TEXT + EXIT_TEXT .exitcall.exit ) #endif
@@ -138,7 +138,7 @@ SECTIONS .data : { /* Data */ DATA_DATA *(.data.*) - *(.exit.data) + EXIT_DATA CONSTRUCTORS }
arch/h8300/kernel/vmlinux.lds.S +4 -4
@@ -110,9 +110,9 @@ SECTIONS . = ALIGN(0x4) ; ___init_begin = .; __sinittext = .; - *(.init.text) + INIT_TEXT __einittext = .; - *(.init.data) + INIT_DATA . = ALIGN(0x4) ; ___setup_start = .; *(.init.setup)
@@ -124,8 +124,8 @@ SECTIONS ___con_initcall_start = .; *(.con_initcall.init) ___con_initcall_end = .; - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA #if defined(CONFIG_BLK_DEV_INITRD) . = ALIGN(4); ___initramfs_start = .;
arch/ia64/kernel/vmlinux.lds.S +4 -4
@@ -27,8 +27,8 @@ SECTIONS { /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) *(.IA_64.unwind.exit.text) *(.IA_64.unwind_info.exit.text)
@@ -119,12 +119,12 @@ SECTIONS .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) - { *(.init.data) } + { INIT_DATA } #ifdef CONFIG_BLK_DEV_INITRD .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET)
arch/m32r/kernel/vmlinux.lds.S +6 -6
@@ -76,10 +76,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) }
@@ -100,8 +100,8 @@ SECTIONS .altinstr_replacement : { *(.altinstr_replacement) } /* .exit.text is discard at runtime, not link time, to deal with references from .altinstructions and .eh_frame */ - .exit.text : { *(.exit.text) } - .exit.data : { *(.exit.data) } + .exit.text : { EXIT_TEXT } + .exit.data : { EXIT_DATA } #ifdef CONFIG_BLK_DEV_INITRD . = ALIGN(4096);
@@ -124,8 +124,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/m68k/kernel/vmlinux-std.lds +4 -4
@@ -45,10 +45,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) }
@@ -82,8 +82,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/m68k/kernel/vmlinux-sun3.lds +4 -4
@@ -38,10 +38,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) }
@@ -77,8 +77,8 @@ __init_begin = .; /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/m68knommu/kernel/vmlinux.lds.S +4 -4
@@ -143,9 +143,9 @@ SECTIONS { . = ALIGN(4096); __init_begin = .; _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; - *(.init.data) + INIT_DATA . = ALIGN(16); __setup_start = .; *(.init.setup)
@@ -170,8 +170,8 @@ SECTIONS { } > INIT /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/mips/kernel/vmlinux.lds.S +4 -4
@@ -114,11 +114,11 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); .init.setup : {
@@ -144,10 +144,10 @@ SECTIONS * references from .rodata */ .exit.text : { - *(.exit.text) + EXIT_TEXT } .exit.data : { - *(.exit.data) + EXIT_DATA } #if defined(CONFIG_BLK_DEV_INITRD) . = ALIGN(_PAGE_SIZE);
arch/parisc/kernel/vmlinux.lds.S +4 -4
@@ -172,11 +172,11 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); .init.setup : {
@@ -215,10 +215,10 @@ SECTIONS * from .altinstructions and .eh_frame */ .exit.text : { - *(.exit.text) + EXIT_TEXT } .exit.data : { - *(.exit.data) + EXIT_DATA } #ifdef CONFIG_BLK_DEV_INITRD . = ALIGN(PAGE_SIZE);
arch/powerpc/kernel/vmlinux.lds.S +6 -4
@@ -23,7 +23,7 @@ SECTIONS /* Sections to be discarded. */ /DISCARD/ : { *(.exitcall.exit) - *(.exit.data) + EXIT_DATA } . = KERNELBASE;
@@ -76,17 +76,19 @@ SECTIONS .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } /* .exit.text is discarded at runtime, not link time, * to deal with references from __bug_table */ - .exit.text : { *(.exit.text) } + .exit.text : { + EXIT_TEXT + } .init.data : { - *(.init.data); + INIT_DATA __vtop_table_begin = .; *(.vtop_fixup); __vtop_table_end = .;
arch/ppc/kernel/vmlinux.lds.S +4 -4
@@ -97,14 +97,14 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } /* .exit.text is discarded at runtime, not link time, to deal with references from __bug_table */ - .exit.text : { *(.exit.text) } + .exit.text : { EXIT_TEXT } .init.data : { - *(.init.data); + INIT_DATA __vtop_table_begin = .; *(.vtop_fixup); __vtop_table_end = .;
@@ -164,6 +164,6 @@ SECTIONS /* Sections to be discarded. */ /DISCARD/ : { *(.exitcall.exit) - *(.exit.data) + EXIT_DATA } }
arch/s390/kernel/vmlinux.lds.S +4 -4
@@ -91,7 +91,7 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } /*
@@ -99,11 +99,11 @@ SECTIONS * to deal with references from __bug_table */ .exit.text : { - *(.exit.text) + EXIT_TEXT } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(0x100); .init.setup : {
@@ -150,7 +150,7 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.data) + EXIT_DATA *(.exitcall.exit) }
arch/sh/kernel/vmlinux.lds.S +4 -4
@@ -70,9 +70,9 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; _sinittext = .; - .init.text : { *(.init.text) } + .init.text : { INIT_TEXT } _einittext = .; - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .;
@@ -108,8 +108,8 @@ SECTIONS * .exit.text is discarded at runtime, not link time, to deal with * references from __bug_table */ - .exit.text : { *(.exit.text) } - .exit.data : { *(.exit.data) } + .exit.text : { EXIT_TEXT } + .exit.data : { EXIT_DATA } . = ALIGN(PAGE_SIZE); .bss : {
arch/sh64/kernel/vmlinux.lds.S +4 -4
@@ -93,9 +93,9 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; _sinittext = .; - .init.text : C_PHYS(.init.text) { *(.init.text) } + .init.text : C_PHYS(.init.text) { INIT_TEXT } _einittext = .; - .init.data : C_PHYS(.init.data) { *(.init.data) } + .init.data : C_PHYS(.init.data) { INIT_DATA } . = ALIGN(L1_CACHE_BYTES); /* Better if Cache Line aligned */ __setup_start = .; .init.setup : C_PHYS(.init.setup) { *(.init.setup) }
@@ -130,8 +130,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/sparc/kernel/vmlinux.lds.S +4 -4
@@ -48,12 +48,12 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } __init_text_end = .; .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); .init.setup : {
@@ -102,8 +102,8 @@ SECTIONS _end = . ; PROVIDE (end = .); /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/sparc64/kernel/vmlinux.lds.S +4 -4
@@ -56,11 +56,11 @@ SECTIONS .init.text : { __init_begin = .; _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); .init.setup : {
@@ -137,8 +137,8 @@ SECTIONS PROVIDE (end = .); /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
arch/um/kernel/dyn.lds.S +2 -2
@@ -17,7 +17,7 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; }
@@ -84,7 +84,7 @@ SECTIONS #include "asm/common.lds.S" - init.data : { *(.init.data) } + init.data : { INIT_DATA } /* Ensure the __preinit_array_start label is properly aligned. We could instead move the label definition inside the section, but
arch/um/kernel/uml.lds.S +2 -2
@@ -23,7 +23,7 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } . = ALIGN(4096);
@@ -48,7 +48,7 @@ SECTIONS #include "asm/common.lds.S" - init.data : { *(init.data) } + init.data : { INIT_DATA } .data : { . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
arch/v850/kernel/vmlinux.lds.S +5 -5
@@ -114,7 +114,7 @@ #define DATA_CONTENTS \ __sdata = . ; \ DATA_DATA \ - *(.exit.data) /* 2.5 convention */ \ + EXIT_DATA /* 2.5 convention */ \ *(.data.exit) /* 2.4 convention */ \ . = ALIGN (16) ; \ *(.data.cacheline_aligned) \
@@ -157,9 +157,9 @@ . = ALIGN (4096) ; \ __init_start = . ; \ __sinittext = .; \ - *(.init.text) /* 2.5 convention */ \ + INIT_TEXT /* 2.5 convention */ \ __einittext = .; \ - *(.init.data) \ + INIT_DATA \ *(.text.init) /* 2.4 convention */ \ *(.data.init) \ INITCALL_CONTENTS \
@@ -170,7 +170,7 @@ #define ROMK_INIT_RAM_CONTENTS \ . = ALIGN (4096) ; \ __init_start = . ; \ - *(.init.data) /* 2.5 convention */ \ + INIT_DATA /* 2.5 convention */ \ *(.data.init) /* 2.4 convention */ \ __init_end = . ; \ . = ALIGN (4096) ;
@@ -179,7 +179,7 @@ should go into ROM. */ #define ROMK_INIT_ROM_CONTENTS \ _sinittext = .; \ - *(.init.text) /* 2.5 convention */ \ + INIT_TEXT /* 2.5 convention */ \ _einittext = .; \ *(.text.init) /* 2.4 convention */ \ INITCALL_CONTENTS \
arch/x86/kernel/vmlinux_32.lds.S +10 -4
@@ -131,10 +131,12 @@ SECTIONS .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { __init_begin = .; _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) } + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { + INIT_DATA + } . = ALIGN(16); .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { __setup_start = .;
@@ -169,8 +171,12 @@ SECTIONS } /* .exit.text is discard at runtime, not link time, to deal with references from .altinstructions and .eh_frame */ - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) } - .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) } + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { + EXIT_TEXT + } + .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { + EXIT_DATA + } #if defined(CONFIG_BLK_DEV_INITRD) . = ALIGN(4096); .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
arch/x86/kernel/vmlinux_64.lds.S +13 -6
@@ -155,12 +155,15 @@ SECTIONS __init_begin = .; .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - __initdata_begin = .; - .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) } - __initdata_end = .; + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { + __initdata_begin = .; + INIT_DATA + __initdata_end = .; + } + . = ALIGN(16); __setup_start = .; .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
@@ -187,8 +190,12 @@ SECTIONS } /* .exit.text is discard at runtime, not link time, to deal with references from .altinstructions and .eh_frame */ - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) } - .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) } + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { + EXIT_TEXT + } + .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { + EXIT_DATA + } /* vdso blob that is mapped into user space */ vdso_start = . ;
arch/xtensa/kernel/vmlinux.lds.S +5 -4
@@ -136,13 +136,13 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.literal) *(.init.text) + *(.init.literal) INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA . = ALIGN(0x4); __tagtable_begin = .; *(.taglist)
@@ -278,8 +278,9 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.literal .exit.text) - *(.exit.data) + *(.exit.literal) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) }
include/asm-generic/vmlinux.lds.h +7 -0
@@ -183,6 +183,13 @@ *(.kprobes.text) \ VMLINUX_SYMBOL(__kprobes_text_end) = .; +/* init and exit section handling */ +#define INIT_TEXT *(init.text) +#define INIT_DATA *(init.data) +#define EXIT_TEXT *(exit.text) +#define EXIT_DATA *(exit.data) + +/* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 compiler.h: introduce __section()
Add a new helper: __section() that makes a section definition much shorter and more readable.
--- include/linux/compiler.h | 5 +++++ include/linux/init.h | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-)
include/linux/compiler.h +5 -0
@@ -175,4 +175,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);#define __cold#endif +/* Simple shorthand for a section definition */ +#ifndef __section +# define __section (S ) __attribute__ ((__section__(#S))) +#endif +#endif /* __LINUX_COMPILER_H */
include/linux/init.h +13 -13
@@ -40,10 +40,10 @@/* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __attribute__ ((__section__ (".init.text"))) __cold -#define __initdata __attribute__ ((__section__ (".init.data"))) -#define __exitdata __attribute__ ((__section__(".exit.data"))) -#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) +#define __init __section(.init.text) __cold +#define __initdata __section(.init.data) +#define __exitdata __section(.exit.data) +#define __exit_call __attribute_used__ __section(.exitcall.exit)/* modpost check for section mismatches during the kernel build. * A section mismatch happens when there are references from a
@@ -55,14 +55,14 @@* the init/exit section (code or data) is valid and will teach modpost * not to issue a warning. * The markers follow same syntax rules as __init / __initdata. */ -#define __init_refok noinline __attribute__ ((__section__ (".text.init.refok"))) -#define __initdata_refok __attribute__ ((__section__ (".data.init.refok"))) -#define __exit_refok noinline __attribute__ ((__section__ (".exit.text.refok"))) +#define __init_refok noinline __section(.text.init.refok) +#define __initdata_refok __section(.data.init.refok) +#define __exit_refok noinline __section(.exit.text.refok)#ifdef MODULE -#define __exit __attribute__ ((__section__(".exit.text"))) __cold +#define __exit __section(.exit.text) __cold#else -#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) __cold +#define __exit __attribute_used__ __section(.exit.text) __cold#endif /* For assembly routines */
@@ -142,11 +142,11 @@ void prepare_namespace(void);#define console_initcall (fn) \ static initcall_t __initcall_##fn \ - __attribute_used__ __attribute__((__section__(".con_initcall.init")))=fn + __attribute_used__ __section(.con_initcall.init)=fn#define security_initcall (fn) \ static initcall_t __initcall_##fn \ - __attribute_used__ __attribute__((__section__(".security_initcall.init"))) = fn + __attribute_used__ __section(.security_initcall.init) = fnstruct obs_kernel_param {const char *str;
@@ -164,7 +164,7 @@ struct obs_kernel_param { static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \ static struct obs_kernel_param __setup_##unique_id \ __attribute_used__ \ - __attribute__((__section__(".init.setup"))) \ + __section(.init.setup) \ __attribute__((aligned((sizeof(long))))) \ = { __setup_str_##unique_id, fn, early }
@@ -242,7 +242,7 @@ void __init parse_early_param(void);#endif /* Data marked not to be saved by software suspend */ -#define __nosavedata __attribute__ ((__section__ (".data.nosave"))) +#define __nosavedata __section(.data.nosave)/* This means "can be init if no module support, otherwise module load may call it." */
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 Use separate sections for __dev/__cpu/__mem code/data
Introducing separate sections for __dev* (HOTPLUG), __cpu* (HOTPLUG_CPU) and __mem* (MEMORY_HOTPLUG) allows us to do a much more reliable Section mismatch check in modpost. We are no longer dependent on the actual configuration of for example HOTPLUG.
This has the effect that all users see much more Section mismatch warnings than before because they were almost all hidden when HOTPLUG was enabled. The advantage of this is that when building a piece of code then it is much more likely that the Section mismatch errors are spotted and the warnings will be felt less random of nature.
--- include/asm-generic/vmlinux.lds.h | 88 ++++++++++++++++++++++++++++++++++--- include/linux/init.h | 77 ++++++++++++++++---------------- scripts/mod/modpost.c | 54 ++++++++++++++++------ 3 files changed, 159 insertions(+), 60 deletions(-)
include/asm-generic/vmlinux.lds.h +82 -6
@@ -9,10 +9,46 @@/* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8) +/* The actual configuration determine if the init/exit sections +* are handled as text/data or they can be discarded (which +* often happens at runtime) +*/ +#ifdef CONFIG_HOTPLUG +#define DEV_KEEP (sec) *(.dev##sec) +#define DEV_DISCARD (sec) +#else +#define DEV_KEEP (sec) +#define DEV_DISCARD (sec) *(.dev##sec) +#endif + +#ifdef CONFIG_HOTPLUG_CPU +#define CPU_KEEP (sec) *(.cpu##sec) +#define CPU_DISCARD (sec) +#else +#define CPU_KEEP (sec) +#define CPU_DISCARD (sec) *(.cpu##sec) +#endif + +#if defined(CONFIG_MEMORY_HOTPLUG ) || defined(CONFIG_ACPI_HOTPLUG_MEMORY ) \ + || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE ) +#define MEM_KEEP (sec) *(.mem##sec) +#define MEM_DISCARD (sec) +#else +#define MEM_KEEP (sec) +#define MEM_DISCARD (sec) *(.mem##sec) +#endif + +/* .data section */ #define DATA_DATA \ *(.data) \ *(.data.init.refok) \ + DEV_KEEP(init.data) \ + DEV_KEEP(exit.data) \ + CPU_KEEP(init.data) \ + CPU_KEEP(exit.data) \ + MEM_KEEP(init.data) \ + MEM_KEEP(exit.data) \ . = ALIGN(8); \ VMLINUX_SYMBOL(__start___markers) = .; \ *(__markers) \
@@ -132,6 +168,16 @@ *(__ksymtab_strings) \ } \ \ +/* __*init sections */ \ + __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \ + DEV_KEEP(init.rodata) \ + DEV_KEEP(exit.rodata) \ + CPU_KEEP(init.rodata) \ + CPU_KEEP(exit.rodata) \ + MEM_KEEP(init.rodata) \ + MEM_KEEP(exit.rodata) \ + } \ + \/* Built-in module parameters. */ \ __param : AT(ADDR(__param) - LOAD_OFFSET) { \ VMLINUX_SYMBOL(__start___param) = .; \
@@ -139,7 +185,6 @@ VMLINUX_SYMBOL(__stop___param) = .; \ VMLINUX_SYMBOL(__end_rodata) = .; \ } \ - \ . = ALIGN((align));/* RODATA provided for backward compatibility.
@@ -159,7 +204,14 @@ALIGN_FUNCTION (); \ *(.text) \ *(.text.init.refok) \ - *(.exit.text.refok) + *(.exit.text.refok) \ + DEV_KEEP(init.text) \ + DEV_KEEP(exit.text) \ + CPU_KEEP(init.text) \ + CPU_KEEP(exit.text) \ + MEM_KEEP(init.text) \ +MEM_KEEP (exit.text) +/* sched.text is aling to function alignment to secure we have same * address even at second ld pass when generating System.map */
@@ -184,11 +236,35 @@ VMLINUX_SYMBOL(__kprobes_text_end) = .;/* init and exit section handling */ -#define INIT_TEXT *(init.text) -#define INIT_DATA *(init.data) -#define EXIT_TEXT *(exit.text) -#define EXIT_DATA *(exit.data) +#define INIT_DATA \ + *(.init.data) \ + DEV_DISCARD(init.data) \ + DEV_DISCARD(init.rodata) \ + CPU_DISCARD(init.data) \ + CPU_DISCARD(init.rodata) \ + MEM_DISCARD(init.data) \ + MEM_DISCARD(init.rodata) + +#define INIT_TEXT \ + *(.init.text) \ + DEV_DISCARD(init.text) \ + CPU_DISCARD(init.text) \ + MEM_DISCARD(init.text) + +#define EXIT_DATA \ + *(.exit.data) \ + DEV_DISCARD(exit.data) \ + DEV_DISCARD(exit.rodata) \ + CPU_DISCARD(exit.data) \ + CPU_DISCARD(exit.rodata) \ + MEM_DISCARD(exit.data) \ + MEM_DISCARD(exit.rodata) +#define EXIT_TEXT \ + *(.exit.text) \ + DEV_DISCARD(exit.text) \ + CPU_DISCARD(exit.text) \ + MEM_DISCARD(exit.text)/* DWARF debug sections. Symbols in the DWARF debugging sections are relative to
include/linux/init.h +38 -39
99 lines not on this page · raw message
scripts/mod/modpost.c +39 -15
88 lines not on this page · raw message
Signature · 1 line
1.5.4.rc3.14.g44397
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 10 lines · Sam Ravnborg
include/asm-generic/vmlinux.lds.h +2
-0@@ -9,10 +9,46 @@/* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8) +/* The actual configuration determine if the init/exit sections +* are handled as text/data or they can be discarded (which
include/asm-generic/vmlinux.lds.h line 23
Quoted 10 lines
include/asm-generic/vmlinux.lds.h +10
-0+* often happens at runtime) +*/ +#ifdef CONFIG_HOTPLUG +#define DEV_KEEP (sec) *(.dev##sec) +#define DEV_DISCARD (sec) +#else +#define DEV_KEEP (sec) +#define DEV_DISCARD (sec) *(.dev##sec) +#endif +
Using your kbuild.git, these blow up for me:
LD .tmp_vmlinux1
sh4-linux-ld:arch/sh/kernel/vmlinux.lds:364: ignoring invalid character #' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:364: ignoring invalid character #' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:364: ignoring invalid character #' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:364: ignoring invalid character #' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:381: ignoring invalid character #' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:381: ignoring invalid character #' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:381: ignoring invalid character `#' in script
...
This comes out as:
.text : {
*(.text.head)
. = ALIGN(8); *(.text) *(.text.init.refok) *(.exit.text.refok) *(.dev##init.text)
*(.dev##exit.text)
. = ALIGN(8); __sched_text_start = .; *(.sched.text)
__sched_text_end = .;
. = ALIGN(8); __lock_text_start = .; *(.spinlock.text)
__lock_text_end = .;
. = ALIGN(8); __kprobes_text_start = .; *(.kprobes.text)
__kprobes_text_end = .;
*(.fixup)
*(.gnu.warning)...
so the ## is being taken directly rather than acting as a concatenation.
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 48 lines · Paul Mundt
Quoted 10 lines · Sam Ravnborg
include/asm-generic/vmlinux.lds.h +2
-0@@ -9,10 +9,46 @@/* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8) +/* The actual configuration determine if the init/exit sections +* are handled as text/data or they can be discarded (which include/asm-generic/vmlinux.lds.h line 23
Quoted 10 lines
include/asm-generic/vmlinux.lds.h +10
-0+* often happens at runtime) +*/ +#ifdef CONFIG_HOTPLUG +#define DEV_KEEP (sec) *(.dev##sec) +#define DEV_DISCARD (sec) +#else +#define DEV_KEEP (sec) +#define DEV_DISCARD (sec) *(.dev##sec) +#endif +Using your kbuild.git, these blow up for me:
LD .tmp_vmlinux1
sh4-linux-ld:arch/sh/kernel/vmlinux.lds:364: ignoring invalid character#' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:364: ignoring invalid character#' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:364: ignoring invalid character#' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:364: ignoring invalid character#' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:381: ignoring invalid character#' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:381: ignoring invalid character#' in script sh4-linux-ld:arch/sh/kernel/vmlinux.lds:381: ignoring invalid character `#' in script
...This comes out as:
.text : { *(.text.head) . = ALIGN(8); *(.text) *(.text.init.refok) *(.exit.text.refok) *(.dev##init.text) *(.dev##exit.text) . = ALIGN(8); __sched_text_start = .; *(.sched.text) __sched_text_end = .; . = ALIGN(8); __lock_text_start = .; *(.spinlock.text) __lock_text_end = .; . = ALIGN(8); __kprobes_text_start = .; *(.kprobes.text) __kprobes_text_end = .; *(.fixup) *(.gnu.warning)
Quoted 3 lines
...
so the ## is being taken directly rather than acting as a concatenation.
Strange...
I can reproduce with gcc 3.4.5 here - will fix.
Setting CONFIG_HOTPLUG=n for sparc64 also cause troubles. Something with local symbols discarded. So more work is needed.
Sam
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 5 lines · Sam Ravnborg
Quoted 1 line · Paul Mundt
so the ## is being taken directly rather than acting as a concatenation.
Strange...
I can reproduce with gcc 3.4.5 here - will fix.
The ## operator does not work with -traditional.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 9 lines · Andreas Schwab
Quoted 5 lines · Sam Ravnborg
Quoted 1 line · Paul Mundt
so the ## is being taken directly rather than acting as a concatenation.
Strange...
I can reproduce with gcc 3.4.5 here - will fix.The ## operator does not work with -traditional.
Crap - then it breaks at the following architectures:
sh64, s390, m68k, m32r
Thanks Andreas.
Sam
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 9 lines · Sam Ravnborg
Quoted 8 lines · Andreas Schwab
Quoted 5 lines · Sam Ravnborg
Quoted 1 line · Paul Mundt
so the ## is being taken directly rather than acting as a concatenation.
Strange...
I can reproduce with gcc 3.4.5 here - will fix.
Quoted 6 lines
Quoted 1 line
The ## operator does not work with -traditional.
Crap - then it breaks at the following architectures:
sh64, s390, m68k, m32rThanks Andreas.
OK - I was too quick it seem.
sh has:
arch/sh/Makefile:CPPFLAGS_vmlinux.lds := -traditional
So this needs to be ripped out as it is not needed.
Sam
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 15 lines · Sam Ravnborg
Quoted 14 lines · Sam Ravnborg
Quoted 9 lines · Andreas Schwab
Quoted 5 lines · Sam Ravnborg
Quoted 1 line · Paul Mundt
so the ## is being taken directly rather than acting as a concatenation.
Strange...
I can reproduce with gcc 3.4.5 here - will fix.The ## operator does not work with -traditional.
Crap - then it breaks at the following architectures:
sh64, s390, m68k, m32r
Quoted 8 lines
Quoted 1 line
Thanks Andreas.
OK - I was too quick it seem.
sh has:
arch/sh/Makefile:CPPFLAGS_vmlinux.lds := -traditionalSo this needs to be ripped out as it is not needed.
Yes, that can be killed. If this is aimed at 2.6.25, I'll just kill it off in my tree. Otherwise, feel free to roll this in to your patch set.
Your kbuild.git works fine with this applied.
---
arch/sh/Makefile +0 -2
@@ -151,8 +151,6 @@ drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/ boot := arch/sh/boot -CPPFLAGS_vmlinux.lds := -traditional - incdir-prefix := $(srctree)/include/asm-sh/ # Update machine arch and proc symlinks if something which affects
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 18 lines · Paul Mundt
Quoted 17 lines · Sam Ravnborg
Quoted 15 lines · Sam Ravnborg
Quoted 9 lines · Andreas Schwab
Quoted 5 lines · Sam Ravnborg
Quoted 1 line · Paul Mundt
so the ## is being taken directly rather than acting as a concatenation.
Strange...
I can reproduce with gcc 3.4.5 here - will fix.The ## operator does not work with -traditional.
Crap - then it breaks at the following architectures:
sh64, s390, m68k, m32rThanks Andreas.
Quoted 8 lines
Quoted 6 lines
OK - I was too quick it seem.
sh has:
arch/sh/Makefile:CPPFLAGS_vmlinux.lds := -traditionalSo this needs to be ripped out as it is not needed.
Yes, that can be killed. If this is aimed at 2.6.25, I'll just kill it off in my tree. Otherwise, feel free to roll this in to your patch set.
It is aimed for 2.6.25 and it looks reasonable to reach that goal. So please take this patch in your tree.
Thanks,
Sam
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 23 lines · Sam Ravnborg
Quoted 22 lines · Paul Mundt
Quoted 21 lines · Sam Ravnborg
Quoted 9 lines · Sam Ravnborg
Quoted 8 lines · Andreas Schwab
Quoted 5 lines · Sam Ravnborg
Quoted 1 line · Paul Mundt
so the ## is being taken directly rather than acting as a concatenation.
Strange...
I can reproduce with gcc 3.4.5 here - will fix.Quoted 6 lines
Quoted 1 line
The ## operator does not work with -traditional.
Crap - then it breaks at the following architectures:
sh64, s390, m68k, m32rThanks Andreas.
OK - I was too quick it seem.
sh has:
arch/sh/Makefile:CPPFLAGS_vmlinux.lds := -traditional
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
So this needs to be ripped out as it is not needed.
Yes, that can be killed. If this is aimed at 2.6.25, I'll just kill it off in my tree. Otherwise, feel free to roll this in to your patch set.
It is aimed for 2.6.25 and it looks reasonable to reach that goal. So please take this patch in your tree.
Done.
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 26 lines · Paul Mundt
Quoted 25 lines · Sam Ravnborg
Quoted 24 lines · Paul Mundt
Quoted 23 lines · Sam Ravnborg
Quoted 9 lines · Sam Ravnborg
Quoted 8 lines · Andreas Schwab
Quoted 5 lines · Sam Ravnborg
Quoted 1 line · Paul Mundt
so the ## is being taken directly rather than acting as a concatenation.
Strange...
I can reproduce with gcc 3.4.5 here - will fix.Quoted 6 lines
Quoted 1 line
The ## operator does not work with -traditional.
Crap - then it breaks at the following architectures:
sh64, s390, m68k, m32rThanks Andreas.
OK - I was too quick it seem.
sh has:
arch/sh/Makefile:CPPFLAGS_vmlinux.lds := -traditionalSo this needs to be ripped out as it is not needed.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Yes, that can be killed. If this is aimed at 2.6.25, I'll just kill it off in my tree. Otherwise, feel free to roll this in to your patch set.
It is aimed for 2.6.25 and it looks reasonable to reach that goal. So please take this patch in your tree.
Done.
Thanks Paul,
and thanks for the prompt testing!
Sam
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
In reply to Sam RavnborgQuoted 14 lines · Sam Ravnborg
Introducing separate sections for __dev* (HOTPLUG), __cpu* (
HOTPLUG_CPU) and __mem* (MEMORY_HOTPLUG) allows us to do a much more reliable Section mismatch check in modpost. We are no longer dependent on the actual configuration of for example HOTPLUG.This has the effect that all users see much more Section mismatch warnings than before because they were almost all hidden when HOTPLUG was enabled. The advantage of this is that when building a piece of code then it is much more likely that the Section mismatch errors are spotted and the warnings will be felt less random of nature.
Quoted 4 lines
Signed-off-by Sam Ravnborg <[email protected]>Cc Greg KH <[email protected]>Cc Randy Dunlap <[email protected]>Cc Adrian Bunk <[email protected]>
I like this a lot. It makes things much more understandable from a driver developer's point of view, and would allow us to mark some things as freeable when we do not run with a CPU hotplug system :)
Feel free to add a:
to the patch, if you want to take it in your tree.
thanks,
greg k-h
Re: [PATCH] Use separate sections for __dev/__cpu/__mem code/data
Quoted 3 lines · Greg KH
I like this a lot. It makes things much more understandable from a driver developer's point of view, and would allow us to mark some things as freeable when we do not run with a CPU hotplug system :)
You mean at run time - I'm not sure if there's any advantage to that.
In order to free the hotplug cpu data and text, you'd have to make those sections page aligned - and then you have the question of how much space you are wasting in doing so. That will be variable over time as the code changes.
Also, if you were to merge the hotplug cpu text and data to reduce the wastage, would that cause any architectures any issues? (Thinking about execute-only being set on the kernel's text section only, etc.)
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Re: [PATCH] kbuild: introduce blacklisting in modpost
In reply to Sam RavnborgQuoted 3 lines · On Monday 21 January 2008 07:08:59 Sam Ravnborg wrote:
Change the logic in modpost so we identify all the bad combinations of sections that refer to other sections.
...
Quoted 7 lines
+/* The pattern is an array of simple patterns.
+ * "foo" will match an exact string equal to "foo"
+ * "foo*" will match a string that begins with "foo"
+ * "foo$" will match a string equal to "foo" or "foo.1"+ * where the '1' can be any number including several digits. + * The $ syntax is for sections where ld append a dot number + * to make section name unique.
Dumb question: would it be easier to canonicalize all the section names by removing trailing .[num]*, then using fnmatch() and standard wildcards?
The rest of the patches look really nice: thanks for doing this cleanup!
Rusty.
Re: [PATCH] kbuild: fix so modpost can now check any .o file
In reply to Sam RavnborgQuoted 5 lines · On Monday 21 January 2008 07:08:56 Sam Ravnborg wrote:
It is very convinient to say:
scripts/mod/modpostmm/built-in.oto check if any section mismatch errors occured
inmm/(as an example).
Hi Sam,
In an ideal world, wouldn't it be better to split out section analysis into a different helper program?
Cheers,
Rusty.
Re: [PATCH] kbuild: fix so modpost can now check any .o file
Quoted 11 lines · Rusty Russell
Quoted 5 lines · On Monday 21 January 2008 07:08:56 Sam Ravnborg wrote:
It is very convinient to say:
scripts/mod/modpostmm/built-in.oto check if any section mismatch errors occured
inmm/(as an example).Hi Sam,
In an ideal world, wouldn't it be better to split out section analysis into a different helper program?
Now whats an ideal world ;-)
But otherwise yes - I have not just got around to it.
Sam
Quoted 3 lines · Sam Ravnborg
I have spent the last week (the time I can afford to Linux stuff anyway) to improve the Section mismatch warnings detected by modpost.
Forgot to mention that all patches are made on top of kbuild.git but I expect then to apply to mainline with minimal effort.
They are all pushed out to the kbuild.git tree
for easy git retrival.
Please note that I often rebase kbuild.git
without any notice.
Sam
Quoted 5 lines · Sam Ravnborg
...
Adrian reminded us that KCFLAGS=-fno-inline told another story with more than 100 Section mismatch warnings on 64 bit x86 with an allyesconfig build.
...
Not -fno-inline but -fno-inline-functions-called-once (completely different option).
Quoted 1 line
Sam
cu
Adrian
Signature · 4 lines
"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 SeedQuoted 9 lines · Adrian Bunk
Quoted 5 lines · Sam Ravnborg
...
Adrian reminded us that KCFLAGS=-fno-inline told another story with more than 100 Section mismatch warnings on 64 bit x86 with an allyesconfig build.
...Not -fno-inline but -fno-inline-functions-called-once (completely different option).
Yep - looked that up after sending the mail.
A quick test shows no diference in # of generated Section mismatch warnings for the two - which is good.
Sam
Quoted 9 lines · Adrian Bunk
Quoted 5 lines · Sam Ravnborg
...
Adrian reminded us that KCFLAGS=-fno-inline told another story with more than 100 Section mismatch warnings on 64 bit x86 with an allyesconfig build.
...Not -fno-inline but -fno-inline-functions-called-once (completely different option).
Do you know when gcc started to support
-fno-inline-functions-called-once?
I do not have anything older than 3.4.5 build here.
I should have a gcc 3.2 (Documentation/Changes)
but no at the moment.
Sam
Quoted 11 lines · Sam Ravnborg
Quoted 9 lines · Adrian Bunk
Quoted 5 lines · Sam Ravnborg
...
Adrian reminded us that KCFLAGS=-fno-inline told another story with more than 100 Section mismatch warnings on 64 bit x86 with an allyesconfig build.
...Not -fno-inline but -fno-inline-functions-called-once (completely different option).
Quoted 7 lines
Do you know when gcc started to support
-fno-inline-functions-called-once?I do not have anything older than 3.4.5 build here.
I should have a gcc 3.2 (
Documentation/Changes)
but no at the moment.
The inline-functions-called-once optimization is only available with unit-at-a-time, and the -fno-inline-functions-called-once option is therefore present since gcc 3.4.
Quoted 1 line
Sam
cu
Adrian
Signature · 4 lines
"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