Re: [PATCH v3 1/3] Make section names compatible with -ffunction-sections-fdata-sections

From: Tim Abbott
Date: Sat Apr 25 2009 - 22:18:25 EST


On Fri, 24 Apr 2009, Sam Ravnborg wrote:

> This patch touches far too many files.
> We should try to work out a method so we are in better control
> of the section names, so renaming in the end is a simple patch
> touching only a few files.

OK, I'm now planning to implement this approach.

> > -.section .text.head, "ax"
> > +.section .text..head, "ax"
>
> Use __HEAD (from include/linux/init.h)
> Same goes for all other uses of .text.head.

I notice that __HEAD uses .head.text, while some architectures use
.text.head. It looks like this is just an inconsistency across
architectures that will be removed as a consequence of this cleanup work
(no architecture uses both .head.text and .text.head).

One challenge with this approach is that many linker scripts use these
section names in more complex ways than just squashing HEAD_TEXT at the
start of the text section. For example, the the linker scripts for x86
and ia64 have code like:

.text.head : AT(ADDR(.text.head) - LOAD_OFFSET) {
_text = .; /* Text and read-only data */
*(.text.head)
} :text = 0x9090

which can't user either the __HEAD macro (which is the full .section line)
or the HEAD_TEXT macro (which is the *(.head.text)). I think the right
way to solve this is to create a HEAD_TEXT_SECTION macro in a new header
(include/linux/section-names.h) and define everything else in terms of
that; these linker script blocks would then use HEAD_TEXT_SECTION when
necessary. The new header would grow to contain several other section
names used in both code and linker scripts as this work proceeds.

I'm sending with this a prototype patch series that replaces all
".head.text" and ".text.head" usage with these macros. Please review the
design, as I intend to implement this design for many other section names
in the near future.

-Tim Abbott

Tim Abbott (15):
Add new HEAD_TEXT_SECTION macro.
xtensa: convert to use __HEAD and HEAD_TEXT macros.
alpha: convert to use __HEAD and HEAD_TEXT macros.
frv: convert frv to use __HEAD and HEAD_TEXT macros.
arm: convert to use __HEAD and HEAD_TEXT macros.
ia64: convert to use __HEAD and HEAD_TEXT macros.
m32r: convert to use __HEAD and HEAD_TEXT macros.
m68k: convert to use __HEAD and HEAD_TEXT macros.
mn10300: convert to use __HEAD and HEAD_TEXT macros.
powerpc: convert to use __HEAD and HEAD_TEXT macros.
s390: convert to use __HEAD and HEAD_TEXT macros.
sh: convert to use __HEAD and HEAD_TEXT macros.
sparc: convert to use __HEAD and HEAD_TEXT macros.
x86: convert to use __HEAD and HEAD_TEXT macros.
modpost: convert modpost to use HEAD_TEXT_SECTION macro.

arch/alpha/kernel/head.S | 3 ++-
arch/alpha/kernel/vmlinux.lds.S | 2 +-
arch/arm/kernel/head-nommu.S | 2 +-
arch/arm/kernel/head.S | 2 +-
arch/arm/kernel/vmlinux.lds.S | 4 ++--
arch/frv/kernel/head.S | 3 ++-
arch/frv/kernel/vmlinux.lds.S | 2 +-
arch/ia64/kernel/head.S | 2 +-
arch/ia64/kernel/vmlinux.lds.S | 4 ++--
arch/m32r/kernel/head.S | 2 +-
arch/m32r/kernel/vmlinux.lds.S | 2 +-
arch/m68k/kernel/head.S | 2 +-
arch/m68k/kernel/sun3-head.S | 2 +-
arch/m68k/kernel/vmlinux-std.lds | 2 +-
arch/m68k/kernel/vmlinux-sun3.lds | 2 +-
arch/mn10300/kernel/head.S | 3 ++-
arch/mn10300/kernel/vmlinux.lds.S | 5 +----
arch/powerpc/kernel/head_32.S | 3 ++-
arch/powerpc/kernel/head_40x.S | 3 ++-
arch/powerpc/kernel/head_44x.S | 3 ++-
arch/powerpc/kernel/head_8xx.S | 3 ++-
arch/powerpc/kernel/head_fsl_booke.S | 3 ++-
arch/powerpc/kernel/vmlinux.lds.S | 2 +-
arch/s390/kernel/head.S | 3 ++-
arch/s390/kernel/vmlinux.lds.S | 4 ++--
arch/sh/kernel/head_32.S | 3 ++-
arch/sh/kernel/head_64.S | 5 ++++-
arch/sh/kernel/vmlinux_32.lds.S | 2 +-
arch/sh/kernel/vmlinux_64.lds.S | 2 +-
arch/sparc/kernel/head_32.S | 2 +-
arch/sparc/kernel/vmlinux.lds.S | 2 +-
arch/x86/boot/compressed/Makefile | 2 ++
arch/x86/boot/compressed/head_32.S | 3 ++-
arch/x86/boot/compressed/head_64.S | 3 ++-
.../{vmlinux_32.lds => vmlinux_32.lds.S} | 6 ++++--
.../{vmlinux_64.lds => vmlinux_64.lds.S} | 6 ++++--
arch/x86/kernel/head_32.S | 2 +-
arch/x86/kernel/head_64.S | 2 +-
arch/x86/kernel/vmlinux_32.lds.S | 4 ++--
arch/x86/kernel/vmlinux_64.lds.S | 2 +-
arch/xtensa/kernel/head.S | 3 ++-
arch/xtensa/kernel/vmlinux.lds.S | 4 ++--
include/asm-generic/vmlinux.lds.h | 4 +++-
include/linux/init.h | 4 +++-
include/linux/section-names.h | 6 ++++++
scripts/mod/modpost.c | 8 +++++---
46 files changed, 87 insertions(+), 56 deletions(-)
rename arch/x86/boot/compressed/{vmlinux_32.lds => vmlinux_32.lds.S} (89%)
rename arch/x86/boot/compressed/{vmlinux_64.lds => vmlinux_64.lds.S} (90%)
create mode 100644 include/linux/section-names.h

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/