Re: [PATCH] fixes for kernel with no procfs.

From: Graham Stoney (greyham@research.canon.com.au)
Date: Wed Apr 05 2000 - 02:43:23 EST


On Wed, 5 Apr 2000, Graham Stoney wrote:
> What you've seen is the Makefiles and/or linker removing entire .o files which
> weren't referenced. The current compiler settings won't remove unused
> functions from .o's which contain other functions that are used. The /proc
> support functions scattered in objects that are needed for other reasons is
> one example: they are there even if CONFIG_PROC_FS is turned off.

What I should have pointed out here is that most of the /proc support functions
are already wrapped in #ifdef CONFIG_PROC_FS, and this does indeed cause them
to disappear when built without /proc. It relies on the authors to manually
insert the #ifdef's though, it's not automatic in this sense.

Arjan van de Ven writes:
> I hate to be a pain, but I am _very_ certain the current linking
> environment will remove individual functions from .a files.

That's OK, it's not particularly obvious what's going on under the hood.

...
> [begin quote from LD manual]

I'm afraid the quote is not very relevant, and the ld manual is rather terse
so I couldn't find a better one explaining that in the absence of the newish
--gc-sections flag, the linker only deals with whole object (i.e. .o) files,
not language level "objects" like functions.

The use of --start-group has no effect on this; it simply allows the linker to
resolve circularish references in one object file by using another object file
which was processed earlier on the command line but didn't appear to be needed
at the time.

...
> This implies that (and it actually happens)
> 1) Normal linking of .a files removes all not-yet-referenced functions, in
              This should read "objects" (i.e. object files) - ^^^^^^^^^

> a way that if a function is referenced in an .o/.a file later on the
                ^^^^^^^^^^ - should read "an object"

> commandline, it's too bad as it is already removed.

At present, the effect that you're seeing is a complex conspiracy between the
kernel Makefiles and a bunch of #ifdef's to remove unused code. It would be
nicer to have the compiler do this automatically, as you believed it had been
doing all along. Doing this requires the use of -ffunction-sections,
-fdata-sections and --gc-sections, and some non-trivial mods to the uaccess.h
and .lds files.

Regards,
Graham

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



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:14 EST