diff mbox series

[libgcc] Use v2 map syntax in libgcc-unwind.map if Solaris ld supports it

Message ID ydd36u9k7fg.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series [libgcc] Use v2 map syntax in libgcc-unwind.map if Solaris ld supports it | expand

Commit Message

Rainer Orth Sept. 16, 2018, 11:28 a.m. UTC
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

Comments

Jeff Law Sept. 17, 2018, 10:52 p.m. UTC | #1
On 9/16/18 5:28 AM, Rainer Orth wrote:
> 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?
OK with a suitable ChangeLog.


Jeff
Rainer Orth Sept. 18, 2018, 7:09 a.m. UTC | #2
Hi Jeff,

> On 9/16/18 5:28 AM, Rainer Orth wrote:
>> 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?
> OK with a suitable ChangeLog.

thanks, installed.  However, the ChangeLog entry already was in the
original patch submission.

	Rainer
diff mbox series

Patch

# 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.