diff --git a/.github/workflows/oracle-client.yml b/.github/workflows/oracle-client.yml index 83d6ade..d737b01 100644 --- a/.github/workflows/oracle-client.yml +++ b/.github/workflows/oracle-client.yml @@ -1,4 +1,4 @@ -name: oracle_client +name: Oracle Client Test on: push: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 56d7a8e..a82208a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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: @@ -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: @@ -86,44 +85,34 @@ 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 @@ -131,8 +120,11 @@ jobs: 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: @@ -155,20 +147,28 @@ 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 @@ -176,21 +176,6 @@ jobs: 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 }}" diff --git a/plthook_osx.c b/plthook_osx.c index 35c38a9..ba6f757 100644 --- a/plthook_osx.c +++ b/plthook_osx.c @@ -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); diff --git a/test/.gitignore b/test/.gitignore index 717715c..c316569 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -5,3 +5,5 @@ libtest.lib libtest.so testprog testprog.exe +dummy.c +dummy.o diff --git a/test/Makefile b/test/Makefile index 98c0f6a..bc90ed4 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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 @@ -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 diff --git a/test/run-test.bat b/test/run-test.bat index edf5983..b22f014 100644 --- a/test/run-test.bat +++ b/test/run-test.bat @@ -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