From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14559 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: size of executable Date: Mon, 12 Aug 2019 14:23:02 -0400 Message-ID: <20190812182302.GW9017@brightrain.aerifal.cx> References: <20190812171851.GS9017@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="251303"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14575-gllmg-musl=m.gmane.org@lists.openwall.com Mon Aug 12 20:23:18 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hxEyT-0013Hs-Dr for gllmg-musl@m.gmane.org; Mon, 12 Aug 2019 20:23:17 +0200 Original-Received: (qmail 14066 invoked by uid 550); 12 Aug 2019 18:23:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14048 invoked from network); 12 Aug 2019 18:23:14 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14559 Archived-At: On Mon, Aug 12, 2019 at 11:16:39AM -0700, Khem Raj wrote: > On Mon, Aug 12, 2019 at 10:19 AM Rich Felker wrote: > > > > On Mon, Aug 12, 2019 at 05:55:28PM +0100, Jorge Almeida wrote: > > > On Mon, Aug 12, 2019 at 5:48 PM Jorge Almeida wrote: > > > > > > > > > > > with gcc-8.3.0 on x86_64. Could someone check the following hello.c > > > > and see what size you get? > > > > I get 16768 bytes (not stripped) and 12324 (stripped). > > > > Note that I'm not even using printf. > > > > > > > > Thanks > > > > > > > > #include > > > > int main(int argc, char* argv[]){ > > > > write(1, "Hello, bloated world...\n", 24); > > > > } > > > > > > Sorry, I forgot to add the compile options. In attachement, due to > > > Gmail interface being what it is. > > > > > gcc -static -Os -march=native -fomit-frame-pointer -pipe -Wall -Werror=pedantic -Werror=implicit-function-declaration -pedantic -pedantic-errors -mpreferred-stack-boundary=4 -falign-functions=1 -falign-jumps=1 -falign-loops=1 -fno-unwind-tables -fdata-sections -ffunction-sections -Wl,--gc-sections -fno-asynchronous-unwind-tables -fstrict-aliasing -Wstrict-aliasing=2 -Wno-unused-function -std=c11 hello.c > > > > > > Stripping: > > > > > > strip -s a.out > > > strip -S --strip-unneeded --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag --remove-section=.eh_frame --remove-section=.eh_frame_ptr -R .note -R .comment -R .note.GNU-stack a.out > > > sstrip a.out > > > > This is a binutils regression from a dubious anti-ROP feature, -z > > separate-code. Add -Wl,-z,noseparate-code and it will go away. > > > > is this still so with latest release as well. The breakage that caused separate-code to crash at runtime was fixed between 2.31 and 2.32, but the size and performance regression remains. With separate-code, a couple extra pages of memory and disk are needed, with corresponding runtime cost to mmap them properly. All to avoid ROP gadgets, when every single dynamic-linked program has a nice ROP gadget named "system" (among many others) in it... Rich