public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: unlvsur unlvsur <unlvsur@live.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>,
	unlvsur unlvsur via Libstdc++ <libstdc++@gcc.gnu.org>
Subject: RE: putting __glibcxx_assert_fail into debug.cc bloats binary size by introducing all the dead code with debug.cc
Date: Thu, 18 Nov 2021 09:14:00 +0000	[thread overview]
Message-ID: <DM6PR05MB469746A3BC3CA8829147D5BED69B9@DM6PR05MB4697.namprd05.prod.outlook.com> (raw)
In-Reply-To: <DM6PR05MB4697793016DC8EB292B6C425D69B9@DM6PR05MB4697.namprd05.prod.outlook.com>

That is exactly why newlib or musl puts every function into separate translation unit to prevent dead code.

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows

From: unlvsur unlvsur<mailto:unlvsur@live.com>
Sent: Thursday, November 18, 2021 04:12
To: Jonathan Wakely<mailto:jwakely.gcc@gmail.com>; unlvsur unlvsur via Libstdc++<mailto:libstdc++@gcc.gnu.org>
Subject: RE: putting __glibcxx_assert_fail into debug.cc bloats binary size by introducing all the dead code with debug.cc

There are all sorts of reasons why it does not work.

sec18-quach.pdf (usenix.org)<https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-quach.pdf>

In the security paper Debloating Software through Piece-Wise Compilation and Loading

Unused Functions. Static analysis during compilation can efficiently remove dead code at a basic block level,
however, entire unused functions are not eliminated. Consider the following program:

int f() { return 1; }
int main() { return 0; }

Both gcc and clang retain the function f in
the above code even under optimization level
-O3. Removal of unused functions require additional non-standard often-unused compiler (-fdata-sections -ffunction-sections -Os) and linker (-Wl,--gc-sections) optimization flags.
Even so, unused functions in dynamically loaded libraries can not be eliminated during compile time.

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows

From: Jonathan Wakely<mailto:jwakely.gcc@gmail.com>
Sent: Thursday, November 18, 2021 04:09
To: unlvsur unlvsur<mailto:unlvsur@live.com>
Cc: unlvsur unlvsur via Libstdc++<mailto:libstdc++@gcc.gnu.org>
Subject: Re: putting __glibcxx_assert_fail into debug.cc bloats binary size by introducing all the dead code with debug.cc


On Thu, 18 Nov 2021, 03:16 unlvsur unlvsur via Libstdc++, <libstdc++@gcc.gnu.org<mailto:libstdc%2B%2B@gcc.gnu.org>> wrote:
Can we put it into a separate translation unit with only __glibcxx_assert_fail? Linker does not remove dead functions.

Why does -ffunction-sections not help?






  reply	other threads:[~2021-11-18  9:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18  3:16 unlvsur unlvsur
2021-11-18  9:09 ` Jonathan Wakely
2021-11-18  9:12   ` unlvsur unlvsur
2021-11-18  9:14     ` unlvsur unlvsur [this message]
2021-11-18  9:44     ` Jonathan Wakely
2021-11-18  9:51       ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR05MB469746A3BC3CA8829147D5BED69B9@DM6PR05MB4697.namprd05.prod.outlook.com \
    --to=unlvsur@live.com \
    --cc=jwakely.gcc@gmail.com \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).