]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
build: compile libevent with -fPIC
authorVincent Bernat <vincent@bernat.im>
Wed, 20 May 2015 06:54:05 +0000 (08:54 +0200)
committerVincent Bernat <vincent@bernat.im>
Wed, 20 May 2015 06:54:05 +0000 (08:54 +0200)
When embedded, libevent is configured with `--disable-shared
--enable-static`. This makes libevent compiled without `-fPIC` and we
cannot build a PIE. Use `--with-pic` to force compilation with `-fPIC`.

configure.ac
m4/libevent.m4

index 190a6df6872c7306560f5dd8fbdfc1635e8cfb23..65b5134964523c8f5ce7dc2fffeccc91c6d6439a 100644 (file)
@@ -85,6 +85,23 @@ AX_CFLAGS_GCC_OPTION([-Wno-sign-compare], [LLDP_CFLAGS]) dnl Should be fixed lat
 AX_LDFLAGS_OPTION([-Wl,-z,relro], [LLDP_LDFLAGS])
 AX_LDFLAGS_OPTION([-Wl,-z,now], [LLDP_LDFLAGS])
 
+# Hardening
+AC_ARG_ENABLE([hardening],
+  [AS_HELP_STRING([--enable-hardening],
+    [Enable compiler and linker options to frustrate memory corruption exploits @<:@yes@:>@])],
+  [hardening="$enableval"],
+  [hardening="yes"])
+
+if test x"$hardening" != x"no"; then
+  AX_CFLAGS_GCC_OPTION([-fstack-protector], [LLDP_CFLAGS])
+  AX_CFLAGS_GCC_OPTION([-fstack-protector-all], [LLDP_CFLAGS])
+  AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
+  AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [LLDP_CPPFLAGS])
+  AX_CFLAGS_GCC_OPTION([-fPIE], [LLDP_CFLAGS])
+  AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_LDFLAGS],
+    [AX_LDFLAGS_OPTION([-fPIE -pie], [LLDP_LDFLAGS])])
+fi
+
 # OS
 lldp_CHECK_OS
 lldp_CFLAGS_OS
@@ -277,26 +294,6 @@ lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
 # Oldies
 lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.18], [no])
 
-
-# Hardening
-AC_ARG_ENABLE([hardening],
-  [AS_HELP_STRING([--enable-hardening],
-    [Enable compiler and linker options to frustrate memory corruption exploits @<:@yes@:>@])],
-  [hardening="$enableval"],
-  [hardening="yes"])
-
-if test x"$hardening" != x"no"; then
-  AX_CFLAGS_GCC_OPTION([-fstack-protector], [LLDP_CFLAGS])
-  AX_CFLAGS_GCC_OPTION([-fstack-protector-all], [LLDP_CFLAGS])
-  AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
-  AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [LLDP_CPPFLAGS])
-  if test x"$LIBEVENT_EMBEDDED" = x; then
-    AX_CFLAGS_GCC_OPTION([-fPIE], [LLDP_CFLAGS])
-    AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_LDFLAGS],
-      [AX_LDFLAGS_OPTION([-fPIE -pie], [LLDP_LDFLAGS])])
-  fi
-fi
-
 #######################
 # Output results
 AC_SUBST([LLDP_CFLAGS])
index cdc05c0c9668e813e6eaf0d0a6fe4e616822314c..899b6d388925309c33061fb5c63c6783673447ba 100644 (file)
@@ -48,7 +48,7 @@ AC_DEFUN([lldp_CHECK_LIBEVENT], [
   # Override configure arguments
   ac_configure_args="$ac_configure_args --disable-libevent-regress --disable-thread-support --disable-openssl"
   ac_configure_args="$ac_configure_args --disable-malloc-replacement --disable-debug-mode --enable-function-sections"
-  ac_configure_args="$ac_configure_args --disable-shared --enable-static --enable-silent-rules"
+  ac_configure_args="$ac_configure_args --disable-shared --with-pic --enable-static --enable-silent-rules"
   AC_CONFIG_SUBDIRS([libevent])
   AM_CONDITIONAL([LIBEVENT_EMBEDDED], [test x"$LIBEVENT_EMBEDDED" != x])
   AC_SUBST([LIBEVENT_LIBS])