[OpenWrt-Devel] [PATCH 1/6] buildsystem: Make PIE ASLR option tristate

Hauke Mehrtens hauke at hauke-m.de
Sun Oct 27 16:32:15 EDT 2019


On 10/27/19 8:05 PM, Rosen Penev wrote:
> On Sun, Oct 27, 2019 at 10:46 AM Hauke Mehrtens <hauke at hauke-m.de> wrote:
>>
>> This tristate choose allows to select to build only some applications
>> with PIE enabled. On MIPS binaries are getting about 30% bigger when PIE
>> is activated for the, which is a huge increase.
> Some of the size increase can be mitigated with extra compile-time options:
> 
> TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
> TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed
> 
> LTO sometimes causes problems but the others should be safe.
> 
> PKG_ASLR_PIE applies $(FPIC) to both C and LDFLAGS. I've noticed that
> applying it only to the former increases the size but not as much as
> with both. No idea why.

Hi Rosen,

Thank you for the hints.

I activated -flto for dnsmasq and the size was decreased by 8% which is
nice. I will test this a little bit and then send a patch to the mailing
list.

The GCC documentation says the following about -pie:
---------------------------------------------------------------------
-pie
    Produce a dynamically linked position independent executable on
targets that support it. For predictable results, you must also specify
the same set of options used for compilation (-fpie, -fPIE, or model
suboptions) when you specify this linker option.
---------------------------------------------------------------------
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options

So we should set it for compiling and linking.

GCC can activate -flto also when only some of the compile units used
LTO, but it should also be set for both steps.

Hauke

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20191027/43989e19/attachment.sig>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list