Linker script cleanup / consolidation
Grumble.. why is this list not following usual naming scheme... Please include all recepients listed below in replies.
Sam
To: David Miller <[email protected]>, [email protected],
[email protected], LKML <[email protected]>
With basis in sparc64 I did a small cleanup / consolidation work. The sparc64 lds script is by no menas the worst to look at but a anyway a good place to start.
In the following patch serie I did:
-> Introduce a C-like indention style
-> Introduce use of PAGE_SIZE as replacement for hardcoded constant -> Consoildate initramfs definition
While browsing the other arch lds files I saw many other smaller items that could be consolidated but creating a define for something like 3-5 lines was to push it too much.
If there are a number of sections that could be defined together I would like to combine then in a common section but I do know too little about the linker scripts to determine this.
The other archs shall have a similar clean-up over time. sparc64 was just a good place to start because David had expressed that he liked the consolidation.
Sam
From: Sam Ravnborg <[email protected]>
Date: Thu, 24 May 2007 22:09:34 +0200
Quoted 3 lines
The other archs shall have a similar clean-up over time. sparc64 was just a good place to start because David had expressed that he liked the consolidation.
This looks great. In fact I'd be happy with you pushing this now for 2.6.22 in order to fix that RODATA() section alignment bug.
On a related topic, I've been wondering how to make instruction patching sections work with initdata without warning. I have a bunch of assembler patches in the main kernel image that go something like this:
661: ldx [%g7 + TRAP_PER_CPU_TSB_HUGE], %g5
nop .section .sun4v_2insn_patch, "ax" .word 661b mov SCRATCHPAD_UTSBREG2, %g5 ldxa [%g5] ASI_SCRATCHPAD, %g5 .previous
And then an __init function walks the tables in the ".sun4v_2insn_patch" instruction to patch things as needed.
I don't need to do this patching in modules or anything complicated like that, just in the static kernel image.
The problem is if I put one of these patches into __init assembler code, the modpost.c thing warns. As you can see, these patch sections in between __init_begin and __init_end.
I see that IA64 has something similar, and they prepend their patch section names with ".data." would that help me with the modpost.c warning issue?
The history behind this is that I want to make the assembler in arch/sparc64/kernel/trampoline.S __init to fix one modpost.c warning, but once I dod that I hit this patching section issue which makes more warnings that the original problem :-)
Quoted 10 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Thu, 24 May 2007 22:09:34 +0200Quoted 3 lines
The other archs shall have a similar clean-up over time. sparc64 was just a good place to start because David had expressed that he liked the consolidation.
This looks great. In fact I'd be happy with you pushing this now for 2.6.22 in order to fix that
RODATA()section alignment bug.
I did not write so I realize but since this targets sparc64 I expected you to apply this to your sparc-2.6.git tree. But I can push too - just confirm what you expect.
Quoted 1 line
On a related topic, I've been wondering how to make instruction
Need sleep before composing an answer - bed-time here.
Sam
From: Sam Ravnborg <[email protected]>
Date: Thu, 24 May 2007 23:15:11 +0200
Quoted 8 lines · David Miller
Quoted 7 lines
From: Sam Ravnborg <[email protected]>
Date: Thu, 24 May 2007 22:09:34 +0200Quoted 3 lines
The other archs shall have a similar clean-up over time. sparc64 was just a good place to start because David had expressed that he liked the consolidation.
Quoted 6 lines
Quoted 3 lines
This looks great. In fact I'd be happy with you pushing this now for 2.6.22 in order to fix that
RODATA()section alignment bug.I did not write so I realize but since this targets sparc64 I expected you to apply this to your sparc-2.6.git tree. But I can push too - just confirm what you expect.
Please merge this with my signoff added to each patch:
I have some bug fixes to move forward I appreciate your taking care of this.
Quoted 2 lines
Quoted 1 line
On a related topic, I've been wondering how to make instruction
Need sleep before composing an answer - bed-time here.
Good night, and thanks for all this work.
Quoted 25 lines
On a related topic, I've been wondering how to make instruction patching sections work with initdata without warning. I have a bunch of assembler patches in the main kernel image that go something like this:
661: ldx [%g7 +
TRAP_PER_CPU_TSB_HUGE], %g5nop .section .sun4v_2insn_patch, "ax" .word 661b mov SCRATCHPAD_UTSBREG2, %g5 ldxa [%g5] ASI_SCRATCHPAD, %g5 .previousAnd then an
__initfunction walks the tables in the ".sun4v_2insn_patch" instruction to patch things as needed.I don't need to do this patching in modules or anything complicated like that, just in the static kernel image.
The problem is if I put one of these patches into
__initassembler code, themodpost.cthing warns. As you can see, these patch sections in between__init_beginand__init_end.
Quoted 8 lines
I see that IA64 has something similar, and they prepend their patch section names with ".data." would that help me with the
modpost.cwarning issue?The history behind this is that I want to make the assembler in
arch/sparc64/kernel/trampoline.S__initto fix onemodpost.cwarning, but once I dod that I hit this patching section issue which makes more warnings that the original problem :-)
First off. I tried building a sparc64 kernel from -linus using defconfig and got no section mismatch warnings. Building a ia64 kernel now...
What we can do in modpost is to define that references from a certain section or sections that start with for example ".patch_insn." to .init.text / .init.data will be ignored.
Avoiding hardcoding ".sun4v_*" would be preferred and maybe we could move paravirt over to use a section with the same naming convention.
Trying to cheat modpost is only a source of confusion and thats not the way to do it.
Sam
From: Sam Ravnborg <[email protected]>
Date: Mon, 28 May 2007 20:53:36 +0200
Quoted 2 lines
First off. I tried building a sparc64 kernel from -linus using defconfig and got no section mismatch warnings.
Turn on SMP. :-)
Quoted 7 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Mon, 28 May 2007 20:53:36 +0200Quoted 2 lines
First off. I tried building a sparc64 kernel from -linus using defconfig and got no section mismatch warnings.
Turn on SMP. :-)
In trampoline.S moved all code to .init.text and got this:
WARNING: arch/sparc64/kernel/built-in.o(.sun4v_1insn_patch+0x8): Section mismatch: reference to .init.text:
WARNING: arch/sparc64/kernel/built-in.o(.sun4v_1insn_patch+0x10): Section mismatch: reference to .init.text:
WARNING: arch/sparc64/kernel/built-in.o(.sun4v_1insn_patch+0x18): Section mismatch: reference to .init.text:
WARNING: arch/sparc64/kernel/built-in.o(.cpuid_patch+0x0): Section mismatch: reference to .init.text:
It is trivial to ignore all references from a section named *_patch to .init.text But grepping linker script files for all other archs this does not look like a common namespace.
modpost has today following list of sections that may reference .init.text without causing a warning:
const char *namelist1[] = {
".init",
".opd", /* see comment [OPD] at exit_section_ref_ok() */
".toc1", /* used by ppc64 */
".stab",
".data.rel.ro", /* used by parisc64 */
".parainstructions",
".text.lock",
"__bug_table", /* used by powerpc for BUG() */
".pci_fixup_header",
".pci_fixup_final",
".pdr",
"__param",
"__ex_table",
".fixup",
".smp_locks",
".plt", /* seen on ARCH=um build on x86_64. Harmless */
"__ftr_fixup", /* powerpc cpu feature fixup */
"__fw_ftr_fixup", /* powerpc firmware feature fixup */
NULL
};
/* Start of section names */
const char *namelist2[] = {
".init.",
".altinstructions",
".eh_frame",
".debug",
".parainstructions",
".rodata",
NULLSo adding a third section that allow references from sections named *_patch is no big deal. Let me know if you stick to that namespace and I will add it to modpost.
Sam