diff --git a/.github/workflows/coding-style.yml b/.github/workflows/coding-style.yml index f63ffa3c..fb8b01c7 100644 --- a/.github/workflows/coding-style.yml +++ b/.github/workflows/coding-style.yml @@ -15,7 +15,7 @@ jobs: steps: - name: dependencies - run: zypper -n install clang git findutils + run: zypper -n install clang git findutils file - uses: actions/checkout@v2 - name: format run: find -type f \( -name "*.[c|h]" -or -name "*.cc" \) -exec clang-format -style=file -i {} \; diff --git a/configure.ac b/configure.ac index a23e41e7..2649d0b2 100644 --- a/configure.ac +++ b/configure.ac @@ -220,16 +220,21 @@ AC_SUBST([PAGE_SIZE], [$($GETCONF PAGE_SIZE)])) _NOPS_LEN=0 _PRE_NOPS_LEN=0 -AS_CASE([$host_cpu], +_LD_LINUX="" +AS_CASE([$target_cpu], [x86_64], [ _NOPS_LEN=16 _PRE_NOPS_LEN=14 + _LD_LINUX="ld-linux-x86-64.so.2" + _PROC="x86_64" ], [powerpc64le], [ _NOPS_LEN=17 _PRE_NOPS_LEN=16 + _LD_LINUX="ld64.so.2" + _PROC="powerpc64le" ] ) @@ -241,13 +246,12 @@ AC_DEFINE_UNQUOTED([ULP_NOPS_LEN], [$ULP_NOPS_LEN], AC_DEFINE_UNQUOTED([PRE_NOPS_LEN], [$PRE_NOPS_LEN], [Padding nops before the entry point of functions]) -_LD_LINUX="" -AC_CHECK_FILE("/usr/lib64/ld-linux-x86-64.so.2", - AC_SUBST([_LD_LINUX], "ld-linux-x86-64.so.2")) -AC_CHECK_FILE("/usr/lib64/ld64.so.2", - AC_SUBST([_LD_LINUX], "ld64.so.2")) +AC_DEFINE_UNQUOTED([LD_LINUX], ["$_LD_LINUX"], +[Path to the ld-linux loader] ) -AC_DEFINE_UNQUOTED([LD_LINUX], ["$_LD_LINUX"], [Path to the ld-linux loader] ) +# Workaround a bug in autoconf 2.69 +AM_CONDITIONAL([CPU_X86_64], [test "$_PROC" == "x86_64"]) +AM_CONDITIONAL([CPU_PPC64LE], [test "$_PROC" == "powerpc64le"]) # Use the glibc versions installed on path AC_ARG_WITH([glibc], @@ -255,7 +259,7 @@ AS_HELP_STRING([--with-glibc=GLIBC_PATH],[Use the glibc installed on GLIBC_PATH, [AC_SUBST([AM_LDFLAGS], ["-Wl,--dynamic-linker=$with_glibc/$_LD_LINUX -Wl,--rpath=$with_glibc/"])], []) -# Check if -fpatchable-function-entry=$ULP_NOPS_LEN,$PRE_NOPS_LEN works +# Check if -fpatchable-function-entry=$ULP_NOPS_LEN,$RE_NOPS_LEN works # correctly. AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[extern void g(void); diff --git a/include/Makefile.am b/include/Makefile.am index 5dc4130a..eee2b5d8 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -27,3 +27,14 @@ noinst_HEADERS = \ terminal_colors.h \ ld_rtld.h \ insn_queue.h + +# Workaround a bug in Autoconf 2.69 +if CPU_X86_64 +noinst_HEADERS += \ + arch/x86_64/arch_common.h +endif + +if CPU_PPC64LE +noinst_HEADERS += \ + arch/powerpc64le/arch_common.h +endif diff --git a/lib/Makefile.am b/lib/Makefile.am index 4c669baf..c6886955 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -23,17 +23,35 @@ libpulp_la_SOURCES = \ ulp.c \ interpose.c \ msg_queue.c \ - error.c \ - arch/$(target_cpu)/ulp_interface.S \ - arch/$(target_cpu)/patch.c -libpulp_la_DEPENDENCIES= libpulp.versions + error.c + libpulp_la_LDFLAGS = \ -ldl \ - -l:@_LD_LINUX@ \ -Wl,--version-script=$(srcdir)/libpulp.versions \ -Wl,--hash-style=sysv \ # Ubuntu seems to default to gnu, so be clear we ... $(AM_LDFLAGS) # ... want old style hash sections, else DT_HASH is empty. +# Workaround a bug in Autoconf 2.69 +if CPU_X86_64 +libpulp_la_SOURCES += \ + arch/x86_64/ulp_interface.S \ + arch/x86_64/patch.c + +libpulp_la_LDFLAGS += \ + -l:ld-linux-x86-64.so.2 +endif + +if CPU_PPC64LE +libpulp_la_SOURCES += \ + arch/powerpc64le/ulp_interface.S \ + arch/powerpc64le/patch.c + +libpulp_la_LDFLAGS += \ + -l:ld64.so.2 +endif + +libpulp_la_DEPENDENCIES= libpulp.versions + libpulp_la_LIBADD = $(top_builddir)/common/libcommon.la AM_CFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/include/arch/$(target_cpu) diff --git a/lib/arch/powerpc64le/patch.c b/lib/arch/powerpc64le/patch.c index 2f0520e4..2c014069 100644 --- a/lib/arch/powerpc64le/patch.c +++ b/lib/arch/powerpc64le/patch.c @@ -27,7 +27,6 @@ #include "config.h" #include "error.h" -#include "insn_queue_lib.h" #include "msg_queue.h" #include "ulp.h" @@ -212,7 +211,7 @@ ulp_patch_addr(void *old_faddr, void *new_faddr, int enable) int ret = 0; if (enable) { - ulp_patch_prologue_layout(dst, new_faddr, ulp_prologue, 4*ULP_NOPS_LEN); + ulp_patch_prologue_layout(dst, new_faddr, ulp_prologue, INSN_SIZE * ULP_NOPS_LEN); ret = ulp_patch_addr_trampoline(dst); } else { ret = ulp_skip_prologue(dst); diff --git a/tests/Makefile.am b/tests/Makefile.am index 58abb6eb..bc2a15e0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -559,9 +559,19 @@ manyprocesses_LDADD = libmanyprocesses.la manyprocesses_DEPENDENCIES = $(POST_PROCESS) $(METADATA) dlsym_SOURCES = dlsym.c -dlsym_LDADD = -lpthread -ldl -lrt -l:@_LD_LINUX@ +dlsym_LDADD = -lpthread -ldl -lrt dlsym_DEPENDENCIES = $(POST_PROCESS) $(METADATA) +# Workaround a bug in Autoconf 2.69 +if CPU_X86_64 +dlsym_LDADD += \ + -l:ld-linux-x86-64.so.2 +endif +if CPU_PPC64LE +dlsym_LDADD += \ + -l:ld64.so.2 +endif + stress_SOURCES = stress.c stress_LDADD = libstress.la stress_DEPENDENCIES = $(POST_PROCESS) $(METADATA) diff --git a/tests/asunsafe_conversion.py b/tests/asunsafe_conversion.py index b1ca5bf7..0eba99b9 100755 --- a/tests/asunsafe_conversion.py +++ b/tests/asunsafe_conversion.py @@ -34,7 +34,7 @@ errors = 0 try: # Apply the live patch. - child.livepatch('.libs/libblocked_livepatch1.so', retries=100) + child.livepatch('.libs/libblocked_livepatch1.so', retries=2000) except subprocess.TimeoutExpired: print('Deadlock while live patching - AS-Unsafe conversion not tested') # The deadlock test (tests/deadlock) has a far greater chance of diff --git a/tools/Makefile.am b/tools/Makefile.am index faa074fb..0637e034 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -55,8 +55,18 @@ ulp_SOURCES = \ pcqueue.c \ extract.c \ set_patchable.c \ - insn_queue.c \ - arch/$(target_cpu)/post-arch.c + insn_queue.c + +# Workaround a bug in Autoconf 2.69 +if CPU_X86_64 +ulp_SOURCES += \ + arch/x86_64/post-arch.c +endif + +if CPU_PPC64LE +ulp_SOURCES += \ + arch/powerpc64le/post-arch.c +endif ulp_LDADD = $(top_builddir)/common/libcommon.la -lelf -ljson-c -lpthread -ldl $(LIBUNWIND_LIBS)