Skip to content

Commit

Permalink
Overhaul dependency management.
Browse files Browse the repository at this point in the history
A (cut-down) version of Zydis and lindw are now
included in a new contrib/ directory.  The build
system now uses these versions rather than
downloading code or relying on dynamic loading.
This makes the code self-contained, and simplifies
the build process.
  • Loading branch information
GJDuck committed Jun 28, 2024
1 parent 03375cf commit b6fee73
Show file tree
Hide file tree
Showing 204 changed files with 100,021 additions and 155 deletions.
49 changes: 31 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#CXX=clang++

CXXFLAGS = -std=c++11 -Wall -Wno-reorder -fPIC -pie -march=native \
-DVERSION=$(shell cat VERSION)
-DVERSION=$(shell cat VERSION) -Wl,-rpath=/usr/share/e9tool/lib/

E9PATCH_OBJS=\
src/e9patch/e9CFR.o \
Expand Down Expand Up @@ -33,10 +33,21 @@ E9TOOL_OBJS=\
src/e9tool/e9tool.o \
src/e9tool/e9types.o \
src/e9tool/e9x86_64.o
E9TOOL_LIBS=\
contrib/zydis/libZydis.a \
contrib/libdw/libdw.a
E9TOOL_CXXFLAGS=\
-I src/e9tool/ -Wno-unused-function \
-I contrib/libdw/ \
-I contrib/zydis/include/ \
-I contrib/zydis/dependencies/zycore/include/
E9TOOL_LDFLAGS=\
-Wl,--dynamic-list=src/e9tool/e9tool.syms \
-lpthread -ldl -lz

release: CXXFLAGS += -O2 -D NDEBUG
release: $(E9PATCH_OBJS)
$(CXX) $(CXXFLAGS) $(E9PATCH_OBJS) -o e9patch $(LDFLAGS)
$(CXX) $(CXXFLAGS) $(E9PATCH_OBJS) -o e9patch
strip e9patch

debug: CXXFLAGS += -O0 -g
Expand All @@ -47,25 +58,21 @@ sanitize: CXXFLAGS += -O0 -g -fsanitize=address
sanitize: $(E9PATCH_OBJS)
$(CXX) $(CXXFLAGS) $(E9PATCH_OBJS) -o e9patch

tool: CXXFLAGS += -O2 -I src/e9tool/ -I zydis/include/ \
-I zydis/dependencies/zycore/include/ -Wno-unused-function
tool: $(E9TOOL_OBJS)
$(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) -o e9tool libZydis.a \
-Wl,--dynamic-list=src/e9tool/e9tool.syms -ldl $(LDFLAGS)
tool: CXXFLAGS += -O2 $(E9TOOL_CXXFLAGS)
tool: $(E9TOOL_OBJS) $(E9TOOL_LIBS)
$(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) $(E9TOOL_LIBS) -o e9tool \
$(E9TOOL_LDFLAGS) -Wl,-Map=output.map
strip e9tool

tool.debug: CXXFLAGS += -O0 -g -I src/e9tool/ -I zydis/include/ \
-I zydis/dependencies/zycore/include/ -Wno-unused-function
tool.debug: $(E9TOOL_OBJS)
$(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) -o e9tool libZydis.a \
-Wl,--dynamic-list=src/e9tool/e9tool.syms -ldl
tool.debug: CXXFLAGS += -O0 -g $(E9TOOL_CXXFLAGS)
tool.debug: $(E9TOOL_OBJS) $(E9TOOL_LIBS)
$(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) $(E9TOOL_LIBS) -o e9tool \
$(E9TOOL_LDFLAGS)

tool.sanitize: CXXFLAGS += -O0 -g -I src/e9tool/ -I zydis/include/ \
-I zydis/dependencies/zycore/include/ -Wno-unused-function \
-fsanitize=address
tool.sanitize: $(E9TOOL_OBJS)
$(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) -o e9tool libZydis.a \
-Wl,--dynamic-list=src/e9tool/e9tool.syms -ldl
tool.sanitize: CXXFLAGS += -O0 -g -fsanitize=address $(E9TOOL_CXXFLAGS)
tool.sanitize: $(E9TOOL_OBJS) $(E9TOOL_LIBS)
$(CXX) $(CXXFLAGS) $(E9TOOL_OBJS) $(E9TOOL_LIBS) -o e9tool \
$(E9TOOL_LDFLAGS)

tool.clean:
rm -rf $(E9TOOL_OBJS) e9tool
Expand All @@ -86,6 +93,12 @@ loader_pe:
src/e9patch/e9elf.o: loader_elf
src/e9patch/e9pe.o: loader_pe

contrib/zydis/libZydis.a:
(cd contrib/zydis/; make)

contrib/libdw/libdw.a:
(cd contrib/libdw/; make)

clean:
rm -rf $(E9PATCH_OBJS) e9patch \
src/e9patch/e9loader.c e9loader.out e9loader.o e9loader.bin
Expand Down
50 changes: 0 additions & 50 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,56 +36,6 @@ do
shift
done

TARGET=`readlink zydis`
if [ ! -d zydis ]
then
ZYDIS_VERSION=3f5a3ad8e16658c62d7033e9373232d19480d3cc
ZYCORE_VERSION=5c341bf141fe9274c9037c542274ead19fb645d8

echo -e "${GREEN}$0${OFF}: downloading zydis-$ZYDIS_VERSION.zip..."
wget -O zydis-$ZYDIS_VERSION.zip https://github.com/zyantific/zydis/archive/$ZYDIS_VERSION.zip

echo -e "${GREEN}$0${OFF}: downloading zycore-$ZYCORE_VERSION.zip..."
wget -O zycore-$ZYCORE_VERSION.zip https://github.com/zyantific/zycore-c/archive/$ZYCORE_VERSION.zip

echo -e "${GREEN}$0${OFF}: extracting zydis-$ZYDIS_VERSION.zip..."
unzip zydis-$ZYDIS_VERSION.zip
rm -f zydis-$ZYDIS_VERSION.zip

echo -e "${GREEN}$0${OFF}: extracting zycore-$ZYCORE_VERSION.zip..."
unzip zycore-$ZYCORE_VERSION.zip
rm -f zycore-$ZYCORE_VERSION.zip

echo -e "${GREEN}$0${OFF}: building Zydis..."
mv zydis-$ZYDIS_VERSION zydis/
rm -rf zydis/dependencies/zycore/
mv zycore-c-$ZYCORE_VERSION zydis/dependencies/zycore/
rm -rf zycore-c-$ZYCORE_VERSION
cat << EOF > zydis/include/ZydisExportConfig.h
#ifndef ZYDIS_EXPORT_H
#define ZYDIS_EXPORT_H
#define ZYDIS_EXPORT
#define ZYDIS_NO_EXPORT
#define ZYDIS_DEPRECATED __attribute__ ((__deprecated__))
#define ZYDIS_DEPRECATED_EXPORT ZYDIS_EXPORT ZYDIS_DEPRECATED
#define ZYDIS_DEPRECATED_NO_EXPORT ZYDIS_NO_EXPORT ZYDIS_DEPRECATED
#define ZYDIS_NO_DEPRECATED
#endif
EOF
cat << EOF > zydis/include/ZycoreExportConfig.h
#ifndef ZYCORE_EXPORT_H
#define ZYCORE_EXPORT_H
#define ZYCORE_EXPORT
#define ZYCORE_NO_EXPORT
#define ZYCORE_DEPRECATED __attribute__ ((__deprecated__))
#define ZYCORE_DEPRECATED_EXPORT ZYCORE_EXPORT ZYCORE_DEPRECATED
#define ZYCORE_DEPRECATED_NO_EXPORT ZYCORE_NO_EXPORT ZYCORE_DEPRECATED
#define ZYCORE_NO_DEPRECATED
#endif
EOF
make -f Makefile.zydis -j `nproc`
fi

echo -e "${GREEN}$0${OFF}: building e9patch and e9tool..."
make tool.clean clean
make -j `nproc` tool release
Expand Down
104 changes: 104 additions & 0 deletions contrib/libdw/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Aaron Merey
Adam Markey
Adrian Ratiu
Ahelenia Ziemiańska
Akihiko Odaki
Alexander Cherepanov
Alexander Kanavin
Alexander Miller
Alice Zhang
Andreas Krebbel
Andreas Schwab
Andrei Homescu
Anthony G. Basile
Ben Woodard
Chih-Hung Hsieh
Claudio Rodrigo Pereyra Diaz
Colin Cross
Cornelius Neckenig
Daniel Cabrera
David Abdurachmanov
Di Chen
Dima Kogan
Dimitris Glezos
Dmitry V. Levin
Dodji Seketeli
Domingo Becker
Eduardo Santiago
Eli Schwartz
Érico Nogueira
Érico Rolim
Filipe Brandenburger
Florian Weimer
Francesco Tombolini
Frank Ch. Eigler
Geert Warrink
Gladys Guerrero
Gustavo Romero
Hayatsu Shunsuke
H.J. Lu
Hyu_gabaru Ryu_ichi
Jakub Jelinek
Jan Kratochvil
Jan Pokorný
Jason P. Leasure
Jean Pihet
Jeff Kenton
Jim Wilson
John M Mellor-Crummey
John Ogness
Jonathan Lebon
Jonathon Anderson
Jose E. Marchesi
Josh Stone
Joshua Watt
Kevin Cernekee
kiyoto hashida
Konrad Kleine
Kurt Roeckx
Kyle McMartin
Lei Zhang
Lubomir Rintel
Luca Boccassi
Luiz Angelo Daros de Luca
Mao Han
Marek Polacek
Mark Wielaard
Martin Liska
Masatake YAMATO
Matt Fleming
Matthias Klose
Matthias Maennich
Max Filippov
Michael Forney
Michael Münch
Mike Frysinger
Milian Wolff
Namhyung Kim
Noah Sanci
Noriko Mizumoto
Omar Sandoval
Petr Machata
Pino Toscano
Piotr Drąg
Ravi Bangoria
Richard Henderson
Roland McGrath
Rosen Penev
Ross Burton
Saleem Abdulrasool
Sergei Trofimovich
Srđan Milaković
Steven Chamberlain
Thomas Canniot
Thomas Spura
Timm Bäder
Tom Tromey
Ulf Hermann
Ulrich Drepper
Wei Liu
William Cohen
Yonghong Song
Yulia Poyarkova
Yunlian Jiang
Yuri Chornoivan
Loading

0 comments on commit b6fee73

Please sign in to comment.