This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: unused functions


Hi,

The trick is to add the -ffunction-sections option to gcc (and
maybe -fdata-sections), and add the --gc-sections option to ld.

The -ffunction-sections option to gcc will tell it to put every function in
its own section, for example "void foo(void)" will end up in ".text.foo".
Likewise the -fdata-sections option will tell gcc to put every data/bss
variable in its own section by adding the dot-variable name as a suffix to
the default section.

The --gc-sections option to ld will tell it to remove all sections that are
not referenced.

The only other thing you may need to do it to check your linker script - you
will need to use a wildcard to handle the sufixes, for example:

.text {
    * (.text*)
}

or

.text {
    * (.text)
    * (.text.*)
}

Nick


----- Original Message -----
From: "Aleksandar Simeonov" <Aleksandar.Simeonov@micronasnit.com>
To: <binutils@sources.redhat.com>
Sent: Thursday, October 31, 2002 4:40 AM
Subject: unused functions


> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> Hi everybody,
> I'm looking the way to delete all unused functions from output elf file.
Is
> there any suggestions about that? I need that for mips-lexra.
>
> Thanks
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]