Skip to content

Commit

Permalink
autotools: Don't allow undefined symbols in plugins when possible
Browse files Browse the repository at this point in the history
Tell the linker not to allow undefined symbols in built plugins it
possible.

This avoids use of non-plugin API functions from plugins as using those
would lead to undefined symbols.  This works even as we don't link to a
"libgeany" or the like because Geany plugin API is hidden behind macros
indirection.
  • Loading branch information
b4n committed Oct 13, 2014
1 parent 8873b90 commit 086fe3d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
40 changes: 40 additions & 0 deletions build/ldflags.m4
@@ -0,0 +1,40 @@
dnl GP_CHECK_LDFLAG(FLAG, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl Checks whether the linker understands FLAG
AC_DEFUN([GP_CHECK_LDFLAG],
[
gp_check_ldflag_LDFLAGS="$LDFLAGS"
LDFLAGS="$1"
AC_MSG_CHECKING([whether the linker understands $LDFLAGS])
AC_LANG_PUSH(C)
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
[AC_MSG_RESULT([yes])
$2],
[AC_MSG_RESULT([no])
$3])
AC_LANG_POP(C)
LDFLAGS="$gp_check_ldflag_LDFLAGS"
])

dnl GP_CHECK_LDFLAGS
dnl Checks for default Geany-Plugins LDFLAGS and defines GP_LDFLAGS
AC_DEFUN([GP_CHECK_LDFLAGS],
[
AC_ARG_ENABLE([extra-ld-flags],
AS_HELP_STRING([--disable-extra-ld-flags],
[Disable extra linker flags]),
[enable_extra_ld_flags=$enableval],
[enable_extra_ld_flags=yes])
GP_LDFLAGS=
AS_IF([test "x$enable_extra_ld_flags" != xno],
[
enable_extra_ld_flags=yes
for flag in -Wl,-z,defs # do not allow undefined symbols in object files
do
GP_CHECK_LDFLAG([$flag], [GP_LDFLAGS="${GP_LDFLAGS} $flag"])
done
])
AC_SUBST([GP_LDFLAGS])
GP_STATUS_BUILD_FEATURE_ADD([Extra linker options],
[$enable_extra_c_warnings])
])
2 changes: 1 addition & 1 deletion build/vars.build.mk
Expand Up @@ -9,7 +9,7 @@ AM_CFLAGS = \
$(GEANY_CFLAGS) \
$(GP_CFLAGS)

AM_LDFLAGS = -module -avoid-version
AM_LDFLAGS = -module -avoid-version $(GP_LDFLAGS)

COMMONLIBS = \
$(GEANY_LIBS) \
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -23,6 +23,7 @@ GP_CHECK_UNITTESTS(0.9.4)
GP_CHECK_GTK_VERSION
GP_CHECK_CPPCHECK
GP_CHECK_CFLAGS
GP_CHECK_LDFLAGS

dnl plugin checks
GP_CHECK_ADDONS
Expand Down

0 comments on commit 086fe3d

Please sign in to comment.