From 903a6c6d5a68b80d99fbf587475f0f56f6b09dc5 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 11 Jan 2021 11:56:54 -0800 Subject: install: Replace scripts/output-format.sed with objdump -f [BZ #26559] GNU ld and gold have supported --print-output-format since 2011. glibc requires binutils>=2.25 (2015), so if LD is GNU ld or gold, we can assume the option is supported. lld is by default a cross linker supporting multiple targets. It auto detects the file format and does not need OUTPUT_FORMAT. It does not support --print-output-format. By parsing objdump -f, we can support all the three linkers. Reviewed-by: Adhemerval Zanella (cherry picked from commit 87d583c6e8cd0e49f64da76636ebeec033298b4d) --- Makerules | 13 +++------- benchtests/strcoll-inputs/filelist#en_US.UTF-8 | 1 - config.make.in | 1 - configure | 19 -------------- configure.ac | 11 -------- scripts/output-format.sed | 35 -------------------------- 6 files changed, 3 insertions(+), 77 deletions(-) delete mode 100644 scripts/output-format.sed diff --git a/Makerules b/Makerules index 1bffdcc..98611ca 100644 --- a/Makerules +++ b/Makerules @@ -1133,20 +1133,13 @@ install: $(inst_slibdir)/libc.so$(libc.so-version) # for the configuration we are building. We put this statement into # the linker scripts we install for -lc et al so that they will not be # used by a link for a different format on a multi-architecture system. -$(common-objpfx)format.lds: $(..)scripts/output-format.sed \ - $(common-objpfx)config.make \ +$(common-objpfx)format.lds: $(common-objpfx)config.make \ $(common-objpfx)config.h $(..)Makerules -ifneq (unknown,$(output-format)) - echo > $@.new 'OUTPUT_FORMAT($(output-format))' -else $(LINK.o) -shared $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \ $(LDFLAGS.so) $(LDFLAGS-lib.so) \ - -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \ - | sed -n -f $< > $@.new - test -s $@.new + -x c /dev/null -o $@.so 2>/dev/null + $(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@ rm -f $@.so -endif - mv -f $@.new $@ common-generated += format.lds ifndef subdir diff --git a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 b/benchtests/strcoll-inputs/filelist#en_US.UTF-8 index aa44107..cb981de 100644 --- a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 +++ b/benchtests/strcoll-inputs/filelist#en_US.UTF-8 @@ -9450,7 +9450,6 @@ move-if-change check-execstack.awk pylint pylintrc -output-format.sed merge-test-results.sh update-copyrights config-uname.sh diff --git a/config.make.in b/config.make.in index 58f56c3..d967eaa 100644 --- a/config.make.in +++ b/config.make.in @@ -72,7 +72,6 @@ fno-unit-at-a-time = @fno_unit_at_a_time@ bind-now = @bindnow@ have-hash-style = @libc_cv_hashstyle@ use-default-link = @use_default_link@ -output-format = @libc_cv_output_format@ have-cxx-thread_local = @libc_cv_cxx_thread_local@ have-loop-to-function = @libc_cv_cc_loop_to_function@ diff --git a/configure b/configure index 9fd2eaa..f723098 100755 --- a/configure +++ b/configure @@ -623,7 +623,6 @@ libc_cv_cc_submachine libc_cv_cc_nofma libc_cv_mtls_dialect_gnu2 fno_unit_at_a_time -libc_cv_output_format libc_cv_has_glob_dat libc_cv_hashstyle libc_cv_fpie @@ -6144,24 +6143,6 @@ fi $as_echo "$libc_cv_has_glob_dat" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5 -$as_echo_n "checking linker output format... " >&6; } -if ${libc_cv_output_format+:} false; then : - $as_echo_n "(cached) " >&6 -else - if libc_cv_output_format=` -${CC-cc} -nostartfiles -nostdlib $no_ssp -Wl,--print-output-format 2>&5` -then - : -else - libc_cv_output_format= -fi -test -n "$libc_cv_output_format" || libc_cv_output_format=unknown -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_output_format" >&5 -$as_echo "$libc_cv_output_format" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-toplevel-reorder -fno-section-anchors" >&5 $as_echo_n "checking for -fno-toplevel-reorder -fno-section-anchors... " >&6; } if ${libc_cv_fno_toplevel_reorder+:} false; then : diff --git a/configure.ac b/configure.ac index cad59fa..b3505fc 100644 --- a/configure.ac +++ b/configure.ac @@ -1465,17 +1465,6 @@ fi rm -f conftest*]) AC_SUBST(libc_cv_has_glob_dat) -AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl -if libc_cv_output_format=` -${CC-cc} -nostartfiles -nostdlib $no_ssp -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD` -then - : -else - libc_cv_output_format= -fi -test -n "$libc_cv_output_format" || libc_cv_output_format=unknown]) -AC_SUBST(libc_cv_output_format) - AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl cat > conftest.c <