diff --git a/configure.ac b/configure.ac index 4034ae7b..d73a3a0f 100644 --- a/configure.ac +++ b/configure.ac @@ -150,6 +150,16 @@ AC_SUBST([LIBUNWIND_LIBS], ["-lunwind-generic -lunwind-ptrace -lunwind"]) AC_DEFINE(ENABLE_STACK_CHECK, 1, [Enable stack checking routines]), AC_DEFINE(ENABLE_STACK_CHECK, 0, [Disable stack checking routines])) +# Enable a gdb interface so that livepatches can be triggered within gdb. +AC_ARG_ENABLE(gdb-interface, +AS_HELP_STRING([--enable-gdb-interface], +[build and exposes an interface for livepatching withing gdb. [default=no]]), +[enable_gdb_interface=yes], +[enable_gdb_interface=no; break]) + +AS_IF([test "$enable_gdb_interface" = "yes"], +AC_DEFINE(ENABLE_GDB_INTERFACE, 1, [Enable gdb interface for livepatching])) + # Check if libseccomp is present. This is required for testing. CFLAGS="$CFLAGS -I/usr/include/libseccomp/" AC_CHECK_HEADER([seccomp.h],, diff --git a/include/insn_queue_lib.h b/include/insn_queue_lib.h index 72f1fa90..adc18710 100644 --- a/include/insn_queue_lib.h +++ b/include/insn_queue_lib.h @@ -32,7 +32,12 @@ ulp_error_t insnq_insert_write(void *addr, int n, const void *bytes); int insnq_ensure_emptiness(void); +/* Not necessary if compiling without gdb interface. */ +#ifdef ENABLE_GDB_INTERFACE + /** Interpret the global instruction queue from process side. */ int insnq_interpret_from_lib(void); +#endif //ENABLE_GDB_INTERFACE + #endif diff --git a/include/minielf.h b/include/minielf.h index e4efdc91..9ef69511 100644 --- a/include/minielf.h +++ b/include/minielf.h @@ -24,6 +24,9 @@ * in this library. */ +/* This file is not needed if we are compiling without gdb interface. */ +#ifdef ENABLE_GDB_INTERFACE + #include /** Maximum size of the Section String Table. */ @@ -67,3 +70,5 @@ long Get_ULP_Section(unsigned dest_size, unsigned char *dest, const char *file); /** Get the .ulp.rev section from the given ELF file. */ long Get_ULP_REV_Section(unsigned dest_size, unsigned char *dest, const char *file); + +#endif //ENABLE_GDB_INTERFACE diff --git a/lib/gdb_interface.c b/lib/gdb_interface.c index 94533eb1..09262a83 100644 --- a/lib/gdb_interface.c +++ b/lib/gdb_interface.c @@ -20,7 +20,11 @@ */ /* Small interface that allows livepatches to be applied or reverted - * within gdb. */ + * within gdb. There is no need to compile this file if + * ENABLE_GDB_INTERFACE is not defined. + */ + +#ifdef ENABLE_GDB_INTERFACE #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -151,3 +155,5 @@ gdb_ulp_revert(const char *path) return 0; } + +#endif //ENABLE_GDB_INTERFACE diff --git a/lib/minielf.c b/lib/minielf.c index 5b1a4856..39b7e17e 100644 --- a/lib/minielf.c +++ b/lib/minielf.c @@ -24,6 +24,9 @@ * in this library. */ +/* So far there is no need to compile this file if GDB interface is not set. */ +#ifdef ENABLE_GDB_INTERFACE + #include #include #include @@ -246,3 +249,5 @@ Get_ULP_REV_Section(unsigned dest_size, unsigned char *dest, const char *file) { return Get_Elf_Section(dest_size, dest, ".ulp.rev", file); } + +#endif //ENABLE_GDB_INTERFACE