2007-07-24 Richard Hughes <richard@hughsie.com>
authorRichard Hughes <richard@hughsie.com>
Tue, 24 Jul 2007 12:31:01 +0000 (12:31 +0000)
committerRichard Hughes <richard@hughsie.com>
Tue, 24 Jul 2007 12:31:01 +0000 (12:31 +0000)
* configure.in:
Check for -Wl,--gc-sections so we can really reduce the size of the
setuid binary.

ChangeLog
configure.in

index 006d334..05369c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2007-07-24  Richard Hughes  <richard@hughsie.com>
 
+       * configure.in:
+       Check for -Wl,--gc-sections so we can really reduce the size of the
+       setuid binary.
+
+2007-07-24  Richard Hughes  <richard@hughsie.com>
+
        * bus/activation.c: (handle_activation_exit_error),
        (babysitter_watch_callback):
        Map the child exit status integer to a proper dbus error.
index 877bc0a..cf0d8ec 100644 (file)
@@ -243,6 +243,32 @@ else
   fi
 fi
 
+# Check for -Wl,--gc-sections
+AC_MSG_CHECKING([for ld that supports "-Wl,--gc-sections"])
+AC_TRY_LINK([
+  int one(void) { return 1; }
+  int two(void) { return 2; }
+  ], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no])
+
+if test "$ac_gcsections" = "yes"; then
+  rm -f conftest.c
+  touch conftest.c
+  if $CC -c conftest.c; then
+    if $LD --gc-sections -o conftest conftest.o 2>&1 | \
+      grep "Warning: gc-sections option ignored" > /dev/null; then
+      ac_gcsections=no
+    fi
+  fi
+  rm -f conftest.c conftest.o conftest
+fi
+if test "$ac_gcsections" = "yes"; then
+  SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
+  CFLAGS="-ffunction-sections -fdata-sections $CFLAGS"
+fi
+AC_SUBST(SECTION_FLAGS)
+AC_SUBST(SECTION_LDFLAGS)
+AC_MSG_RESULT($ac_gcsections)
+
 # Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris
 #
 case $target_os in