public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/maskray/lld] install: Replace scripts/output-format.sed with objdump -f [BZ #26559]
@ 2021-01-18 21:41 Fangrui Song
  0 siblings, 0 replies; 4+ messages in thread
From: Fangrui Song @ 2021-01-18 21:41 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=87d583c6e8cd0e49f64da76636ebeec033298b4d

commit 87d583c6e8cd0e49f64da76636ebeec033298b4d
Author: Fangrui Song <maskray@google.com>
Date:   Mon Jan 11 11:56:54 2021 -0800

    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  <adhemerval.zanella@linaro.org>

Diff:
---
 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(-)

diff --git a/Makerules b/Makerules
index 0b300613cc..06c7c48310 100644
--- a/Makerules
+++ b/Makerules
@@ -1065,20 +1065,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>/dev/null \
-	| 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 2f4ef195bb..43eb9efb40 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 7ae27564fd..7f47f0caa4 100644
--- a/config.make.in
+++ b/config.make.in
@@ -73,7 +73,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@
 have-textrel_ifunc = @libc_cv_textrel_ifunc@
diff --git a/configure b/configure
index 6a35553805..49f7b32b52 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
@@ -6074,24 +6073,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 43cfac9d48..341d4eeac2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1429,17 +1429,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 <<EOF
 int foo;
diff --git a/scripts/output-format.sed b/scripts/output-format.sed
deleted file mode 100644
index 364f52059f..0000000000
--- a/scripts/output-format.sed
+++ /dev/null
@@ -1,35 +0,0 @@
-/ld.*[ 	]-E[BL]/b f
-/collect.*[ 	]-E[BL]/b f
-/OUTPUT_FORMAT[^)]*$/{N
-s/\n[	 ]*/ /
-}
-t o
-: o
-s/^.*OUTPUT_FORMAT(\([^,]*\), \1, \1).*$/OUTPUT_FORMAT(\1)/
-t q
-s/^.*OUTPUT_FORMAT(\([^,]*\), \([^,]*\), \([^,]*\)).*$/\1,\2,\3/
-t s
-s/^.*OUTPUT_FORMAT(\([^,)]*\).*$)/OUTPUT_FORMAT(\1)/
-t q
-d
-: s
-s/"//g
-G
-s/\n//
-s/^\([^,]*\),\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\2)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\3)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\)/OUTPUT_FORMAT(\1)/p
-/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p
-q
-: q
-s/"//g
-p
-q
-: f
-s/^.*[ 	]-E\([BL]\)[ 	].*$/,\1/
-t h
-s/^.*[ 	]-E\([BL]\)$/,\1/
-t h
-d
-: h
-h


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/maskray/lld] install: Replace scripts/output-format.sed with objdump -f [BZ #26559]
@ 2020-12-28 21:08 Fangrui Song
  0 siblings, 0 replies; 4+ messages in thread
From: Fangrui Song @ 2020-12-28 21:08 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1b80f58e6f25c0f7fb4d2e3406bf4fdcf3431299

commit 1b80f58e6f25c0f7fb4d2e3406bf4fdcf3431299
Author: Fangrui Song <maskray@google.com>
Date:   Mon Dec 28 11:33:45 2020 -0800

    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.

Diff:
---
 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(-)

diff --git a/Makerules b/Makerules
index ef0fe67d9a..146d1ab650 100644
--- a/Makerules
+++ b/Makerules
@@ -1065,20 +1065,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>/dev/null \
-	| 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 2f4ef195bb..43eb9efb40 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 7ae27564fd..7f47f0caa4 100644
--- a/config.make.in
+++ b/config.make.in
@@ -73,7 +73,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@
 have-textrel_ifunc = @libc_cv_textrel_ifunc@
diff --git a/configure b/configure
index f67eb287fc..6bbf648c41 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
@@ -6143,24 +6142,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 59dbf9bda8..d6dbd64a1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1439,17 +1439,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 <<EOF
 int foo;
diff --git a/scripts/output-format.sed b/scripts/output-format.sed
deleted file mode 100644
index 364f52059f..0000000000
--- a/scripts/output-format.sed
+++ /dev/null
@@ -1,35 +0,0 @@
-/ld.*[ 	]-E[BL]/b f
-/collect.*[ 	]-E[BL]/b f
-/OUTPUT_FORMAT[^)]*$/{N
-s/\n[	 ]*/ /
-}
-t o
-: o
-s/^.*OUTPUT_FORMAT(\([^,]*\), \1, \1).*$/OUTPUT_FORMAT(\1)/
-t q
-s/^.*OUTPUT_FORMAT(\([^,]*\), \([^,]*\), \([^,]*\)).*$/\1,\2,\3/
-t s
-s/^.*OUTPUT_FORMAT(\([^,)]*\).*$)/OUTPUT_FORMAT(\1)/
-t q
-d
-: s
-s/"//g
-G
-s/\n//
-s/^\([^,]*\),\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\2)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\3)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\)/OUTPUT_FORMAT(\1)/p
-/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p
-q
-: q
-s/"//g
-p
-q
-: f
-s/^.*[ 	]-E\([BL]\)[ 	].*$/,\1/
-t h
-s/^.*[ 	]-E\([BL]\)$/,\1/
-t h
-d
-: h
-h


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/maskray/lld] install: Replace scripts/output-format.sed with objdump -f [BZ #26559]
@ 2020-12-28 21:06 Fangrui Song
  0 siblings, 0 replies; 4+ messages in thread
From: Fangrui Song @ 2020-12-28 21:06 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=50e9b02e3f92335933e34c228915d5ae9e07e1d0

commit 50e9b02e3f92335933e34c228915d5ae9e07e1d0
Author: Fangrui Song <maskray@google.com>
Date:   Mon Dec 28 11:33:45 2020 -0800

    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.

Diff:
---
 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(-)

diff --git a/Makerules b/Makerules
index ef0fe67d9a..146d1ab650 100644
--- a/Makerules
+++ b/Makerules
@@ -1065,20 +1065,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>/dev/null \
-	| 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 2f4ef195bb..43eb9efb40 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 7ae27564fd..7f47f0caa4 100644
--- a/config.make.in
+++ b/config.make.in
@@ -73,7 +73,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@
 have-textrel_ifunc = @libc_cv_textrel_ifunc@
diff --git a/configure b/configure
index f67eb287fc..6bbf648c41 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
@@ -6143,24 +6142,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 59dbf9bda8..d6dbd64a1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1439,17 +1439,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 <<EOF
 int foo;
diff --git a/scripts/output-format.sed b/scripts/output-format.sed
deleted file mode 100644
index 364f52059f..0000000000
--- a/scripts/output-format.sed
+++ /dev/null
@@ -1,35 +0,0 @@
-/ld.*[ 	]-E[BL]/b f
-/collect.*[ 	]-E[BL]/b f
-/OUTPUT_FORMAT[^)]*$/{N
-s/\n[	 ]*/ /
-}
-t o
-: o
-s/^.*OUTPUT_FORMAT(\([^,]*\), \1, \1).*$/OUTPUT_FORMAT(\1)/
-t q
-s/^.*OUTPUT_FORMAT(\([^,]*\), \([^,]*\), \([^,]*\)).*$/\1,\2,\3/
-t s
-s/^.*OUTPUT_FORMAT(\([^,)]*\).*$)/OUTPUT_FORMAT(\1)/
-t q
-d
-: s
-s/"//g
-G
-s/\n//
-s/^\([^,]*\),\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\2)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\3)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\)/OUTPUT_FORMAT(\1)/p
-/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p
-q
-: q
-s/"//g
-p
-q
-: f
-s/^.*[ 	]-E\([BL]\)[ 	].*$/,\1/
-t h
-s/^.*[ 	]-E\([BL]\)$/,\1/
-t h
-d
-: h
-h


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/maskray/lld] install: Replace scripts/output-format.sed with objdump -f [BZ #26559]
@ 2020-12-28 19:34 Fangrui Song
  0 siblings, 0 replies; 4+ messages in thread
From: Fangrui Song @ 2020-12-28 19:34 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e2cdef6b86008f9c18665b987b3d9b429f650953

commit e2cdef6b86008f9c18665b987b3d9b429f650953
Author: Fangrui Song <maskray@google.com>
Date:   Mon Dec 28 11:33:45 2020 -0800

    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.

Diff:
---
 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(-)

diff --git a/Makerules b/Makerules
index ef0fe67d9a..146d1ab650 100644
--- a/Makerules
+++ b/Makerules
@@ -1065,20 +1065,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>/dev/null \
-	| 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 2f4ef195bb..43eb9efb40 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 7ae27564fd..7f47f0caa4 100644
--- a/config.make.in
+++ b/config.make.in
@@ -73,7 +73,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@
 have-textrel_ifunc = @libc_cv_textrel_ifunc@
diff --git a/configure b/configure
index 6dcd2270f8..4b0ab150cb 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
@@ -6077,24 +6076,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 1a2054cd1a..baf3a05ae7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1432,17 +1432,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 <<EOF
 int foo;
diff --git a/scripts/output-format.sed b/scripts/output-format.sed
deleted file mode 100644
index 364f52059f..0000000000
--- a/scripts/output-format.sed
+++ /dev/null
@@ -1,35 +0,0 @@
-/ld.*[ 	]-E[BL]/b f
-/collect.*[ 	]-E[BL]/b f
-/OUTPUT_FORMAT[^)]*$/{N
-s/\n[	 ]*/ /
-}
-t o
-: o
-s/^.*OUTPUT_FORMAT(\([^,]*\), \1, \1).*$/OUTPUT_FORMAT(\1)/
-t q
-s/^.*OUTPUT_FORMAT(\([^,]*\), \([^,]*\), \([^,]*\)).*$/\1,\2,\3/
-t s
-s/^.*OUTPUT_FORMAT(\([^,)]*\).*$)/OUTPUT_FORMAT(\1)/
-t q
-d
-: s
-s/"//g
-G
-s/\n//
-s/^\([^,]*\),\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\2)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\3)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\)/OUTPUT_FORMAT(\1)/p
-/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p
-q
-: q
-s/"//g
-p
-q
-: f
-s/^.*[ 	]-E\([BL]\)[ 	].*$/,\1/
-t h
-s/^.*[ 	]-E\([BL]\)$/,\1/
-t h
-d
-: h
-h


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-18 21:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 21:41 [glibc/maskray/lld] install: Replace scripts/output-format.sed with objdump -f [BZ #26559] Fangrui Song
  -- strict thread matches above, loose matches on Subject: below --
2020-12-28 21:08 Fangrui Song
2020-12-28 21:06 Fangrui Song
2020-12-28 19:34 Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).