This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add OUTPUT_FORMAT () into libc.so version script


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]