Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
autotools: Don't allow undefined symbols in plugins when possible
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
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters