Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] Tool for eliminating non used code or symbols? Kfir Lavi <lavi.kfir@×××××.com>