Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- configure.ac | 41 -------------------------------- m4/virt-linker-no-indirect.m4 | 32 ------------------------- m4/virt-linker-no-undefined.m4 | 32 ------------------------- m4/virt-linker-relro.m4 | 35 --------------------------- meson.build | 43 ++++++++++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 140 deletions(-) delete mode 100644 m4/virt-linker-no-indirect.m4 delete mode 100644 m4/virt-linker-no-undefined.m4 delete mode 100644 m4/virt-linker-relro.m4 diff --git a/configure.ac b/configure.ac index 56a471fc3ab..cb1aed73828 100644 --- a/configure.ac +++ b/configure.ac @@ -64,43 +64,6 @@ m4_ifndef([LT_INIT], [ AM_PROG_CC_C_O AM_PROG_LD -AC_MSG_CHECKING([for how to mark DSO non-deletable at runtime]) -LIBVIRT_NODELETE= -`$LD --help 2>&1 | grep -- "-z nodelete" >/dev/null` && \ - LIBVIRT_NODELETE="-Wl,-z -Wl,nodelete" -AC_MSG_RESULT([$LIBVIRT_NODELETE]) -AC_SUBST([LIBVIRT_NODELETE]) - -AC_MSG_CHECKING([for how to set DSO symbol versions]) -case "$host" in - *-*-mingw* | *-*-msvc* ) - # mingw's ld has the --version-script parameter, but it requires a .def file - # instead to work properly, therefore clear --version-script here and use - # -Wl, to pass the .def file to the linker - VERSION_SCRIPT_FLAGS="-Wl," - ;; - * ) - VERSION_SCRIPT_FLAGS=-Wl,--version-script= - `$LD --help 2>&1 | grep -- --version-script >/dev/null` || \ - VERSION_SCRIPT_FLAGS="-Wl,-M -Wl," - ;; -esac -AC_MSG_RESULT([$VERSION_SCRIPT_FLAGS]) -AC_SUBST([VERSION_SCRIPT_FLAGS]) - -dnl macOS has two-level namespaces by default. -dnl Override it to allow symbol replacement with DYLD_INSERT_LIBRARIES -case "$host" in - *-*-darwin*) - FLAT_NAMESPACE_FLAGS=-Wl,-flat_namespace - ;; - * ) - FLAT_NAMESPACE_FLAGS="" - ;; -esac -AC_MSG_RESULT([$FLAT_NAMESPACE_FLAGS]) -AC_SUBST([FLAT_NAMESPACE_FLAGS]) - dnl Specify if we rely on ifconfig instead of iproute2 (e.g. in case dnl we're working on BSD) want_ifconfig=no @@ -161,10 +124,6 @@ fi # Check for compiler and library settings. -LIBVIRT_LINKER_RELRO -LIBVIRT_LINKER_NO_INDIRECT -LIBVIRT_LINKER_NO_UNDEFINED - LIBVIRT_ARG_APPARMOR LIBVIRT_ARG_ATTR LIBVIRT_ARG_AUDIT diff --git a/m4/virt-linker-no-indirect.m4 b/m4/virt-linker-no-indirect.m4 deleted file mode 100644 index b344f708539..00000000000 --- a/m4/virt-linker-no-indirect.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl -dnl Check for --no-copy-dt-needed-entries -dnl -dnl Copyright (C) 2013 Guido Günther <agx@xxxxxxxxxxx> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl <http://www.gnu.org/licenses/>. -dnl - -AC_DEFUN([LIBVIRT_LINKER_NO_INDIRECT],[ - AC_MSG_CHECKING([for how to avoid indirect lib deps]) - - NO_INDIRECT_LDFLAGS= - case `$LD --help 2>&1` in - *"--no-copy-dt-needed-entries"*) - NO_INDIRECT_LDFLAGS="-Wl,--no-copy-dt-needed-entries" ;; - esac - AC_SUBST([NO_INDIRECT_LDFLAGS]) - - AC_MSG_RESULT([$NO_INDIRECT_LDFLAGS]) -]) diff --git a/m4/virt-linker-no-undefined.m4 b/m4/virt-linker-no-undefined.m4 deleted file mode 100644 index 532b0de212c..00000000000 --- a/m4/virt-linker-no-undefined.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl -dnl Check for -z defs linker flag -dnl -dnl Copyright (C) 2013-2018 Red Hat, Inc. -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl <http://www.gnu.org/licenses/>. -dnl - -AC_DEFUN([LIBVIRT_LINKER_NO_UNDEFINED],[ - AC_MSG_CHECKING([for how to stop undefined symbols at link time]) - - NO_UNDEFINED_LDFLAGS= - ld_help=`$LD --help 2>&1` - case $ld_help in - *"-z defs"*) NO_UNDEFINED_LDFLAGS="-Wl,-z -Wl,defs" ;; - esac - AC_SUBST([NO_UNDEFINED_LDFLAGS]) - - AC_MSG_RESULT([$NO_UNDEFINED_LDFLAGS]) -]) diff --git a/m4/virt-linker-relro.m4 b/m4/virt-linker-relro.m4 deleted file mode 100644 index 079a095feed..00000000000 --- a/m4/virt-linker-relro.m4 +++ /dev/null @@ -1,35 +0,0 @@ -dnl -dnl Check for -z now and -z relro linker flags -dnl -dnl Copyright (C) 2013 Red Hat, Inc. -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl <http://www.gnu.org/licenses/>. -dnl - -AC_DEFUN([LIBVIRT_LINKER_RELRO],[ - AC_MSG_CHECKING([for how to force completely read-only GOT table]) - - RELRO_LDFLAGS= - ld_help=`$LD --help 2>&1` - case $ld_help in - *"-z relro"*) RELRO_LDFLAGS="-Wl,-z -Wl,relro" ;; - esac - case $ld_help in - *"-z now"*) RELRO_LDFLAGS="$RELRO_LDFLAGS -Wl,-z -Wl,now" ;; - esac - AC_SUBST([RELRO_LDFLAGS]) - - AC_MSG_RESULT([$RELRO_LDFLAGS]) -]) diff --git a/meson.build b/meson.build index 2450a8bdd79..d1237c10875 100644 --- a/meson.build +++ b/meson.build @@ -574,6 +574,49 @@ cc_flags_relaxed_frame_limit = [ ] +# various linker checks + +libvirt_relro = cc.get_supported_link_arguments([ + '-Wl,-z,relro', + '-Wl,-z,now', +]) + +libvirt_nodelete = cc.get_supported_link_arguments([ + '-Wl,-z,nodelete', +]) + +libvirt_no_undefined = cc.get_supported_link_arguments([ + '-Wl,-z,defs', +]) + +libvirt_no_indirect = cc.get_supported_link_arguments([ + '-Wl,--no-copy-dt-needed-entries', +]) + +if host_machine.system() == 'windows' + version_script_flags = '-Wl,' +else + test_file = '@0@/src/libvirt_qemu.syms'.format(meson.source_root()) + if cc.has_link_argument('-Wl,--version-script=@0@'.format(test_file)) + version_script_flags = '-Wl,--version-script=' + elif cc.has_link_argument('-Wl,-M,') + version_script_flags = '-Wl,-M,' + else + error('No supported version script link argument found.') + endif +endif + +libvirt_flat_namespace = [] +if host_machine.system() == 'darwin' + libvirt_flat_namespace = '-Wl,-flat_namespace' +endif + +libvirt_export_dynamic = cc.first_supported_link_argument([ + '-Wl,-export-dynamic', + '-Wl,-export_dynamic', +]) + + # define top include directory top_inc_dir = include_directories('.') -- 2.26.2