29c9b5a
--- binutils.orig/ld/ldlang.c	2021-09-17 10:38:18.073366643 +0100
29c9b5a
+++ binutils-2.37/ld/ldlang.c	2021-09-17 10:50:50.155450530 +0100
29c9b5a
@@ -6978,7 +6978,8 @@ lang_end (void)
29c9b5a
 	  if (!bfd_set_start_address (link_info.output_bfd, val))
29c9b5a
 	    einfo (_("%F%P: can't set start address\n"));
29c9b5a
 	}
29c9b5a
-      else
29c9b5a
+      /* BZ 2004952: Only use the start of the .text section for executables.  */
29c9b5a
+      else if bfd_link_executable (&link_info)
29c9b5a
 	{
29c9b5a
 	  asection *ts;
29c9b5a
 
29c9b5a
@@ -7004,6 +7005,13 @@ lang_end (void)
29c9b5a
 		       entry_symbol.name);
29c9b5a
 	    }
29c9b5a
 	}
29c9b5a
+      else
29c9b5a
+	{
29c9b5a
+	  if (warn)
29c9b5a
+	    einfo (_("%P: warning: cannot find entry symbol %s;"
29c9b5a
+		     " not setting start address\n"),
29c9b5a
+		   entry_symbol.name);
29c9b5a
+	}
29c9b5a
     }
29c9b5a
 }
29c9b5a
 
29c9b5a
diff -rup binutils.orig/ld/testsuite/ld-arm/tls-gdesc-got.d binutils-2.37/ld/testsuite/ld-arm/tls-gdesc-got.d
29c9b5a
--- binutils.orig/ld/testsuite/ld-arm/tls-gdesc-got.d	2021-09-29 13:17:21.501277341 +0100
29c9b5a
+++ binutils-2.37/ld/testsuite/ld-arm/tls-gdesc-got.d	2021-09-29 13:20:04.481132127 +0100
29c9b5a
@@ -2,7 +2,7 @@
29c9b5a
 .*/tls-lib2-got.so:     file format elf32-.*arm.*
29c9b5a
 architecture: arm.*, flags 0x00000150:
29c9b5a
 HAS_SYMS, DYNAMIC, D_PAGED
29c9b5a
-start address 0x0+8(1e8|220)
29c9b5a
+start address 0x[0-9a-f]+
29c9b5a
 
29c9b5a
 
29c9b5a
 Disassembly of section .got:
29c9b5a
diff -rup binutils.orig/ld/testsuite/ld-i386/tlsnopic.rd binutils-2.37/ld/testsuite/ld-i386/tlsnopic.rd
29c9b5a
--- binutils.orig/ld/testsuite/ld-i386/tlsnopic.rd	2021-09-29 13:17:21.588276729 +0100
29c9b5a
+++ binutils-2.37/ld/testsuite/ld-i386/tlsnopic.rd	2021-09-29 13:20:59.456745814 +0100
29c9b5a
@@ -26,7 +26,7 @@ Key to Flags:
29c9b5a
 #...
29c9b5a
 
29c9b5a
 Elf file type is DYN \(Shared object file\)
29c9b5a
-Entry point 0x1000
29c9b5a
+Entry point 0x[0-9a-f]+
29c9b5a
 There are [0-9]+ program headers, starting at offset [0-9]+
29c9b5a
 
29c9b5a
 Program Headers:
29c9b5a
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr14207.d binutils-2.37/ld/testsuite/ld-x86-64/pr14207.d
29c9b5a
--- binutils.orig/ld/testsuite/ld-x86-64/pr14207.d	2021-09-29 13:17:21.551276989 +0100
29c9b5a
+++ binutils-2.37/ld/testsuite/ld-x86-64/pr14207.d	2021-09-29 13:21:27.632547838 +0100
29c9b5a
@@ -5,7 +5,7 @@
29c9b5a
 #target: x86_64-*-linux*
29c9b5a
 
29c9b5a
 Elf file type is DYN \(Shared object file\)
29c9b5a
-Entry point 0x149
29c9b5a
+Entry point 0x[0-9a-f]+
29c9b5a
 There are 4 program headers, starting at offset 64
29c9b5a
 
29c9b5a
 Program Headers:
29c9b5a
diff -rup binutils.orig/ld/testsuite/ld-x86-64/tlsdesc.rd binutils-2.37/ld/testsuite/ld-x86-64/tlsdesc.rd
29c9b5a
--- binutils.orig/ld/testsuite/ld-x86-64/tlsdesc.rd	2021-09-29 13:17:21.554276968 +0100
29c9b5a
+++ binutils-2.37/ld/testsuite/ld-x86-64/tlsdesc.rd	2021-09-29 13:21:47.920405285 +0100
29c9b5a
@@ -29,7 +29,7 @@ Key to Flags:
29c9b5a
 #...
29c9b5a
 
29c9b5a
 Elf file type is DYN \(Shared object file\)
29c9b5a
-Entry point 0x1000
29c9b5a
+Entry point 0x[0-9a-f]+
29c9b5a
 There are [0-9]+ program headers, starting at offset [0-9]+
29c9b5a
 
29c9b5a
 Program Headers:
29c9b5a
diff -rup binutils.orig/ld/testsuite/ld-x86-64/tlspic.rd binutils-2.37/ld/testsuite/ld-x86-64/tlspic.rd
29c9b5a
--- binutils.orig/ld/testsuite/ld-x86-64/tlspic.rd	2021-09-29 13:17:21.546277025 +0100
29c9b5a
+++ binutils-2.37/ld/testsuite/ld-x86-64/tlspic.rd	2021-09-29 13:22:04.224290720 +0100
29c9b5a
@@ -29,7 +29,7 @@ Key to Flags:
29c9b5a
 #...
29c9b5a
 
29c9b5a
 Elf file type is DYN \(Shared object file\)
29c9b5a
-Entry point 0x1000
29c9b5a
+Entry point 0x[0-9a-f]+
29c9b5a
 There are [0-9]+ program headers, starting at offset [0-9]+
29c9b5a
 
29c9b5a
 Program Headers:
29c9b5a
diff -rup binutils.orig/ld/testsuite/ld-x86-64/tlspic2.rd binutils-2.37/ld/testsuite/ld-x86-64/tlspic2.rd
29c9b5a
--- binutils.orig/ld/testsuite/ld-x86-64/tlspic2.rd	2021-09-29 13:17:21.552276982 +0100
29c9b5a
+++ binutils-2.37/ld/testsuite/ld-x86-64/tlspic2.rd	2021-09-29 13:22:18.432190887 +0100
29c9b5a
@@ -30,7 +30,7 @@ Key to Flags:
29c9b5a
 #...
29c9b5a
 
29c9b5a
 Elf file type is DYN \(Shared object file\)
29c9b5a
-Entry point 0x1000
29c9b5a
+Entry point 0x[0-9a-f]+
29c9b5a
 There are [0-9]+ program headers, starting at offset [0-9]+
29c9b5a
 
29c9b5a
 Program Headers: