Currently, the libgcc-unwind.map file generated for use with Solaris ld http://gcc.gnu.org/ml/gcc-patches/2014-01/msg01088.html
uses the v1 linker map file syntax because both that's supported everywhere. However, with ld -z guidance, newer versions of ld warn about this: ld: guidance: version 2 mapfile syntax recommended: ./libgcc-unwind.map Since it is easy to detect if ld supports v2 map syntax (introduced in Solaris 11 and later backported to some Solaris 10 patches) and the mapfile is generated at build time, the following patch performs this check and generates a v2 mapfile if ld supports it. While testing the patch, I found that the arg to AC_TRY_COMMAND needed quoting to avoid the embedded commas in -Wl,-M,... ended the command. Shouldn't the other uses of AC_TRY_COMMAND receive the same quoting for safety and consistency? Bootstrapped on i386-pc-solaris2.10 (with older v1-only ld) and i386-pc-solaris2.11 without regressions. Ok for mainline? Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University 2018-09-14 Rainer Orth <r...@cebitec.uni-bielefeld.de> * configure.ac (solaris_ld_v2_maps): New test. * configure: Regenerate. * Makefile.in (solaris_ld_v2_maps): New variable. * config/t-slibgcc-sld (libgcc-unwind.map): Emit v2 mapfile syntax if supported.
# HG changeset patch # Parent 6e22c7ec2252ccb001d91cccbacc5378de003e7c Use v2 map syntax in libgcc-unwind.map if Solaris ld supports it diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -44,6 +44,7 @@ enable_vtable_verify = @enable_vtable_ve enable_decimal_float = @enable_decimal_float@ fixed_point = @fixed_point@ with_aix_soname = @with_aix_soname@ +solaris_ld_v2_maps = @solaris_ld_v2_maps@ enable_execute_stack = @enable_execute_stack@ unwind_header = @unwind_header@ md_unwind_header = @md_unwind_header@ diff --git a/libgcc/config/t-slibgcc-sld b/libgcc/config/t-slibgcc-sld --- a/libgcc/config/t-slibgcc-sld +++ b/libgcc/config/t-slibgcc-sld @@ -8,12 +8,23 @@ ifeq ($(enable_shared),yes) # Linker mapfile to enforce direct binding to libgcc_s unwinder # (PR target/59788). +# Emit v2 mapfile syntax if possible, otherwise ld -z guidance complains +# every time the mapfile is used. libgcc-unwind.map: libgcc-std.ver +ifeq ($(solaris_ld_v2_maps),yes) + @(echo '$$mapfile_version 2'; \ + echo "SYMBOL_SCOPE {"; \ + for f in `grep _Unwind_ $< | sort`; do \ + echo " $$f { FLAGS = EXTERN DIRECT };"; \ + done; \ + echo "};" ) > $@ +else @(echo "{"; \ for f in `grep _Unwind_ $< | sort`; do \ echo " $$f = EXTERN DIRECT;"; \ done; \ echo "};" ) > $@ +endif # Copy libgcc-unwind.map to the place where gcc will look for it at build-time. install-libgcc-unwind-map-forbuild: libgcc-unwind.map diff --git a/libgcc/configure.ac b/libgcc/configure.ac --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -459,6 +459,21 @@ EOF ;; esac +# Check if Solaris linker support v2 linker mapfile syntax. +# Link with -nostartfiles -nodefaultlibs since neither are present while +# building libgcc. +case ${host} in +*-*-solaris2*) + solaris_ld_v2_maps=no + echo 'int main(void) {return 0;}' > conftest.c + echo '$mapfile_version 2' > conftest.map + if AC_TRY_COMMAND([${CC-cc} -nostartfiles -nodefaultlibs -Wl,-M,conftest.map -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]); then + solaris_ld_v2_maps=yes + fi + ;; +esac +AC_SUBST(solaris_ld_v2_maps) + # Check if xtensa target is configured for windowed ABI and thus needs to use # custom unwind code. # This is after config.host so we can augment tmake_file.