public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Roland McGrath <roland@redhat.com>, Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Add OUTPUT_FORMAT () into libc.so version script
Date: Fri, 06 Dec 2002 07:00:00 -0000	[thread overview]
Message-ID: <20021206160035.F1310@sunsite.ms.mff.cuni.cz> (raw)

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

             reply	other threads:[~2002-12-06 15:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-06  7:00 Jakub Jelinek [this message]
2002-12-06 12:41 ` Roland McGrath
2002-12-07 14:05 ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021206160035.F1310@sunsite.ms.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    --cc=roland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).