News for hackers. Stuff that matters.
Re:Slim Binaries (1997) by jacinabox on Wednesday July 31, 2019 @11:51AM (#20575406)
In the early aughts I was kicking around an idea for minimization of binaries/libraries. The idea was to take a compiled binary plus debug information, and use disassembly to work out which code paths are reachable from a selected set of entry points (say the ones used by your application). Then code paths which are considered "dead" would be zeroed out, preparing a minimized binary.
Re:Slim Binaries (1997) by thefreeman on Wednesday July 31, 2019 @12:09PM (#20575564)
Don't most compilers already do this?
Re:Slim Binaries (1997) by acqq on Wednesday July 31, 2019 @04:41PM (#20578320)
Speaking about C and C++ on Linux, I have an impression that the compilers seldom can decide that the whole functions aren't used, especially because most libraries and programs "export" "everything" by default, so only on run-time it can be decided what will be actually used -- the last linking step happens only when you start the program, by the loader.
Re:Slim Binaries (1997) by saagarjha on Wednesday July 31, 2019 @12:31PM (#20575782)
Yeah, isn't this just link-time optimization?
Re:Slim Binaries (1997) by throwaway542134 on Wednesday July 31, 2019 @01:21PM (#20576306)
It's called dead code elimination/optimization and compilers can do it without LTO, with LTO you can can get more savings but ymmv.
Re:Slim Binaries (1997) by saagarjha on Wednesday July 31, 2019 @01:28PM (#20576378)
The original comment pointed out "entry points", so I assumed that they were talking about libraries rather than standard dead code elimination (which has been a thing for quite some time).
Re:Slim Binaries (1997) by ronsor on Wednesday July 31, 2019 @11:52AM (#20575412)
solution: run the application and find out what functions are/are not called.
Re:Slim Binaries (1997) by mrec on Wednesday July 31, 2019 @12:01PM (#20575495)
That only tells you what functions got called on that run, for that run's sequence of inputs.

https://fgiesen.wordpress.com/2012/04/08/metaprogramming-for...

Taster:

> In the menu at the start, cursor-down works, but cursor-up doesn’t (he never hit cursor-up in menus during the test run). The small enemies at the start can hit you, but he didn’t get hit by any enemy shots, so in the released version of .kkrieger enemy shots deal no damage.