All of lore.kernel.org
 help / color / mirror / Atom feed
* Linker script cleanup / consolidation
@ 2007-05-24 20:04 Sam Ravnborg
  0 siblings, 0 replies; 8+ messages in thread
From: Sam Ravnborg @ 2007-05-24 20:04 UTC (permalink / raw)
  To: David Miller, linux-arch, linux-sparc, LKML

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Linker script cleanup / consolidation
@ 2007-05-24 20:09 Sam Ravnborg
  2007-05-24 20:45 ` David Miller
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Sam Ravnborg @ 2007-05-24 20:09 UTC (permalink / raw)
  To: sparclinux

Grumble.. why is this list not following usual naming scheme...
Please include all recepients listed below in replies.

	Sam

To: David Miller <davem@davemloft.net>, linux-arch@vger.kernel.org,
	linux-sparc@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linker script cleanup / consolidation
  2007-05-24 20:09 Linker script cleanup / consolidation Sam Ravnborg
@ 2007-05-24 20:45 ` David Miller
  2007-05-24 21:15 ` Sam Ravnborg
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2007-05-24 20:45 UTC (permalink / raw)
  To: sparclinux

From: Sam Ravnborg <sam@ravnborg.org>
Date: Thu, 24 May 2007 22:09:34 +0200

> 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 :-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linker script cleanup / consolidation
  2007-05-24 20:09 Linker script cleanup / consolidation Sam Ravnborg
  2007-05-24 20:45 ` David Miller
@ 2007-05-24 21:15 ` Sam Ravnborg
  2007-05-24 21:16 ` David Miller
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Sam Ravnborg @ 2007-05-24 21:15 UTC (permalink / raw)
  To: sparclinux

On Thu, May 24, 2007 at 01:45:12PM -0700, David Miller wrote:
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Thu, 24 May 2007 22:09:34 +0200
> 
> > 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.

> On a related topic, I've been wondering how to make instruction
Need sleep before composing an answer - bed-time here.

	Sam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linker script cleanup / consolidation
  2007-05-24 20:09 Linker script cleanup / consolidation Sam Ravnborg
  2007-05-24 20:45 ` David Miller
  2007-05-24 21:15 ` Sam Ravnborg
@ 2007-05-24 21:16 ` David Miller
  2007-05-28 18:53 ` Sam Ravnborg
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2007-05-24 21:16 UTC (permalink / raw)
  To: sparclinux

From: Sam Ravnborg <sam@ravnborg.org>
Date: Thu, 24 May 2007 23:15:11 +0200

> On Thu, May 24, 2007 at 01:45:12PM -0700, David Miller wrote:
> > From: Sam Ravnborg <sam@ravnborg.org>
> > Date: Thu, 24 May 2007 22:09:34 +0200
> > 
> > > 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.

Please merge this with my signoff added to each patch:

Signed-off-by: David S. Miller <davem@davemloft.net>

I have some bug fixes to move forward I appreciate your taking care of
this.

> > 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linker script cleanup / consolidation
  2007-05-24 20:09 Linker script cleanup / consolidation Sam Ravnborg
                   ` (2 preceding siblings ...)
  2007-05-24 21:16 ` David Miller
@ 2007-05-28 18:53 ` Sam Ravnborg
  2007-05-29  6:00 ` David Miller
  2007-05-29 18:41 ` Sam Ravnborg
  5 siblings, 0 replies; 8+ messages in thread
From: Sam Ravnborg @ 2007-05-28 18:53 UTC (permalink / raw)
  To: sparclinux

> 
> 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 :-)

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linker script cleanup / consolidation
  2007-05-24 20:09 Linker script cleanup / consolidation Sam Ravnborg
                   ` (3 preceding siblings ...)
  2007-05-28 18:53 ` Sam Ravnborg
@ 2007-05-29  6:00 ` David Miller
  2007-05-29 18:41 ` Sam Ravnborg
  5 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2007-05-29  6:00 UTC (permalink / raw)
  To: sparclinux

From: Sam Ravnborg <sam@ravnborg.org>
Date: Mon, 28 May 2007 20:53:36 +0200

> First off. I tried building a sparc64 kernel from -linus using
> defconfig and got no section mismatch warnings.

Turn on SMP. :-)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Linker script cleanup / consolidation
  2007-05-24 20:09 Linker script cleanup / consolidation Sam Ravnborg
                   ` (4 preceding siblings ...)
  2007-05-29  6:00 ` David Miller
@ 2007-05-29 18:41 ` Sam Ravnborg
  5 siblings, 0 replies; 8+ messages in thread
From: Sam Ravnborg @ 2007-05-29 18:41 UTC (permalink / raw)
  To: sparclinux

On Mon, May 28, 2007 at 11:00:29PM -0700, David Miller wrote:
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Mon, 28 May 2007 20:53:36 +0200
> 
> > 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",
		NULL


So 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-05-29 18:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-24 20:09 Linker script cleanup / consolidation Sam Ravnborg
2007-05-24 20:45 ` David Miller
2007-05-24 21:15 ` Sam Ravnborg
2007-05-24 21:16 ` David Miller
2007-05-28 18:53 ` Sam Ravnborg
2007-05-29  6:00 ` David Miller
2007-05-29 18:41 ` Sam Ravnborg
  -- strict thread matches above, loose matches on Subject: below --
2007-05-24 20:04 Sam Ravnborg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.