public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add OUTPUT_FORMAT () into libc.so version script
@ 2002-12-06  7:00 Jakub Jelinek
  2002-12-06 12:41 ` Roland McGrath
  2002-12-07 14:05 ` Roland McGrath
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2002-12-06  7:00 UTC (permalink / raw)
  To: Roland McGrath, Ulrich Drepper; +Cc: Glibc hackers

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  <jakub@redhat.com>

	* 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

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

end of thread, other threads:[~2002-12-07 22:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-06  7:00 [PATCH] Add OUTPUT_FORMAT () into libc.so version script Jakub Jelinek
2002-12-06 12:41 ` Roland McGrath
2002-12-07 14:05 ` Roland McGrath

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