Default to an entry address of 0 for shared libraries.

Resolves: #2004952
This commit is contained in:
Nick Clifton 2021-09-17 12:23:04 +01:00
parent 73c2d21c11
commit e59cdcdfc5
2 changed files with 35 additions and 1 deletions

View File

@ -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);
+ }
}
}

View File

@ -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 <nickc@redhat.com> - 2.27-13
- Default to an entry address of 0 for shared libraries. (#2004952)
* Mon Sep 13 2021 Tom Stellard <tstellar@redhat.com> - 2.37-12
- Disable LTO on arm. (#1918924)