Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/oracle-client.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: oracle_client
name: Oracle Client Test
on:
push:

Expand Down
129 changes: 57 additions & 72 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ jobs:
tests_on_ubuntu:
name: Tests on Ubuntu (x86_64 and i686)
if: github.event.inputs.tests_on_ubuntu == 'true' || github.event.inputs.tests_on_ubuntu == ''
strategy:
fail-fast: false
matrix:
optimization: ["", "-O3"]
sanitize: ["", "-g -fsanitize=address -fsanitize=undefined"]
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -39,43 +44,37 @@ jobs:
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y libc6-dbg:i386 libgcc-s1:i386
- name: x86_64 without optimization
run: |
make relro_pie_tests
- name: i686 without optimization
run: |
make relro_pie_m32_tests
- name: x86_64 on valgrind without optimization
run: |
make relro_pie_tests_on_valgrind
- name: uclibc x86_64 without optimization
run: |
./uclibc-test.sh x86_64
- name: uclibc i686 without optimization
run: |
./uclibc-test.sh i686
- name: set OPT_CLFAGS
run: |
echo OPT_CFLAGS=-O3 >> $GITHUB_ENV
- name: x86_64 with optimization
echo OPT_CFLAGS="${{ matrix.optimization }} ${{ matrix.sanitize }}" >> $GITHUB_ENV
- name: x86_64
run: |
make relro_pie_tests
- name: i686 with optimization
- name: i686
run: |
make relro_pie_m32_tests
- name: x86_64 on valgrind with optimization
- name: x86_64 on valgrind
if: ${{ matrix.sanitize == '' }} # Run without sanitizers only
run: |
make relro_pie_tests_on_valgrind
- name: uclib x86_64 with optimization
- name: uclibc x86_64
if: ${{ matrix.sanitize == '' }} # Run without sanitizers only
run: |
./uclibc-test.sh x86_64
- name: uclibc i686 with optimization
- name: uclibc i686
if: ${{ matrix.sanitize == '' }} # Run without sanitizers only
run: |
./uclibc-test.sh i686

tests_on_qemu:
name: Tests on Qemu (arm, armhf, arm64, ppc, ppc64le and riscv64)
if: github.event.inputs.tests_on_qemu == 'true' || github.event.inputs.tests_on_qemu == ''
strategy:
fail-fast: false
matrix:
optimization: ["", "-O2", "-O3"]
# TODO: Sanitizer fails in armhf and aarch64
# sanitize: ["", "-g -fsanitize=address -fsanitize=undefined"]
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -86,53 +85,46 @@ jobs:
run: |
sudo apt update
sudo apt install -y qemu-user gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-powerpc-linux-gnu gcc-powerpc64le-linux-gnu gcc-riscv64-linux-gnu libc6-dev-armhf-cross libc6-dev-ppc64el-cross libc6-dev-powerpc-cross libc6-dev-armel-cross libc6-dev-arm64-cross
- name: arm-linux-gnueabi without optimization
- name: Set OPT_CLFAGS
run: |
echo OPT_CFLAGS="${{ matrix.optimization }}" >> $GITHUB_ENV
# TODO: Sanitizer fails in armhf and aarch64
# echo OPT_CFLAGS="${{ matrix.optimization }} ${{ matrix.sanitize }}" >> $GITHUB_ENV
- name: arm-linux-gnueabi
env:
OPT_CFLAGS: "-latomic"
run: |
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabi
- name: arm-linux-gnueabihf without optimization
- name: arm-linux-gnueabihf
env:
# TODO: detect_leaks=0 because it fails to create the ptrace thread
LSAN_OPTIONS: "verbosity=1:log_threads=1:detect_leaks=0"
run: |
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabihf
- name: aarch64-linux-gnu without optimization
- name: aarch64-linux-gnu
# TODO: aarch64 fails with optimizations https://github.com/kubo/plthook/issues/51
if: ${{ matrix.optimization == '' }}
run: |
make relro_pie_tests TARGET_PLATFORM=aarch64-linux-gnu
- name: powerpc-linux-gnu without optimization
run: |
make relro_pie_tests TARGET_PLATFORM=powerpc-linux-gnu QEMU_ARCH=ppc
- name: powerpc64le-linux-gnu without optimization
run: |
make relro_pie_tests TARGET_PLATFORM=powerpc64le-linux-gnu QEMU_ARCH=ppc64le
- name: riscv64-linux-gnu without optimization
run: |
make relro_pie_tests TARGET_PLATFORM=riscv64-linux-gnu QEMU_ARCH=riscv64
- name: set OPT_CLFAGS
run: |
echo OPT_CFLAGS=-O3 >> $GITHUB_ENV
- name: arm-linux-gnueabi with optimization
run: |
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabi
- name: arm-linux-gnueabihf with optimization
run: |
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabihf
# TODO: https://github.com/kubo/plthook/issues/51
# - name: aarch64-linux-gnu with optimization
# run: |
# make relro_pie_tests TARGET_PLATFORM=aarch64-linux-gnu
- name: powerpc-linux-gnu with optimization
- name: powerpc-linux-gnu
run: |
make relro_pie_tests TARGET_PLATFORM=powerpc-linux-gnu QEMU_ARCH=ppc
- name: powerpc64le-linux-gnu with optimization
- name: powerpc64le-linux-gnu
run: |
make relro_pie_tests TARGET_PLATFORM=powerpc64le-linux-gnu QEMU_ARCH=ppc64le
- name: riscv64-linux-gnu with optimization
- name: riscv64-linux-gnu
run: |
make relro_pie_tests TARGET_PLATFORM=riscv64-linux-gnu QEMU_ARCH=riscv64

tests_on_macos:
name: Tests on macOS
if: github.event.inputs.tests_on_macos == 'true' || github.event.inputs.tests_on_macos == ''
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14, macos-15]
optimization: ["", "-O3"]
sanitize: ["", "-g -fsanitize=address -fsanitize=undefined"]
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -155,42 +147,35 @@ jobs:
- name: dyld_info
run: |
for arg in -segments -dependents -inits -exports -imports -objc -fixups -fixup_chains -fixup_chain_details -symbolic_fixups; do echo "======== $arg ========"; xcrun dyld_info $arg libtest.so; done; true
- name: tests without optimization
run: |
make run_tests
- name: set OPT_CLFAGS
run: |
echo OPT_CFLAGS=-O3 >> $GITHUB_ENV
- name: tests with optimization
echo OPT_CFLAGS="${{ matrix.optimization }} ${{ matrix.sanitize }}" >> $GITHUB_ENV
- name: Tests
run: |
make run_tests

tests_on_windows:
name: Tests on Windows (x64 and x86)
if: github.event.inputs.tests_on_windows == 'true' || github.event.inputs.tests_on_windows == ''
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
os: [2019, 2022, 2025]
architecture: [x86, amd64]
options: [
{ dll: "/LD /MD", exe: "/MD" },
{ dll: "/LD /MD /O2", exe: "/MD /O2" },
{ dll: "/LDd /MDd", exe: "/MDd" },
{ dll: "/LDd /MDd /Z7 /fsanitize=address", exe: "/MDd /Z7 /fsanitize=address" }
]
runs-on: windows-${{ matrix.os }}
defaults:
run:
shell: cmd
working-directory: test
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: x64 without optimization
run: |
run-test.bat amd64 "-LD -MD" "-MD"
- name: x86 without optimization
run: |
run-test.bat x86 "-LD -MD" "-MD"
- name: x64 with optimization
run: |
run-test.bat amd64 "-LD -MD -O2" "-MD -O2"
- name: x86 with optimization
run: |
run-test.bat x86 "-LD -MD -O2" "-MD -O2"
- name: x64 with debug
run: |
run-test.bat amd64 "-LDd -MDd" "-MDd"
- name: x86 with debug
- name: Test
run: |
run-test.bat x86 "-LDd -MDd" "-MDd"
run-test.bat ${{ matrix.os }} ${{ matrix.architecture }} "${{ matrix.options.dll }}" "${{ matrix.options.exe }}"
2 changes: 0 additions & 2 deletions plthook_osx.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ int plthook_open(plthook_t **plthook_out, const char *filename)
}
cnt = _dyld_image_count();
namelen = strlen(filename);
namelen = strlen(filename);
cnt = _dyld_image_count();

for (idx = 0; idx < cnt; idx++) {
const char *image_name = _dyld_get_image_name(idx);
Expand Down
2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ libtest.lib
libtest.so
testprog
testprog.exe
dummy.c
dummy.o
7 changes: 4 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
UNAME_S := $(shell uname -s)

CFLAGS_SHARED = -shared -fPIC
CFLAGS = $(CFLAGS_WARNING) $(EXTRA_CFLAGS) $(OPT_CFLAGS)
CFLAGS_WARNING = -Wall
CFLAGS = $(CFLAGS_WARNING) $(EXTRA_CFLAGS) $(OPT_CFLAGS)
LDFLAGS = $(EXTRA_LDFLAGS) $(OPT_LDFLAGS)
EXEEXT =
SOEXT = so
LIBS = -ldl -lm
Expand Down Expand Up @@ -58,10 +59,10 @@ endif
all: libtest.$(SOEXT) testprog$(EXEEXT)

libtest.$(SOEXT): libtest.c libtest.h
$(CC) $(CFLAGS_SHARED) $(CFLAGS) -DLIBTEST_DLL -o libtest.$(SOEXT) libtest.c -lm
$(CC) $(CFLAGS_SHARED) $(CFLAGS) -DLIBTEST_DLL -o libtest.$(SOEXT) libtest.c -lm $(LDFLAGS)

testprog$(EXEEXT): testprog.c ../$(PLTHOOK_C) libtest.h
$(CC) $(CFLAGS_EXE) $(CFLAGS) -o testprog$(EXEEXT) -I.. testprog.c ../$(PLTHOOK_C) -L. -ltest $(LIBS)
$(CC) $(CFLAGS_EXE) $(CFLAGS) -o testprog$(EXEEXT) -I.. testprog.c ../$(PLTHOOK_C) -L. -ltest $(LIBS) $(LDFLAGS)

run_tests: clean libtest.$(SOEXT) testprog$(EXEEXT)
LD_LIBRARY_PATH=. $(KICK_CMD) ./testprog$(EXEEXT) open
Expand Down
9 changes: 7 additions & 2 deletions test/run-test.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %1
nmake /f Makefile.win32 check clean DLL_CFLAGS=%2 EXE_CFLAGS=%3
if "%1" == "2019" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %2
) else (
@rem "TODO: Implement 2025 support in the future"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %2
)
nmake /f Makefile.win32 check clean DLL_CFLAGS=%3 EXE_CFLAGS=%4