From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15989 invoked by alias); 6 Dec 2002 15:00:50 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 15909 invoked from network); 6 Dec 2002 15:00:39 -0000 Received: from unknown (HELO sunsite.mff.cuni.cz) (195.113.19.66) by sources.redhat.com with SMTP; 6 Dec 2002 15:00:39 -0000 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.11.6/8.11.6) id gB6F0ZF07815; Fri, 6 Dec 2002 16:00:35 +0100 Date: Fri, 06 Dec 2002 07:00:00 -0000 From: Jakub Jelinek To: Roland McGrath , Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Add OUTPUT_FORMAT () into libc.so version script Message-ID: <20021206160035.F1310@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-SW-Source: 2002-12/txt/msg00004.txt.bz2 Hi! The following patch adds OUTPUT_FORMAT statement to linker scripts, so that recent linkers can skip it if it is for another ABI glibc. It is a make macro, so that it can be used for linker scripts other than libc.so (e.g. in nptl/Makefile one can just add $(print_output_format);\ before echo 'GROUP... ). It tries to deal with the fact that OUTPUT_FORMAT in the built-in linker script can either have one argument or 3, in which it matters if linker is called with -EB, -EL or none of the above options. 2002-12-06 Jakub Jelinek * Makerules (print_output_format): Define. ($(inst_libdir)/libc.so): Use it. --- libc/Makerules.jj 2002-11-15 23:47:41.000000000 +0100 +++ libc/Makerules 2002-11-15 23:47:41.000000000 +0100 @@ -883,6 +883,33 @@ $(inst_slibdir)/libc-$(version).so: $(co $(do-install-program) install: $(inst_slibdir)/libc.so$(libc.so-version) +ifeq ($(elf),yes) +define print_output_format + output_format=$$(echo `$(LINK.o) -shared $(sysdep-LDFLAGS) \ + $(config-LDFLAGS) $(LDFLAGS.so) \ + -xc /dev/null -o $@.new.tmp -Wl,--verbose \ + 2>&1 | grep -A1 OUTPUT_FORMAT` \ + | sed -e 's/^.*OUTPUT_FORMAT[ ]*([ ]*//' \ + -e 's/).*$$//;s/,[ ]*/ /g;s/"//g;');\ + rm -f $@.new.tmp;\ + if [ -n "$$output_format" ]; then \ + case `$(LINK.o) -shared $(sysdep-LDFLAGS) $(config-LDFLAGS) \ + $(LDFLAGS.so) -xc /dev/null -o $@.new.tmp -v 2>&1 \ + | sed -n 's/^.*\(ld\|collect\).*[ ]-\(E[BL]\)\([ ].*\|\)$$/\2/p'` in\ + EB) output_format=`echo "$$output_format" \ + | $(AWK) '{ if (NF == 3) print $$2; else print $$1 }'`;;\ + EL) output_format=`echo "$$output_format" \ + | $(AWK) '{ if (NF == 3) print $$3; else print $$1 }'`;;\ + *) output_format=`echo "$$output_format" | sed 's/ .*$$//'`;;\ + esac; \ + rm -f $@.new.tmp;\ + echo "OUTPUT_FORMAT ( \"$$output_format\" )";\ + fi +endef +else +print_output_format=: +endif + ifndef subdir # What we install as libc.so for programs to link against is in fact a # link script. It contains references for the various libraries we need. @@ -898,6 +925,7 @@ $(inst_libdir)/libc.so: $(common-objpfx) (echo '/* GNU ld script';\ echo ' Use the shared library, but some functions are only in';\ echo ' the static library, so try that secondarily. */';\ + $(print_output_format);\ echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \ '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\ ')' \ Jakub