Skip to content

Commit

Permalink
Workaround bug in autoconf 2.69
Browse files Browse the repository at this point in the history
Autoconf 2.69 does not expand the $(target_cpu) variable when creating
directories, hence we have to do things manually.  Also it doesn't
seems to like the @var@ variable replacements.

Signed-off-by: Giuliano Belinassi <[email protected]>
  • Loading branch information
giulianobelinassi committed Oct 14, 2024
1 parent 482f139 commit b74f6be
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} \;
Expand Down
20 changes: 12 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
)

Expand All @@ -241,21 +246,20 @@ 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],
AS_HELP_STRING([--with-glibc=GLIBC_PATH],[Use the glibc installed on GLIBC_PATH, where the .so file is present]),
[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);
Expand Down
11 changes: 11 additions & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 23 additions & 5 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions lib/arch/powerpc64le/patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#include "config.h"
#include "error.h"
#include "insn_queue_lib.h"
#include "msg_queue.h"
#include "ulp.h"

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/asunsafe_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions tools/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b74f6be

Please sign in to comment.