From 4a5a8b983fb31a67f976e0dd9cf5e8580ef55098 Mon Sep 17 00:00:00 2001
From: Romain Naour <romain.naour@gmail.com>
Date: Fri, 21 Apr 2017 21:23:55 +0300
Subject: [PATCH] check-ldrunpath-length

[Romain: rebase on top of 2.26]
Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
 ld/emultempl/elf32.em | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index d4837d0..937da8a 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1460,6 +1460,8 @@ fragment <<EOF
 	      && command_line.rpath == NULL)
 	    {
 	      path = (const char *) getenv ("LD_RUN_PATH");
+	      if ((path) && (strlen (path) == 0))
+	        path = NULL;
 	      if (path
 		  && gld${EMULATION_NAME}_search_needed (path, &n, force))
 		break;
@@ -1737,6 +1739,8 @@ gld${EMULATION_NAME}_before_allocation (void)
   rpath = command_line.rpath;
   if (rpath == NULL)
     rpath = (const char *) getenv ("LD_RUN_PATH");
+  if ((rpath) && (strlen (rpath) == 0))
+    rpath = NULL;
 
   for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
     if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
-- 
2.7.4

