putting __glibcxx_assert_fail into debug.cc bloats binary size by introducing all the dead code with debug.cc

unlvsur unlvsur unlvsur@live.com
Thu Nov 18 09:14:00 GMT 2021


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?







More information about the Libstdc++ mailing list