Gentoo Archives: gentoo-embedded

From: Kfir Lavi <lavi.kfir@×××××.com>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] Tool for eliminating non used code or symbols?
Date: Sun, 14 Apr 2013 13:07:54
Message-Id: CAHNvW1Kc8GNF=d1p+EAaFTH6s_oiZSHv4=O4YUZSMVDDqugaLw@mail.gmail.com
In Reply to: Re: [gentoo-embedded] Tool for eliminating non used code or symbols? by Markos Chandras
1 On Sat, Mar 30, 2013 at 4:09 AM, Markos Chandras <hwoarang@g.o>wrote:
2
3 > On 25 March 2013 07:01, Kfir Lavi <lavi.kfir@×××××.com> wrote:
4 > > Hi,
5 > > I'm looking for a way to reduce glibc code size.
6 > > It can be a way to make system smaller and minimize the impact
7 > > of attack vectors in glibc, as in return-to-libc attack.
8 > >
9 > > Lets say I'm deleting the program 'mkdir', and mkdir uses a function
10 > > in glibc that non of the other parts of the system uses.
11 > > Then I want to eliminate this function from glibc. This leads to smaller
12 > > code and if this function is used in some attack scenario, maybe prevent
13 > it.
14 > >
15 > > Is there a way to do it?
16 > > Can you help me think how to build a tool like this? or, integrate
17 > > with existing tools.
18 > >
19 > > Thanks,
20 > > Kfir
21 > >
22 >
23 > You can use -Os when you compile your packages to reduce the size of
24 > the resulting ELF file.
25 > As for the second part of your question, I am not sure if this is
26 > possible. I haven't thought this through, but
27 > assuming you know no other packages depend on the function you want to
28 > remove, you will have to mess
29 > with the ELF file and its plt and other section entries to remove all
30 > the references of that symbol. It's likely you
31 > will break the file in the end.
32 >
33 > --
34 > Regards,
35 > Markos Chandras - Gentoo Linux Developer
36 > http://dev.gentoo.org/~hwoarang
37 >
38 > Yes you right,
39 This is why I want to remove the function from the sources and compile it
40 again.
41
42 Kfir