Closed milahu closed 1 month ago
Yes, the build system is slightly unconventional and could be normalized. This project really does not have any dependencies (aside from zydis
, which requires a specific version to be statically linked in), which is why a simple build script suffices without needing things like autotools or cmake, etc. Perhaps a more conventional build process could be supported in parallel.
zydis
, which requires a specific version to be statically linked in
Could you elaborate on the reason behind this? I'm trying to package e9Patch for Guix and dependency vendoring is a no-go for security reasons (not just Guix but also most distributions). It's perfectly fine if E9Patch relies on a specific version of Zydis (with some extra patches) though.
Can't test on non-POSIX systems, but on normal systems both vendored dependencies (elfutils and zydis+zycore) are installed to standard locations so a C compiler can find the libraries with -ldw -lZydis
(zlib is already linked this way) and the headers naturally (with a tiny change into #include <elfutils/libdw.h>
).
Could you elaborate on the reason behind this?
libdw
, E9tool only needs a relatively small part of the library (line number parsing code), so only that specific functionality was included (& statically linked). libz
, it is pulled in by libdw
(ELF compressed sections?). It is stable and ubiquitous, so not really a problem.So I think it would be problematic to change the version of Zydis. For libdw
, it would be a relatively small effort to use dynamic linking and the system libdw
, and this could be achieved by updating the Makefile
to support this option. In fact, the Makefile
should probably be updated to use conventional targets and build options by default, and can still support unconventional builds via non-standard targets.
I've added a more traditional build:
$ make
$ make install
This is in addition to the old build.sh
and install.sh
scripts.
Perhaps this will help. Please let me know if anything else is needed.
thanks!
almost there, see my e9patch.nix and Makefile
dependency: zydis.nix
make install
fails with
install: cannot create directory '/usr': Permission denied
fixed by using $(prefix)
in Makefile
e9compile
does not find stdlib.c
typo: example -> examples
broken colors in e9compile
(deja vu...)
fixed by
sed -i -E s/'="\\033\[([0-9]+)m"'/"=$'\\\\033[\1m'"/ e9compile.sh
type warning in src/e9tool/e9cfg.cpp
- %zu
-> %u
not sure if the segfault is expected ...
$ ./result/bin/e9compile result/share/e9tool/examples/bounds.c
gcc -fno-stack-protector -fno-builtin -fno-exceptions -fpie -O2 -Wno-unused-function -U_FORTIFY_SOURCE -mno-mmx -mno-sse -mno-avx -mno-avx2 -mno-avx512f -msoft-float -mstringop-strategy=loop -fno-tree-vectorize -fomit-frame-pointer -I /nix/store/by9kqjzr4pbikqma6scqwrv5a5h7zm5c-e9patch-1.0.0-rc10-unstable-2024-08-07/share/e9compile/include/ -c -Wall result/share/e9tool/examples/bounds.c
gcc bounds.o -o bounds -pie -nostdlib -Wl,-z -Wl,max-page-size=4096 -Wl,-z -Wl,norelro -Wl,-z -Wl,stack-size=0 -Wl,--export-dynamic -Wl,--entry=0x0 -Wl,--strip-all
$ ./bounds
Segmentation fault (core dumped)
Thanks, I will check what changes are necessary.
not sure if the segfault is expected ...
Yes, the SEGV is not ideal, but it is expected. The e9compile
script emits a binary executable that is compatible with E9Tool instrumentation, but is not designed to be run directly.
I assume this has been resolved.
colors are still broken
note the $
before '...'
aka ansi c quoted strings
$ echo '\033[31mred\033[0m'
\033[31mred\033[0m
$ echo -e '\033[31mred\033[0m'
red
$ echo 'RED="\033[31m"' | sed -E s/'="\\033\[([0-9]+)m"'/"=$'\\\\033[\1m'"/
RED=$'\033[31m'
$ echo $'\033[31mred\033[0m'
red
low priority...
currently, packaging e9patch is too verbose
ideally, build and install should work with
make && sudo make install
ideally, the build should work offline by default,
make
should download and unpack thezydis
andzycore
sources optionally,make
should acceptZYDIS_SOURCE
andZYCORE_SOURCE
envs to copy the unpacked sources from these pathscurrently,
ZydisExportConfig.h
andZycoreExportConfig.h
are generated bybuild.sh
these should be stored as*.h.in
files and copied tozydis/include/