Re: [PATCH 0/3] build system: section garbage collection for vmlinux

Denys Vlasenko
2007-09-05T18:37:28Z

On Wednesday 05 September 2007 17:29, Daniel Walker wrote:
> On Wed, 2007-09-05 at 14:43 +0100, Denys Vlasenko wrote:
> > Build system: section garbage collection for vmlinux
> >
> >
> > Newer gcc and binutils can do dead code and data removal
> > at link time. It is achieved using combination of
> > -ffunction-sections -fdata-sections options for gcc and
> > --gc-sections for ld.
> >
> > Theory of operation:
> >
> > Option -ffunction-sections instructs gcc to place each function
> > (including static ones) in it's own section named .text.function_name
> > instead of placing all functions in one big .text section.
> >
> > At link time, ld normally coalesce all such sections into one
> > output section .text again. It is achieved by having *(.text.*) spec
> > along with *(.text) spec in built-in linker scripts.
>
> You version doesn't work with CONFIG_MODULES right?

It works with CONFIG_MODULES.

> Also, why do you need this patch,
>
> [PATCH 1/3] build system: section garbage collection for vmlinux

Because otherwise, for example, .data.percpu sections we already have
get picked up by *(.data.*), and then *(.data.percpu) end up empty:

__per_cpu_start = .;
*(.data.percpu)
*(.data.percpu.shared_aligned)
__per_cpu_end = .;

and all hell breaks loose.

We need to stop using sections named like

.text.xxxx
.data.xxxx
.rodata.xxxx
.bss.xxxx

--
vda