From 87d583c6e8cd0e49f64da76636ebeec033298b4d 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 --- Makerules | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'Makerules') diff --git a/Makerules b/Makerules index 0b30061..06c7c48 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 -- cgit v1.1