diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 944a5db07c7..89dd269b8cc 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -32,6 +32,9 @@ stdenv.mkDerivation rec { # This is needed, for instance, so that running "ldd" on a binary that is # PaX-marked to disable mprotect doesn't fail with permission denied. ./pt-pax-flags.patch + + # Bug fix backported from binutils master. + ./fix-bsymbolic.patch ]; outputs = [ "out" "info" ]; diff --git a/pkgs/development/tools/misc/binutils/fix-bsymbolic.patch b/pkgs/development/tools/misc/binutils/fix-bsymbolic.patch new file mode 100644 index 00000000000..afaafc997ef --- /dev/null +++ b/pkgs/development/tools/misc/binutils/fix-bsymbolic.patch @@ -0,0 +1,47 @@ +http://lists.gnu.org/archive/html/bug-binutils/2016-01/msg00193.html +https://sourceware.org/bugzilla/show_bug.cgi?id=19615 + +From 1dab972d797c060e17229c2e10da01852ba82629 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Thu, 11 Feb 2016 15:31:15 -0800 +Subject: [PATCH] Enable -Bsymbolic and -Bsymbolic-functions to PIE + +Before binutils 2.26, -Bsymbolic and -Bsymbolic-functions were also +applied to PIE so that "ld -pie -Bsymbolic -E" can be used to export +symbols in PIE with local binding. This patch re-enables -Bsymbolic +and -Bsymbolic-functions for PIE. + +diff --git a/ld/lexsup.c b/ld/lexsup.c +index 4cad209..e2fb212 100644 +--- a/ld/lexsup.c ++++ b/ld/lexsup.c +@@ -1586,15 +1586,14 @@ parse_args (unsigned argc, char **argv) + /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data, + --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and + --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are +- for shared libraries. -Bsymbolic overrides all others and vice +- versa. */ ++ for PIC outputs. -Bsymbolic overrides all others and vice versa. */ + switch (command_line.symbolic) + { + case symbolic_unset: + break; + case symbolic: +- /* -Bsymbolic is for shared library only. */ +- if (bfd_link_dll (&link_info)) ++ /* -Bsymbolic is for PIC output only. */ ++ if (bfd_link_pic (&link_info)) + { + link_info.symbolic = TRUE; + /* Should we free the unused memory? */ +@@ -1603,8 +1602,8 @@ parse_args (unsigned argc, char **argv) + } + break; + case symbolic_functions: +- /* -Bsymbolic-functions is for shared library only. */ +- if (bfd_link_dll (&link_info)) ++ /* -Bsymbolic-functions is for PIC output only. */ ++ if (bfd_link_pic (&link_info)) + command_line.dynamic_list = dynamic_list_data; + break; + }