HexHive / retrowrite-dev

Retrowrite Development (Internal) Repository
7 stars 2 forks source link

Full-static compilation tests #9

Closed diagprov closed 2 years ago

diagprov commented 3 years ago

Fully-statically compiled binaries are those that have no shared object dependencies at all. They include a full working copy of libc inside their own ELF container and do not need to load any other shared objects. You can try ldd to see if this is the case:

$ ldd name-of-binary
    statically linked

or

$ ldd name-of-binary
    not a dynamic executable

I have added tests/integration/amd64_musl_fullstatic and tests/integration/arm64_musl_fullstatic which includes fully-statically-compiled versions of "hello world", linked against musl-libc and compiled as position-independent-executables.

This issue exists to track progress for fixing this case in retrowrite, which currently fails.


Things you might want to know if replicating:

  1. Static compilation with glibc is almost not supported any more. Some distributions (Fedora) do not provide static libc objects at all. Others (Ubuntu) do. The libc will need to be compiled as -pie; I am not aware of the status of ubuntu's libc-static-dev.
  2. musl-cross-make with --enable-default-pie is the easiest method I have found for this kind of thing.
  3. You will need to be sure to pass -static -Bstatic -pie -fPIC when linking and -fpic when compiling.