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

Andrew Morton
2009-01-12T21:52:19Z

On Sun, 4 Jan 2009 14:20:35 -0500 (EST)
Tim Abbott <tabbott@MIT.EDU> wrote:

> On Thu, 1 Jan 2009, Andrew Morton wrote:
>
> > OK, it hits a lot of files in minor ways.
> >
> > You could ask Linus to merge it late in the -rc1 merge window (please
> > cc me on the email). Or you could just send it to me (with the usual
> > cc's) and I'll toss it into my 2.6.29-rc1 pile. I doubt if it'll cause
> > much trouble. But please do check its applicability to linux-next - people
> > have been moving arch files into different directories lately.
>
> Andrew,
>
> I've attached for you a version of the patch the applies to current
> linux-next (next-20090102).
>
> It does not apply to Linus' current master because d3794979a in linux-next
> adds use of the ".data.percpu.first" section name, which this patch
> updates to ".kernel.data.percpu.first". I think it'll be easiest to just
> merge this after d3794979a.
>
> If a version of d3794979a is not going to be merged first, there will be
> two merge conflicts that are easy to resolve as they are changes to code
> added by d3794979a, but we'll then need to fix d3794979a before merging
> d3794979a.
>

I don't think anyone will want to carry this in a non-mainline tree for
any amount of time. it'd be best to squeeze it into mainline pretty
much immediately. But...

> This patch was originally written by Denys Vlasenko, but it has been
> substantially modified by Anders Kaseorg and Tim Abbott to update it
> to apply to the current kernel and fix bugs. Any bugs were added by
> Anders Kaseorg and Tim Abbott.
>
> The purpose of this patch is to make it possible to build the kernel
> with "gcc -ffunction-sections -fdata-sections".
>
> The problem is that with -ffunction-sections -fdata-sections, gcc
> creates sections like .text.head and .data.nosave whenever someone has
> innocuous code like this:
>
> static void head(...) {...}
>
> or this:
>
> static int nosave = 1;
>
> somewhere in the kernel.
>
> The kernel linker scripts are confused by such names, and thus put
> these sections in the wrong places.
>
> This patch renames all "magic" section names used by the kernel to not
> have this format, eliminating the possibility of such collisions.
>
> Ksplice's 'run-pre matching' process is much simpler if the original
> kernel was compiled with -ffunction-sections and -fdata-sections.
>

The changelog gives us no reason to do that.

So we `make it possible to build the kernel > with "gcc
-ffunction-sections -fdata-sections"'. So what? Where is the value in
that?