Skip to content

Switch to lief for binary parsing, add OSX support. - #41

Open
TaylorSasser wants to merge 1 commit into
yugr:masterfrom
TaylorSasser:add-osx-support
Open

Switch to lief for binary parsing, add OSX support.#41
TaylorSasser wants to merge 1 commit into
yugr:masterfrom
TaylorSasser:add-osx-support

Conversation

@TaylorSasser

Copy link
Copy Markdown

No description provided.

@yugr

yugr commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Testing

Your Lief port seems to work reasonably well! There are some crashes on Linux though which you may want to check. They all look like

File "/home/yugr/src/Implib.so-Taylor/./implib-gen.py", line 699, in <module>
  sys.exit(main())
File "/home/yugr/src/Implib.so-Taylor/./implib-gen.py", line 688, in main
  Generator(backend, templates_dir=str(platform_root / arch),
common_templates_dir=str(platform_root / "common"),
File "/home/yugr/src/Implib.so-Taylor/./implib-gen.py", line 592, in run
  self.backend.collect_relocations(), opts.ptr_size, opts.symbol_reloc_types,
File "/home/yugr/src/Implib.so-Taylor/./implib-gen.py", line 304, in
collect_relocations
  idx = bisect.bisect_right(starts, target_addr) - 1
TypeError: '<' not supported between instances of 'lief_errors' and 'int'

(e.g. got this for /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30 from libstdc++6 package on Ubuntu 22.04).

You probably also want to

-    platform_root = Path(__file__).resolve().parent / "arch" / args.platform
+    platform_root = Path(__file__).resolve().parent / "arch" / platform

I got significant mismatches in init.c files with --vtables enabled for some libraries:

  • libboost_wserialization.so.1.74.0.init.c
  • libgvplugin_visio.so.6.0.0.init.c
  • libicui18n.so.70.1.init.c
  • etc.

This may well be a bug in current Implib.so which I should look into !

Performance

My findings here are not very inspiring: despite being implemented in C++ and omitting several heavy libs due to crashes, lief-based implementation is significantly slower: on Ubuntu 22.04 with some additional libs installed I got ~400 sec. for legacy vs ~1200 sec. for lief (see scripts/perf_test.sh).

Portability

Lief does not support all Implib.so platforms, particularly BSDs. Only FreeBSD has some (super-old) port and other users on other BSD flavors will have to build lief and all its dependencies from source.

Maintenance

Although lief seems to be good and well-maintained piece of code there are some obvious disadvantages:

  1. It is a non-trivial dependency with lots of C++ code (90 KLOC). My experience with Binutils helped me in the past and switching to lief will require significant investment in case of bugs in future.

  2. Lief is mainly developed by single developer so bus factor is rather high and also issues may take long to respond/fix.

  3. Lief API is unstable even in minor versions. This will complicate maintenance and may force some users to use virtualenvs for implib-gen which is not very convenient.

Questions

I think my main question is whether lief solves some problems or is just cleaner and easier to use than current approach.

It's obviously more modern and convenient than parsing raw readelf (or doing portability layer on top of it) but it also comes with its own disadvantages like performance, lack of BSD support and maintenance
risks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants