From e59cdcdfc53882951dc0621d580694cfffe71ca3 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 17 Sep 2021 12:23:04 +0100 Subject: [PATCH] Default to an entry address of 0 for shared libraries. Resolves: #2004952 --- ...ils-ld-default-entry-of-0-for-shared.patch | 26 +++++++++++++++++++ binutils.spec | 10 ++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 binutils-ld-default-entry-of-0-for-shared.patch diff --git a/binutils-ld-default-entry-of-0-for-shared.patch b/binutils-ld-default-entry-of-0-for-shared.patch new file mode 100644 index 0000000..ffa9e7c --- /dev/null +++ b/binutils-ld-default-entry-of-0-for-shared.patch @@ -0,0 +1,26 @@ +--- binutils.orig/ld/ldlang.c 2021-09-17 10:38:18.073366643 +0100 ++++ binutils-2.37/ld/ldlang.c 2021-09-17 10:50:50.155450530 +0100 +@@ -6978,7 +6978,8 @@ lang_end (void) + if (!bfd_set_start_address (link_info.output_bfd, val)) + einfo (_("%F%P: can't set start address\n")); + } +- else ++ /* BZ 2004952: Only use the start of the .text section for executables. */ ++ else if bfd_link_executable (&link_info) + { + asection *ts; + +@@ -7004,6 +7005,13 @@ lang_end (void) + entry_symbol.name); + } + } ++ else ++ { ++ if (warn) ++ einfo (_("%P: warning: cannot find entry symbol %s;" ++ " not setting start address\n"), ++ entry_symbol.name); ++ } + } + } + diff --git a/binutils.spec b/binutils.spec index c082da4..3b6bb94 100644 --- a/binutils.spec +++ b/binutils.spec @@ -39,7 +39,7 @@ Summary: A GNU collection of binary utilities Name: binutils%{?name_cross}%{?_with_debug:-debug} Version: 2.37 -Release: 12%{?dist} +Release: 13%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -296,6 +296,11 @@ Patch20: binutils-bfd-close-fds.patch # Lifetime: Fixed in 2.38 (maybe ?) Patch21: binutils-autoconf-version.patch +# Purpose: Set the entry address of shared libraries to 0, so that they can +# be detected by the loader and not run as an executable. +# Lifetime: Permanent. +Patch22: binutils-ld-default-entry-of-0-for-shared.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -905,6 +910,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Fri Sep 17 2021 Nick Clifton - 2.27-13 +- Default to an entry address of 0 for shared libraries. (#2004952) + * Mon Sep 13 2021 Tom Stellard - 2.37-12 - Disable LTO on arm. (#1918924)