NetBSD Problem Report #52233
From www@NetBSD.org Sun May 14 15:00:26 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 696127A16D
for <gnats-bugs@gnats.NetBSD.org>; Sun, 14 May 2017 15:00:26 +0000 (UTC)
Message-Id: <20170514150024.E56147A2A5@mollari.NetBSD.org>
Date: Sun, 14 May 2017 15:00:24 +0000 (UTC)
From: coypu@sdf.org
Reply-To: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Subject: Static binaries are exceptionally massive
X-Send-Pr-Version: www-1.0
>Number: 52233
>Category: toolchain
>Synopsis: Static binaries are exceptionally massive
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun May 14 15:05:00 +0000 2017
>Closed-Date: Sat Dec 09 21:52:57 +0000 2017
>Last-Modified: Sat Dec 09 21:52:57 +0000 2017
>Originator: coypu
>Release: NetBSD 7.99.71
>Organization:
>Environment:
NetBSD loggy 7.99.71 NetBSD 7.99.71 (SAFE) #0: Sat May 13 15:28:53 IDT 2017 fly@loggy:/usr/src/sys/arch/amd64/compile/SAFE amd64
>Description:
% cat test.c
void main() {;}
% gcc -static -o static test.c
% ls -lh static
-rwxr-xr-x 1 fly users 228K May 14 17:35 static
>How-To-Repeat:
>Fix:
highlights from digging:
- nm says lots of citrus, string stuff, what's pulling it in?
- objdump says I have a huge function called _lwp_setprivate - but that's just a short syscall. gdb seems to find the correct definition.
- xxd finds a lot of dead space containing:
0002e550: 0800 0000 0800 0000 0800 0000 0800 0000 ................
0002e560: 1b00 0000 0100 0000 0000 0000 002a 2a2a .............***
0002e570: 204e 6f20 4c61 6265 6c20 5072 6f76 6964 No Label Provid
0002e580: 6564 202a 2a2a 0000 f1cf 0200 0000 0000 ed ***..........
0002e590: 0000 0000 0000 0000 0800 0000 0800 0000 ................
0002e5a0: 0c00 0000 0c00 0000 1b00 0000 0100 0000 ................
0002e5b0: 0000 0000 0000 0000 002a 2a2a 204e 6f20 .........*** No
0002e5c0: 4c61 6265 6c20 5072 6f76 6964 6564 202a Label Provided *
0002e5d0: 2a2a 0000 f1cf 0200 0000 0000 0000 0000 **..............
0002e5e0: 0000 0000 0800 0000 0e00 0000 1400 0000 ................
0002e5f0: 1400 0000 1b00 0000 0100 0000 0000 0000 ................
and so on...
this remains even after calling strip.
>Release-Note:
>Audit-Trail:
From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: toolchain/52233: Static binaries are exceptionally massive
Date: Sun, 14 May 2017 15:11:33 +0000
On Sun, May 14, 2017 at 03:05:00PM +0000, coypu@sdf.org wrote:
> - xxd finds a lot of dead space containing:
> 0002e550: 0800 0000 0800 0000 0800 0000 0800 0000 ................
> 0002e560: 1b00 0000 0100 0000 0000 0000 002a 2a2a .............***
> 0002e570: 204e 6f20 4c61 6265 6c20 5072 6f76 6964 No Label Provid
> 0002e580: 6564 202a 2a2a 0000 f1cf 0200 0000 0000 ed ***..........
> 0002e590: 0000 0000 0000 0000 0800 0000 0800 0000 ................
> 0002e5a0: 0c00 0000 0c00 0000 1b00 0000 0100 0000 ................
> 0002e5b0: 0000 0000 0000 0000 002a 2a2a 204e 6f20 .........*** No
> 0002e5c0: 4c61 6265 6c20 5072 6f76 6964 6564 202a Label Provided *
> 0002e5d0: 2a2a 0000 f1cf 0200 0000 0000 0000 0000 **..............
> 0002e5e0: 0000 0000 0800 0000 0e00 0000 1400 0000 ................
> 0002e5f0: 1400 0000 1b00 0000 0100 0000 0000 0000 ................
> and so on...
> this remains even after calling strip.
#define CTF_DEFAULT_LABEL "*** No Label Provided ***"
that's one and possibly more mysteries solved, although I got an even
bigger binary cross compiling to mips.
From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: toolchain/52233: Static binaries are exceptionally massive
Date: Mon, 15 May 2017 18:25:01 +0000
with christos change to src/lib/libc/gen/assert.c:1.18
a dummy binary is 113K.
nick points out there are calls to sysctl along the way, pulling in some
of stdio and more. there's at least one in
_libc_init->__guard_setup->use sysctl to get random numbers, possibly
more.
State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sat, 09 Dec 2017 21:52:57 +0000
State-Changed-Why:
Half size is pretty good
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.