Merge remote-tracking branch 'origin/binutils-2.26' into staging

This still breaks a few packages, but nothing really major:

  http://hydra.nixos.org/eval/1241850?filter=x86_64-linux&compare=1237919&full=#tabs-now-fail
This commit is contained in:
Eelco Dolstra 2016-03-11 11:58:49 +01:00
commit 2af1cb3aa6
14 changed files with 527 additions and 1839 deletions

View file

@ -146,11 +146,26 @@ if [ "$NIX_DONT_SET_RPATH" != 1 ]; then
# Finally, add `-rpath' switches.
for i in $rpath; do
extra=(${extra[@]} -rpath $i)
extra+=(-rpath $i)
done
fi
# Only add --build-id if this is a final link. FIXME: should build gcc
# with --enable-linker-build-id instead?
if [ "$NIX_SET_BUILD_ID" = 1 ]; then
for p in "${params[@]}"; do
if [ "$p" = "-r" -o "$p" = "--relocatable" -o "$p" = "-i" ]; then
relocatable=1
break
fi
done
if [ -z "$relocatable" ]; then
extra+=(--build-id)
fi
fi
# Optionally print debug info.
if [ -n "$NIX_DEBUG" ]; then
echo "original flags to @prog@:" >&2

View file

@ -22,20 +22,20 @@ envHooks+=(addCVars)
# Note: these come *after* $out in the PATH (see setup.sh).
if [ -n "@cc@" ]; then
addToSearchPath PATH @cc@/bin
if [ -n "@binutils@" ]; then
addToSearchPath _PATH @binutils@/bin
fi
if [ -n "@binutils@" ]; then
addToSearchPath PATH @binutils@/bin
if [ -n "@cc@" ]; then
addToSearchPath _PATH @cc@/bin
fi
if [ -n "@libc@" ]; then
addToSearchPath PATH @libc@/bin
addToSearchPath _PATH @libc@/bin
fi
if [ -n "@coreutils@" ]; then
addToSearchPath PATH @coreutils@/bin
addToSearchPath _PATH @coreutils@/bin
fi
if [ -z "$crossConfig" ]; then

View file

@ -1,5 +1,6 @@
export NIX_LDFLAGS+=" --build-id"
export NIX_CFLAGS_COMPILE+=" -ggdb"
export NIX_SET_BUILD_ID=1
export NIX_LDFLAGS+=" --compress-debug-sections=zlib"
export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections"
dontStrip=1
fixupOutputHooks+=(_separateDebugInfo)
@ -25,18 +26,10 @@ _separateDebugInfo() {
# Extract the debug info.
header "separating debug info from $i (build ID $id)"
mkdir -p "$dst/${id:0:2}"
objcopy --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug" --compress-debug-sections
objcopy --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug"
strip --strip-debug "$i"
# Also a create a symlink <original-name>.debug.
ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
done < <(find "$prefix" -type f -print0)
}
# - We might prefer to compress the debug info during link-time already,
# but our ld doesn't support --compress-debug-sections=zlib (yet).
# - Debug info may cause problems due to excessive memory usage during linking.
# Using -Wa,--compress-debug-sections should help with that;
# further interesting information: https://gcc.gnu.org/wiki/DebugFission
# - Another related tool: https://fedoraproject.org/wiki/Features/DwarfCompressor

View file

@ -87,6 +87,7 @@ stdenv.mkDerivation rec {
patches = [
./remove-tools-1.4.patch
./new-binutils.patch
];
GOOS = if stdenv.isDarwin then "darwin" else "linux";

View file

@ -0,0 +1,194 @@
https://github.com/golang/go/issues/13114
https://gnats.netbsd.org/50777
--- a/src/cmd/6l/asm.c 2015-09-23 06:20:05.000000000 +0200
+++ b/src/cmd/6l/asm.c 2016-03-10 21:00:29.032083210 +0100
@@ -118,6 +118,8 @@
return;
case 256 + R_X86_64_GOTPCREL:
+ case 256 + R_X86_64_GOTPCRELX:
+ case 256 + R_X86_64_REX_GOTPCRELX:
if(targ->type != SDYNIMPORT) {
// have symbol
if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
--- a/src/cmd/8l/asm.c 2015-09-23 06:20:05.000000000 +0200
+++ b/src/cmd/8l/asm.c 2016-03-10 21:02:16.702064080 +0100
@@ -115,6 +115,7 @@
return;
case 256 + R_386_GOT32:
+ case 256 + R_386_GOT32X:
if(targ->type != SDYNIMPORT) {
// have symbol
if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
--- a/src/cmd/ld/elf.h 2015-09-23 06:20:05.000000000 +0200
+++ b/src/cmd/ld/elf.h 2016-03-10 21:00:29.033083211 +0100
@@ -478,32 +478,47 @@
* Relocation types.
*/
-#define R_X86_64_NONE 0 /* No relocation. */
-#define R_X86_64_64 1 /* Add 64 bit symbol value. */
-#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */
-#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */
-#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */
-#define R_X86_64_COPY 5 /* Copy data from shared object. */
-#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */
-#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */
-#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */
-#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */
-#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */
-#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */
-#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */
-#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */
-#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */
-#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */
-#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
-#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */
-#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */
-#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */
-#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */
-#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
-#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */
-#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */
-
-#define R_X86_64_COUNT 24 /* Count of defined relocation types. */
+#define R_X86_64_NONE 0
+#define R_X86_64_64 1
+#define R_X86_64_PC32 2
+#define R_X86_64_GOT32 3
+#define R_X86_64_PLT32 4
+#define R_X86_64_COPY 5
+#define R_X86_64_GLOB_DAT 6
+#define R_X86_64_JMP_SLOT 7
+#define R_X86_64_RELATIVE 8
+#define R_X86_64_GOTPCREL 9
+#define R_X86_64_32 10
+#define R_X86_64_32S 11
+#define R_X86_64_16 12
+#define R_X86_64_PC16 13
+#define R_X86_64_8 14
+#define R_X86_64_PC8 15
+#define R_X86_64_DTPMOD64 16
+#define R_X86_64_DTPOFF64 17
+#define R_X86_64_TPOFF64 18
+#define R_X86_64_TLSGD 19
+#define R_X86_64_TLSLD 20
+#define R_X86_64_DTPOFF32 21
+#define R_X86_64_GOTTPOFF 22
+#define R_X86_64_TPOFF32 23
+#define R_X86_64_PC64 24
+#define R_X86_64_GOTOFF64 25
+#define R_X86_64_GOTPC32 26
+#define R_X86_64_GOT64 27
+#define R_X86_64_GOTPCREL64 28
+#define R_X86_64_GOTPC64 29
+#define R_X86_64_GOTPLT64 30
+#define R_X86_64_PLTOFF64 31
+#define R_X86_64_SIZE32 32
+#define R_X86_64_SIZE64 33
+#define R_X86_64_GOTPC32_TLSDEC 34
+#define R_X86_64_TLSDESC_CALL 35
+#define R_X86_64_TLSDESC 36
+#define R_X86_64_IRELATIVE 37
+#define R_X86_64_PC32_BND 40
+#define R_X86_64_GOTPCRELX 41
+#define R_X86_64_REX_GOTPCRELX 42
#define R_ALPHA_NONE 0 /* No reloc */
@@ -581,39 +596,42 @@
#define R_ARM_COUNT 38 /* Count of defined relocation types. */
-#define R_386_NONE 0 /* No relocation. */
-#define R_386_32 1 /* Add symbol value. */
-#define R_386_PC32 2 /* Add PC-relative symbol value. */
-#define R_386_GOT32 3 /* Add PC-relative GOT offset. */
-#define R_386_PLT32 4 /* Add PC-relative PLT offset. */
-#define R_386_COPY 5 /* Copy data from shared object. */
-#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */
-#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */
-#define R_386_RELATIVE 8 /* Add load address of shared object. */
-#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */
-#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */
-#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */
-#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */
-#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */
-#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */
-#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */
-#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */
-#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */
-#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */
-#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */
-#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */
-#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */
-#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */
-#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */
-#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */
-#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */
-#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */
-#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */
-#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */
-#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */
-#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */
-
-#define R_386_COUNT 38 /* Count of defined relocation types. */
+#define R_386_NONE 0
+#define R_386_32 1
+#define R_386_PC32 2
+#define R_386_GOT32 3
+#define R_386_PLT32 4
+#define R_386_COPY 5
+#define R_386_GLOB_DAT 6
+#define R_386_JMP_SLOT 7
+#define R_386_RELATIVE 8
+#define R_386_GOTOFF 9
+#define R_386_GOTPC 10
+#define R_386_TLS_TPOFF 14
+#define R_386_TLS_IE 15
+#define R_386_TLS_GOTIE 16
+#define R_386_TLS_LE 17
+#define R_386_TLS_GD 18
+#define R_386_TLS_LDM 19
+#define R_386_TLS_GD_32 24
+#define R_386_TLS_GD_PUSH 25
+#define R_386_TLS_GD_CALL 26
+#define R_386_TLS_GD_POP 27
+#define R_386_TLS_LDM_32 28
+#define R_386_TLS_LDM_PUSH 29
+#define R_386_TLS_LDM_CALL 30
+#define R_386_TLS_LDM_POP 31
+#define R_386_TLS_LDO_32 32
+#define R_386_TLS_IE_32 33
+#define R_386_TLS_LE_32 34
+#define R_386_TLS_DTPMOD32 35
+#define R_386_TLS_DTPOFF32 36
+#define R_386_TLS_TPOFF32 37
+#define R_386_TLS_GOTDESC 39
+#define R_386_TLS_DESC_CALL 40
+#define R_386_TLS_DESC 41
+#define R_386_IRELATIVE 42
+#define R_386_GOT32X 43
#define R_PPC_NONE 0 /* No relocation. */
#define R_PPC_ADDR32 1
--- a/src/cmd/ld/ldelf.c 2015-09-23 06:20:05.000000000 +0200
+++ b/src/cmd/ld/ldelf.c 2016-03-10 21:00:29.033083211 +0100
@@ -888,12 +888,15 @@
case R('6', R_X86_64_PC32):
case R('6', R_X86_64_PLT32):
case R('6', R_X86_64_GOTPCREL):
+ case R('6', R_X86_64_GOTPCRELX):
+ case R('6', R_X86_64_REX_GOTPCRELX):
case R('8', R_386_32):
case R('8', R_386_PC32):
case R('8', R_386_GOT32):
case R('8', R_386_PLT32):
case R('8', R_386_GOTOFF):
case R('8', R_386_GOTPC):
+ case R('8', R_386_GOT32X):
*siz = 4;
break;
case R('6', R_X86_64_64):

View file

@ -37,6 +37,10 @@ postInstall() {
# Get rid of more unnecessary stuff.
rm -rf $out/var $out/sbin/sln
for i in $out/lib/*.a; do
strip -S "$i"
done
}
genericBuild

View file

@ -2,7 +2,6 @@
, installLocales ? true
, profilingLibraries ? false
, gccCross ? null
, debugSymbols ? false
, withGd ? false, gd ? null, libpng ? null
}:
@ -13,9 +12,7 @@ let
cross = if gccCross != null then gccCross.target else null;
in
build cross ({
name = "glibc"
+ lib.optionalString debugSymbols "-debug"
+ lib.optionalString withGd "-gd";
name = "glibc" + lib.optionalString withGd "-gd";
inherit lib stdenv fetchurl linuxHeaders installLocales
profilingLibraries gccCross withGd gd libpng;
@ -38,23 +35,13 @@ in
fi
'';
separateDebugInfo = true;
meta.description = "The GNU C Library";
}
//
(if debugSymbols
then {
# Build with debugging symbols, but leave optimizations on and don't
# attempt to keep the build tree.
dontStrip = true;
dontCrossStrip = true;
NIX_STRIP_DEBUG = 0;
}
else {})
//
(if cross != null
then {
preConfigure = ''

View file

@ -30,6 +30,9 @@ stdenv.mkDerivation rec {
[ "--with-threads" ]
++ stdenv.lib.optional withBdb "--with-bdb=${db}";
# Fix broken DT_NEEDED in lib/redland/librdf_storage_sqlite.so.
NIX_CFLAGS_LINK = "-lraptor2";
meta = {
homepage = http://librdf.org/;
};

View file

@ -2,7 +2,7 @@
, cross ? null, gold ? true, bison ? null
}:
let basename = "binutils-2.23.1"; in
let basename = "binutils-2.26"; in
with { inherit (stdenv.lib) optional optionals optionalString; };
@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
src = fetchurl {
url = "mirror://gnu/binutils/${basename}.tar.bz2";
sha256 = "06bs5v5ndb4g5qx96d52lc818gkbskd1m0sz57314v887sqfbcia";
sha256 = "1ngc2h3knhiw8s22l8y6afycfaxr5grviqy7mwvm4bsl14cf9b62";
};
patches = [
@ -31,10 +31,15 @@ stdenv.mkDerivation rec {
# Always add PaX flags section to ELF files.
# 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-20121023.patch
./pt-pax-flags.patch
# Bug fix backported from binutils master.
./fix-bsymbolic.patch
];
nativeBuildInputs = optional gold bison;
outputs = [ "out" "info" ];
nativeBuildInputs = [ bison ];
buildInputs = [ zlib ];
inherit noSysDirs;

View file

@ -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" <hjl.tools@gmail.com>
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;
}

View file

@ -0,0 +1,233 @@
--- binutils-2.15.94.0.2.2.orig/bfd/elf-bfd.h 2005-02-07 20:42:44.000000000 +0100
+++ binutils-2.15.94.0.2.2/bfd/elf-bfd.h 2005-02-20 13:13:17.362558200 +0100
@@ -1266,6 +1266,9 @@
/* Should the PT_GNU_RELRO segment be emitted? */
bfd_boolean relro;
+ /* Segment flags for the PT_PAX_FLAGS segment. */
+ unsigned int pax_flags;
+
/* Symbol version definitions in external objects. */
Elf_Internal_Verdef *verdef;
--- binutils-2.17.50.0.18/bfd/elf.c.orig 2007-08-01 11:12:02.000000000 -0400
+++ binutils-2.17.50.0.18/bfd/elf.c 2007-08-01 14:27:36.086986774 -0400
@@ -1085,6 +1085,7 @@
case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
case PT_GNU_STACK: pt = "STACK"; break;
case PT_GNU_RELRO: pt = "RELRO"; break;
+ case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break;
default: pt = NULL; break;
}
return pt;
@@ -2346,6 +2347,9 @@
case PT_GNU_RELRO:
return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "relro");
+ case PT_PAX_FLAGS:
+ return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "pax_flags");
+
default:
/* Check for any processor-specific program segment types. */
bed = get_elf_backend_data (abfd);
@@ -3326,6 +3330,11 @@
++segs;
}
+ {
+ /* We need a PT_PAX_FLAGS segment. */
+ ++segs;
+ }
+
for (s = abfd->sections; s != NULL; s = s->next)
{
if ((s->flags & SEC_LOAD) != 0
@@ -3945,6 +3954,20 @@
pm = &m->next;
}
+ {
+ amt = sizeof (struct elf_segment_map);
+ m = bfd_zalloc (abfd, amt);
+ if (m == NULL)
+ goto error_return;
+ m->next = NULL;
+ m->p_type = PT_PAX_FLAGS;
+ m->p_flags = elf_tdata (abfd)->pax_flags;
+ m->p_flags_valid = 1;
+
+ *pm = m;
+ pm = &m->next;
+ }
+
free (sections);
elf_tdata (abfd)->segment_map = mfirst;
}
@@ -5129,7 +5152,8 @@
5. PT_GNU_STACK segments do not include any sections.
6. PT_TLS segment includes only SHF_TLS sections.
7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments.
- 8. PT_DYNAMIC should not contain empty sections at the beginning
+ 8. PT_PAX_FLAGS segments do not include any sections.
+ 9. PT_DYNAMIC should not contain empty sections at the beginning
(with the possible exception of .dynamic). */
#define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed) \
((((segment->p_paddr \
@@ -5138,6 +5162,7 @@
&& (section->flags & SEC_ALLOC) != 0) \
|| IS_COREFILE_NOTE (segment, section)) \
&& segment->p_type != PT_GNU_STACK \
+ && segment->p_type != PT_PAX_FLAGS \
&& (segment->p_type != PT_TLS \
|| (section->flags & SEC_THREAD_LOCAL)) \
&& (segment->p_type == PT_LOAD \
--- binutils-2.23.52.0.1/bfd/elflink.c.orig 2013-02-27 21:28:03.000000000 +0100
+++ binutils-2.23.52.0.1/bfd/elflink.c 2013-03-01 17:32:44.922717879 +0100
@@ -5764,18 +5764,32 @@
&& ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
return FALSE;
+ elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC;
+
+ if (info->execheap)
+ elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT;
+ else if (info->noexecheap)
+ elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT;
+
/* Determine any GNU_STACK segment requirements, after the backend
has had a chance to set a default segment size. */
if (info->execstack)
+ {
elf_stack_flags (output_bfd) = PF_R | PF_W | PF_X;
+ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
+ }
else if (info->noexecstack)
+ {
elf_stack_flags (output_bfd) = PF_R | PF_W;
+ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
+ }
else
{
bfd *inputobj;
asection *notesec = NULL;
int exec = 0;
+ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
for (inputobj = info->input_bfds;
inputobj;
inputobj = inputobj->link_next)
@@ -5789,7 +5803,11 @@
if (s)
{
if (s->flags & SEC_CODE)
- exec = PF_X;
+ {
+ elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP;
+ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
+ exec = PF_X;
+ }
notesec = s;
}
else if (bed->default_execstack)
--- binutils-2.15.94.0.2.2.orig/binutils/readelf.c 2005-02-18 07:14:30.000000000 +0100
+++ binutils-2.15.94.0.2.2/binutils/readelf.c 2005-02-20 13:13:17.470541784 +0100
@@ -2293,6 +2293,7 @@
return "GNU_EH_FRAME";
case PT_GNU_STACK: return "GNU_STACK";
case PT_GNU_RELRO: return "GNU_RELRO";
+ case PT_PAX_FLAGS: return "PAX_FLAGS";
default:
if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
--- binutils-2.15.94.0.2.2.orig/include/bfdlink.h 2004-11-22 21:33:32.000000000 +0100
+++ binutils-2.15.94.0.2.2/include/bfdlink.h 2005-02-20 13:13:17.476540872 +0100
@@ -313,6 +313,14 @@
flags. */
unsigned int noexecstack: 1;
+ /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT
+ flags. */
+ unsigned int execheap: 1;
+
+ /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT
+ flags. */
+ unsigned int noexecheap: 1;
+
/* TRUE if PT_GNU_RELRO segment should be created. */
unsigned int relro: 1;
--- binutils-2.15.94.0.2.2.orig/include/elf/common.h 2004-11-22 21:33:32.000000000 +0100
+++ binutils-2.15.94.0.2.2/include/elf/common.h 2005-02-20 13:13:17.482539960 +0100
@@ -423,6 +423,7 @@
#define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */
#define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */
#define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */
+#define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */
/* Program segment permissions, in program header p_flags field. */
@@ -433,6 +434,19 @@
#define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */
#define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */
+#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */
+#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */
+#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */
+#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */
+#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */
+#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */
+#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */
+#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */
+#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */
+#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */
+#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */
+#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */
+
/* Values for section header, sh_type field. */
#define SHT_NULL 0 /* Section header table entry unused */
--- binutils-2.18.50.0.1/ld/emultempl/elf32.em.orig 2007-09-08 19:34:12.000000000 +0200
+++ binutils-2.18.50.0.1/ld/emultempl/elf32.em 2007-09-15 21:41:35.688212063 +0200
@@ -2139,6 +2139,16 @@
link_info.noexecstack = TRUE;
link_info.execstack = FALSE;
}
+ else if (strcmp (optarg, "execheap") == 0)
+ {
+ link_info.execheap = TRUE;
+ link_info.noexecheap = FALSE;
+ }
+ else if (strcmp (optarg, "noexecheap") == 0)
+ {
+ link_info.noexecheap = TRUE;
+ link_info.execheap = FALSE;
+ }
EOF
if test -n "$COMMONPAGESIZE"; then
--- binutils-2.15.94.0.2.2.orig/ld/ldgram.y 2004-11-22 21:33:32.000000000 +0100
+++ binutils-2.15.94.0.2.2/ld/ldgram.y 2005-02-20 13:13:17.499537376 +0100
@@ -1073,6 +1073,8 @@
$$ = exp_intop (0x6474e550);
else if (strcmp (s, "PT_GNU_STACK") == 0)
$$ = exp_intop (0x6474e551);
+ else if (strcmp (s, "PT_PAX_FLAGS") == 0)
+ $$ = exp_intop (0x65041580);
else
{
einfo (_("\
--- binutils-2.26/ld/lexsup.c.orig 2015-11-13 09:27:42.000000000 +0100
+++ binutils-2.26/ld/lexsup.c 2016-01-26 21:08:41.787138458 +0100
@@ -1793,8 +1793,12 @@
fprintf (file, _("\
-z muldefs Allow multiple definitions\n"));
fprintf (file, _("\
+ -z execheap Mark executable as requiring executable heap\n"));
+ fprintf (file, _("\
-z execstack Mark executable as requiring executable stack\n"));
fprintf (file, _("\
+ -z noexecheap Mark executable as not requiring executable heap\n"));
+ fprintf (file, _("\
-z noexecstack Mark executable as not requiring executable stack\n"));
}

View file

@ -214,7 +214,6 @@ PATH=
for i in $initialPath; do
if [ "$i" = / ]; then i=; fi
addToSearchPath PATH $i/bin
addToSearchPath PATH $i/sbin
done
if [ "$NIX_DEBUG" = 1 ]; then
@ -262,6 +261,10 @@ findInputs() {
source "$pkg"
fi
if [ -d $1/bin ]; then
addToSearchPath _PATH $1/bin
fi
if [ -f "$pkg/nix-support/setup-hook" ]; then
source "$pkg/nix-support/setup-hook"
fi
@ -289,10 +292,6 @@ done
_addToNativeEnv() {
local pkg=$1
if [ -d $1/bin ]; then
addToSearchPath _PATH $1/bin
fi
# Run the package-specific hooks set by the setup-hook scripts.
runHook envHook "$pkg"
}
@ -304,13 +303,6 @@ done
_addToCrossEnv() {
local pkg=$1
# Some programs put important build scripts (freetype-config and similar)
# into their crossDrv bin path. Intentionally these should go after
# the nativePkgs in PATH.
if [ -d $1/bin ]; then
addToSearchPath _PATH $1/bin
fi
# Run the package-specific hooks set by the setup-hook scripts.
runHook crossEnvHook "$pkg"
}

View file

@ -187,7 +187,7 @@ rec {
name = "bootstrap-gcc-wrapper";
overrides = pkgs: {
inherit (stage1.pkgs) perl binutils paxctl;
inherit (stage1.pkgs) perl binutils paxctl gnum4 bison;
# This also contains the full, dynamically linked, final Glibc.
};
};
@ -204,7 +204,7 @@ rec {
name = "bootstrap-gcc-wrapper";
overrides = pkgs: rec {
inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders;
inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders gnum4 bison;
# Link GCC statically against GMP etc. This makes sense because
# these builds of the libraries are only used by GCC, so it
# reduces the size of the stdenv closure.
@ -238,7 +238,7 @@ rec {
# because gcc (since JAR support) already depends on zlib, and
# then if we already have a zlib we want to use that for the
# other purposes (binutils and top-level pkgs) too.
inherit (stage3.pkgs) gettext gnum4 gmp perl glibc zlib linuxHeaders;
inherit (stage3.pkgs) gettext gnum4 bison gmp perl glibc zlib linuxHeaders;
gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
nativeTools = false;