about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile35
-rw-r--r--elf/ldd.bash.in15
-rw-r--r--elf/ldd.sh.in8
3 files changed, 44 insertions, 14 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 5e221ec352..33f60c52f1 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -164,23 +164,34 @@ $(inst_slibdir)/$(rtld-installed-name): \
 .PHONY: ldso_install
 ldso_install: $(inst_slibdir)/$(rtld-installed-name)
 
+
+sh-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
+		 -e 's%@VERSION@%$(version)%g'
+bash-ldd-rewrite = $(sh-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
+		   -e 's%@TEXTDOMAINDIR@%$(localedir)%g'
+
 ifneq ($(have-bash2),yes)
-$(objpfx)ldd: ldd.sh.in $(common-objpfx)version.mk \
-	      $(common-objpfx)soversions.mk $(common-objpfx)config.make
-	sed -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
-	    -e 's%@VERSION@%$(version)%g' < $< > $@.new
-	chmod 555 $@.new
-	mv -f $@.new $@
+ldd-shell = bash
+else
+ldd-shell = sh
+endif
+
+ifeq ($(ldd-rewrite-script),no)
+define gen-ldd
+sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
+endef
 else
-$(objpfx)ldd: ldd.bash.in $(common-objpfx)version.mk \
+define gen-ldd
+sed $($(ldd-shell)-ldd-rewrite) < $< | sed -f $(ldd-rewrite-script) > $@.new
+endef
+endif
+
+$(objpfx)ldd: ldd.$(ldd-shell).in $(common-objpfx)version.mk \
 	      $(common-objpfx)soversions.mk $(common-objpfx)config.make
-	sed -e 's%@BASH@%$(BASH)%g' \
-	    -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
-	    -e 's%@VERSION@%$(version)%g' \
-	    -e 's%@TEXTDOMAINDIR@%$(localedir)%g' < $< > $@.new
+	$(gen-ldd)
 	chmod 555 $@.new
 	mv -f $@.new $@
-endif
+
 
 ifeq ($(build-shared),yes)
 $(objpfx)sprof: $(objpfx)libdl.so$(libdl.so-version)
diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
index 54dc837d3e..5d4bb3cccc 100644
--- a/elf/ldd.bash.in
+++ b/elf/ldd.bash.in
@@ -87,6 +87,12 @@ Report bugs using the \`glibcbug' script to <bugs@gnu.org>."
   esac
 done
 
+nonelf ()
+{
+  # Maybe extra code for non-ELF binaries.
+  return 1;
+}
+
 add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
 add_env="$add_env LD_VERBOSE=$verbose"
 case $# in
@@ -115,6 +121,8 @@ case $# in
       eval $add_env exec '"$file"' || exit 1
       ;;
     1)
+      # This can be a non-ELF binary or no binary at all.
+      nonelf $file ||
       echo $"	not a dynamic executable"
       exit 1
       ;;
@@ -154,8 +162,11 @@ warning: you do not have execution permission for" "\`$file'"
 	eval $add_env '"$file"' || result=1
 	;;
       1)
-	echo $"	not a dynamic executable"
-	result=1
+	# This can be a non-ELF binary or no binary at all.
+	nonelf $file || {
+	  echo $"	not a dynamic executable"
+	  result=1
+	}
 	;;
       2)
         eval $add_env ${RTLD} '"$file"' || result=1
diff --git a/elf/ldd.sh.in b/elf/ldd.sh.in
index 884472f654..a82deb5cb7 100644
--- a/elf/ldd.sh.in
+++ b/elf/ldd.sh.in
@@ -83,6 +83,12 @@ Try \`ldd --help' for more information."
   esac
 done
 
+nonelf ()
+{
+  # Maybe extra code for non-ELF binaries.
+  return 1;
+}
+
 add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
 add_env="$add_env LD_VERBOSE=$verbose"
 case $# in
@@ -113,6 +119,7 @@ Try \`ldd --help' for more information."
 	eval $add_env exec '"$file"' || exit 1
 	;;
       1)
+        nonelf $file ||
 	echo '	not a dynamic executable'
 	exit 1
 	;;
@@ -155,6 +162,7 @@ ldd: warning: you do not have execution permission for \`$file'"
 	  eval $add_env '"$file"' || result=1
 	  ;;
 	1)
+          nonelf $file ||
 	  echo '	not a dynamic executable'
 	  result=1
 	  ;;