···146146147147 # Finally, add `-rpath' switches.
148148 for i in $rpath; do
149149- extra=(${extra[@]} -rpath $i)
149149+ extra+=(-rpath $i)
150150+ done
151151+fi
152152+153153+154154+# Only add --build-id if this is a final link. FIXME: should build gcc
155155+# with --enable-linker-build-id instead?
156156+if [ "$NIX_SET_BUILD_ID" = 1 ]; then
157157+ for p in "${params[@]}"; do
158158+ if [ "$p" = "-r" -o "$p" = "--relocatable" -o "$p" = "-i" ]; then
159159+ relocatable=1
160160+ break
161161+ fi
150162 done
163163+ if [ -z "$relocatable" ]; then
164164+ extra+=(--build-id)
165165+ fi
151166fi
152167153168
+6-6
pkgs/build-support/cc-wrapper/setup-hook.sh
···22222323# Note: these come *after* $out in the PATH (see setup.sh).
24242525-if [ -n "@cc@" ]; then
2626- addToSearchPath PATH @cc@/bin
2525+if [ -n "@binutils@" ]; then
2626+ addToSearchPath _PATH @binutils@/bin
2727fi
28282929-if [ -n "@binutils@" ]; then
3030- addToSearchPath PATH @binutils@/bin
2929+if [ -n "@cc@" ]; then
3030+ addToSearchPath _PATH @cc@/bin
3131fi
32323333if [ -n "@libc@" ]; then
3434- addToSearchPath PATH @libc@/bin
3434+ addToSearchPath _PATH @libc@/bin
3535fi
36363737if [ -n "@coreutils@" ]; then
3838- addToSearchPath PATH @coreutils@/bin
3838+ addToSearchPath _PATH @coreutils@/bin
3939fi
40404141if [ -z "$crossConfig" ]; then
···11-export NIX_LDFLAGS+=" --build-id"
22-export NIX_CFLAGS_COMPILE+=" -ggdb"
11+export NIX_SET_BUILD_ID=1
22+export NIX_LDFLAGS+=" --compress-debug-sections=zlib"
33+export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections"
34dontStrip=1
4556fixupOutputHooks+=(_separateDebugInfo)
···2526 # Extract the debug info.
2627 header "separating debug info from $i (build ID $id)"
2728 mkdir -p "$dst/${id:0:2}"
2828- objcopy --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug" --compress-debug-sections
2929+ objcopy --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug"
2930 strip --strip-debug "$i"
30313132 # Also a create a symlink <original-name>.debug.
3233 ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
3334 done < <(find "$prefix" -type f -print0)
3435}
3535-3636-# - We might prefer to compress the debug info during link-time already,
3737-# but our ld doesn't support --compress-debug-sections=zlib (yet).
3838-# - Debug info may cause problems due to excessive memory usage during linking.
3939-# Using -Wa,--compress-debug-sections should help with that;
4040-# further interesting information: https://gcc.gnu.org/wiki/DebugFission
4141-# - Another related tool: https://fedoraproject.org/wiki/Features/DwarfCompressor
4242-
+1
pkgs/development/compilers/go/1.4.nix
···87878888 patches = [
8989 ./remove-tools-1.4.patch
9090+ ./new-binutils.patch
9091 ];
91929293 GOOS = if stdenv.isDarwin then "darwin" else "linux";
+194
pkgs/development/compilers/go/new-binutils.patch
···11+https://github.com/golang/go/issues/13114
22+https://gnats.netbsd.org/50777
33+44+--- a/src/cmd/6l/asm.c 2015-09-23 06:20:05.000000000 +0200
55++++ b/src/cmd/6l/asm.c 2016-03-10 21:00:29.032083210 +0100
66+@@ -118,6 +118,8 @@
77+ return;
88+99+ case 256 + R_X86_64_GOTPCREL:
1010++ case 256 + R_X86_64_GOTPCRELX:
1111++ case 256 + R_X86_64_REX_GOTPCRELX:
1212+ if(targ->type != SDYNIMPORT) {
1313+ // have symbol
1414+ if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
1515+--- a/src/cmd/8l/asm.c 2015-09-23 06:20:05.000000000 +0200
1616++++ b/src/cmd/8l/asm.c 2016-03-10 21:02:16.702064080 +0100
1717+@@ -115,6 +115,7 @@
1818+ return;
1919+2020+ case 256 + R_386_GOT32:
2121++ case 256 + R_386_GOT32X:
2222+ if(targ->type != SDYNIMPORT) {
2323+ // have symbol
2424+ if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
2525+--- a/src/cmd/ld/elf.h 2015-09-23 06:20:05.000000000 +0200
2626++++ b/src/cmd/ld/elf.h 2016-03-10 21:00:29.033083211 +0100
2727+@@ -478,32 +478,47 @@
2828+ * Relocation types.
2929+ */
3030+3131+-#define R_X86_64_NONE 0 /* No relocation. */
3232+-#define R_X86_64_64 1 /* Add 64 bit symbol value. */
3333+-#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */
3434+-#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */
3535+-#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */
3636+-#define R_X86_64_COPY 5 /* Copy data from shared object. */
3737+-#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */
3838+-#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */
3939+-#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */
4040+-#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */
4141+-#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */
4242+-#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */
4343+-#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */
4444+-#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */
4545+-#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */
4646+-#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */
4747+-#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
4848+-#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */
4949+-#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */
5050+-#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */
5151+-#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */
5252+-#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
5353+-#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */
5454+-#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */
5555+-
5656+-#define R_X86_64_COUNT 24 /* Count of defined relocation types. */
5757++#define R_X86_64_NONE 0
5858++#define R_X86_64_64 1
5959++#define R_X86_64_PC32 2
6060++#define R_X86_64_GOT32 3
6161++#define R_X86_64_PLT32 4
6262++#define R_X86_64_COPY 5
6363++#define R_X86_64_GLOB_DAT 6
6464++#define R_X86_64_JMP_SLOT 7
6565++#define R_X86_64_RELATIVE 8
6666++#define R_X86_64_GOTPCREL 9
6767++#define R_X86_64_32 10
6868++#define R_X86_64_32S 11
6969++#define R_X86_64_16 12
7070++#define R_X86_64_PC16 13
7171++#define R_X86_64_8 14
7272++#define R_X86_64_PC8 15
7373++#define R_X86_64_DTPMOD64 16
7474++#define R_X86_64_DTPOFF64 17
7575++#define R_X86_64_TPOFF64 18
7676++#define R_X86_64_TLSGD 19
7777++#define R_X86_64_TLSLD 20
7878++#define R_X86_64_DTPOFF32 21
7979++#define R_X86_64_GOTTPOFF 22
8080++#define R_X86_64_TPOFF32 23
8181++#define R_X86_64_PC64 24
8282++#define R_X86_64_GOTOFF64 25
8383++#define R_X86_64_GOTPC32 26
8484++#define R_X86_64_GOT64 27
8585++#define R_X86_64_GOTPCREL64 28
8686++#define R_X86_64_GOTPC64 29
8787++#define R_X86_64_GOTPLT64 30
8888++#define R_X86_64_PLTOFF64 31
8989++#define R_X86_64_SIZE32 32
9090++#define R_X86_64_SIZE64 33
9191++#define R_X86_64_GOTPC32_TLSDEC 34
9292++#define R_X86_64_TLSDESC_CALL 35
9393++#define R_X86_64_TLSDESC 36
9494++#define R_X86_64_IRELATIVE 37
9595++#define R_X86_64_PC32_BND 40
9696++#define R_X86_64_GOTPCRELX 41
9797++#define R_X86_64_REX_GOTPCRELX 42
9898+9999+100100+ #define R_ALPHA_NONE 0 /* No reloc */
101101+@@ -581,39 +596,42 @@
102102+ #define R_ARM_COUNT 38 /* Count of defined relocation types. */
103103+104104+105105+-#define R_386_NONE 0 /* No relocation. */
106106+-#define R_386_32 1 /* Add symbol value. */
107107+-#define R_386_PC32 2 /* Add PC-relative symbol value. */
108108+-#define R_386_GOT32 3 /* Add PC-relative GOT offset. */
109109+-#define R_386_PLT32 4 /* Add PC-relative PLT offset. */
110110+-#define R_386_COPY 5 /* Copy data from shared object. */
111111+-#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */
112112+-#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */
113113+-#define R_386_RELATIVE 8 /* Add load address of shared object. */
114114+-#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */
115115+-#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */
116116+-#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */
117117+-#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */
118118+-#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */
119119+-#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */
120120+-#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */
121121+-#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */
122122+-#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */
123123+-#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */
124124+-#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */
125125+-#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */
126126+-#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */
127127+-#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */
128128+-#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */
129129+-#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */
130130+-#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */
131131+-#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */
132132+-#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */
133133+-#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */
134134+-#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */
135135+-#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */
136136+-
137137+-#define R_386_COUNT 38 /* Count of defined relocation types. */
138138++#define R_386_NONE 0
139139++#define R_386_32 1
140140++#define R_386_PC32 2
141141++#define R_386_GOT32 3
142142++#define R_386_PLT32 4
143143++#define R_386_COPY 5
144144++#define R_386_GLOB_DAT 6
145145++#define R_386_JMP_SLOT 7
146146++#define R_386_RELATIVE 8
147147++#define R_386_GOTOFF 9
148148++#define R_386_GOTPC 10
149149++#define R_386_TLS_TPOFF 14
150150++#define R_386_TLS_IE 15
151151++#define R_386_TLS_GOTIE 16
152152++#define R_386_TLS_LE 17
153153++#define R_386_TLS_GD 18
154154++#define R_386_TLS_LDM 19
155155++#define R_386_TLS_GD_32 24
156156++#define R_386_TLS_GD_PUSH 25
157157++#define R_386_TLS_GD_CALL 26
158158++#define R_386_TLS_GD_POP 27
159159++#define R_386_TLS_LDM_32 28
160160++#define R_386_TLS_LDM_PUSH 29
161161++#define R_386_TLS_LDM_CALL 30
162162++#define R_386_TLS_LDM_POP 31
163163++#define R_386_TLS_LDO_32 32
164164++#define R_386_TLS_IE_32 33
165165++#define R_386_TLS_LE_32 34
166166++#define R_386_TLS_DTPMOD32 35
167167++#define R_386_TLS_DTPOFF32 36
168168++#define R_386_TLS_TPOFF32 37
169169++#define R_386_TLS_GOTDESC 39
170170++#define R_386_TLS_DESC_CALL 40
171171++#define R_386_TLS_DESC 41
172172++#define R_386_IRELATIVE 42
173173++#define R_386_GOT32X 43
174174+175175+ #define R_PPC_NONE 0 /* No relocation. */
176176+ #define R_PPC_ADDR32 1
177177+--- a/src/cmd/ld/ldelf.c 2015-09-23 06:20:05.000000000 +0200
178178++++ b/src/cmd/ld/ldelf.c 2016-03-10 21:00:29.033083211 +0100
179179+@@ -888,12 +888,15 @@
180180+ case R('6', R_X86_64_PC32):
181181+ case R('6', R_X86_64_PLT32):
182182+ case R('6', R_X86_64_GOTPCREL):
183183++ case R('6', R_X86_64_GOTPCRELX):
184184++ case R('6', R_X86_64_REX_GOTPCRELX):
185185+ case R('8', R_386_32):
186186+ case R('8', R_386_PC32):
187187+ case R('8', R_386_GOT32):
188188+ case R('8', R_386_PLT32):
189189+ case R('8', R_386_GOTOFF):
190190+ case R('8', R_386_GOTPC):
191191++ case R('8', R_386_GOT32X):
192192+ *siz = 4;
193193+ break;
194194+ case R('6', R_X86_64_64):
+4
pkgs/development/libraries/glibc/builder.sh
···37373838 # Get rid of more unnecessary stuff.
3939 rm -rf $out/var $out/sbin/sln
4040+4141+ for i in $out/lib/*.a; do
4242+ strip -S "$i"
4343+ done
4044}
41454246genericBuild
+3-16
pkgs/development/libraries/glibc/default.nix
···22, installLocales ? true
33, profilingLibraries ? false
44, gccCross ? null
55-, debugSymbols ? false
65, withGd ? false, gd ? null, libpng ? null
76}:
87···1312 cross = if gccCross != null then gccCross.target else null;
1413in
1514 build cross ({
1616- name = "glibc"
1717- + lib.optionalString debugSymbols "-debug"
1818- + lib.optionalString withGd "-gd";
1515+ name = "glibc" + lib.optionalString withGd "-gd";
19162017 inherit lib stdenv fetchurl linuxHeaders installLocales
2118 profilingLibraries gccCross withGd gd libpng;
···3835 fi
3936 '';
40373838+ separateDebugInfo = true;
3939+4140 meta.description = "The GNU C Library";
4241 }
4343-4444- //
4545-4646- (if debugSymbols
4747- then {
4848- # Build with debugging symbols, but leave optimizations on and don't
4949- # attempt to keep the build tree.
5050- dontStrip = true;
5151- dontCrossStrip = true;
5252- NIX_STRIP_DEBUG = 0;
5353- }
5454- else {})
55425643 //
5744
···11+http://lists.gnu.org/archive/html/bug-binutils/2016-01/msg00193.html
22+https://sourceware.org/bugzilla/show_bug.cgi?id=19615
33+44+From 1dab972d797c060e17229c2e10da01852ba82629 Mon Sep 17 00:00:00 2001
55+From: "H.J. Lu" <hjl.tools@gmail.com>
66+Date: Thu, 11 Feb 2016 15:31:15 -0800
77+Subject: [PATCH] Enable -Bsymbolic and -Bsymbolic-functions to PIE
88+99+Before binutils 2.26, -Bsymbolic and -Bsymbolic-functions were also
1010+applied to PIE so that "ld -pie -Bsymbolic -E" can be used to export
1111+symbols in PIE with local binding. This patch re-enables -Bsymbolic
1212+and -Bsymbolic-functions for PIE.
1313+1414+diff --git a/ld/lexsup.c b/ld/lexsup.c
1515+index 4cad209..e2fb212 100644
1616+--- a/ld/lexsup.c
1717++++ b/ld/lexsup.c
1818+@@ -1586,15 +1586,14 @@ parse_args (unsigned argc, char **argv)
1919+ /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data,
2020+ --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and
2121+ --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are
2222+- for shared libraries. -Bsymbolic overrides all others and vice
2323+- versa. */
2424++ for PIC outputs. -Bsymbolic overrides all others and vice versa. */
2525+ switch (command_line.symbolic)
2626+ {
2727+ case symbolic_unset:
2828+ break;
2929+ case symbolic:
3030+- /* -Bsymbolic is for shared library only. */
3131+- if (bfd_link_dll (&link_info))
3232++ /* -Bsymbolic is for PIC output only. */
3333++ if (bfd_link_pic (&link_info))
3434+ {
3535+ link_info.symbolic = TRUE;
3636+ /* Should we free the unused memory? */
3737+@@ -1603,8 +1602,8 @@ parse_args (unsigned argc, char **argv)
3838+ }
3939+ break;
4040+ case symbolic_functions:
4141+- /* -Bsymbolic-functions is for shared library only. */
4242+- if (bfd_link_dll (&link_info))
4343++ /* -Bsymbolic-functions is for PIC output only. */
4444++ if (bfd_link_pic (&link_info))
4545+ command_line.dynamic_list = dynamic_list_data;
4646+ break;
4747+ }
···11+--- binutils-2.15.94.0.2.2.orig/bfd/elf-bfd.h 2005-02-07 20:42:44.000000000 +0100
22++++ binutils-2.15.94.0.2.2/bfd/elf-bfd.h 2005-02-20 13:13:17.362558200 +0100
33+@@ -1266,6 +1266,9 @@
44+ /* Should the PT_GNU_RELRO segment be emitted? */
55+ bfd_boolean relro;
66+77++ /* Segment flags for the PT_PAX_FLAGS segment. */
88++ unsigned int pax_flags;
99++
1010+ /* Symbol version definitions in external objects. */
1111+ Elf_Internal_Verdef *verdef;
1212+1313+--- binutils-2.17.50.0.18/bfd/elf.c.orig 2007-08-01 11:12:02.000000000 -0400
1414++++ binutils-2.17.50.0.18/bfd/elf.c 2007-08-01 14:27:36.086986774 -0400
1515+@@ -1085,6 +1085,7 @@
1616+ case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
1717+ case PT_GNU_STACK: pt = "STACK"; break;
1818+ case PT_GNU_RELRO: pt = "RELRO"; break;
1919++ case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break;
2020+ default: pt = NULL; break;
2121+ }
2222+ return pt;
2323+@@ -2346,6 +2347,9 @@
2424+ case PT_GNU_RELRO:
2525+ return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "relro");
2626+2727++ case PT_PAX_FLAGS:
2828++ return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "pax_flags");
2929++
3030+ default:
3131+ /* Check for any processor-specific program segment types. */
3232+ bed = get_elf_backend_data (abfd);
3333+@@ -3326,6 +3330,11 @@
3434+ ++segs;
3535+ }
3636+3737++ {
3838++ /* We need a PT_PAX_FLAGS segment. */
3939++ ++segs;
4040++ }
4141++
4242+ for (s = abfd->sections; s != NULL; s = s->next)
4343+ {
4444+ if ((s->flags & SEC_LOAD) != 0
4545+@@ -3945,6 +3954,20 @@
4646+ pm = &m->next;
4747+ }
4848+4949++ {
5050++ amt = sizeof (struct elf_segment_map);
5151++ m = bfd_zalloc (abfd, amt);
5252++ if (m == NULL)
5353++ goto error_return;
5454++ m->next = NULL;
5555++ m->p_type = PT_PAX_FLAGS;
5656++ m->p_flags = elf_tdata (abfd)->pax_flags;
5757++ m->p_flags_valid = 1;
5858++
5959++ *pm = m;
6060++ pm = &m->next;
6161++ }
6262++
6363+ free (sections);
6464+ elf_tdata (abfd)->segment_map = mfirst;
6565+ }
6666+@@ -5129,7 +5152,8 @@
6767+ 5. PT_GNU_STACK segments do not include any sections.
6868+ 6. PT_TLS segment includes only SHF_TLS sections.
6969+ 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments.
7070+- 8. PT_DYNAMIC should not contain empty sections at the beginning
7171++ 8. PT_PAX_FLAGS segments do not include any sections.
7272++ 9. PT_DYNAMIC should not contain empty sections at the beginning
7373+ (with the possible exception of .dynamic). */
7474+ #define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed) \
7575+ ((((segment->p_paddr \
7676+@@ -5138,6 +5162,7 @@
7777+ && (section->flags & SEC_ALLOC) != 0) \
7878+ || IS_COREFILE_NOTE (segment, section)) \
7979+ && segment->p_type != PT_GNU_STACK \
8080++ && segment->p_type != PT_PAX_FLAGS \
8181+ && (segment->p_type != PT_TLS \
8282+ || (section->flags & SEC_THREAD_LOCAL)) \
8383+ && (segment->p_type == PT_LOAD \
8484+--- binutils-2.23.52.0.1/bfd/elflink.c.orig 2013-02-27 21:28:03.000000000 +0100
8585++++ binutils-2.23.52.0.1/bfd/elflink.c 2013-03-01 17:32:44.922717879 +0100
8686+@@ -5764,18 +5764,32 @@
8787+ && ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
8888+ return FALSE;
8989+9090++ elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC;
9191++
9292++ if (info->execheap)
9393++ elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT;
9494++ else if (info->noexecheap)
9595++ elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT;
9696++
9797+ /* Determine any GNU_STACK segment requirements, after the backend
9898+ has had a chance to set a default segment size. */
9999+ if (info->execstack)
100100++ {
101101+ elf_stack_flags (output_bfd) = PF_R | PF_W | PF_X;
102102++ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
103103++ }
104104+ else if (info->noexecstack)
105105++ {
106106+ elf_stack_flags (output_bfd) = PF_R | PF_W;
107107++ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
108108++ }
109109+ else
110110+ {
111111+ bfd *inputobj;
112112+ asection *notesec = NULL;
113113+ int exec = 0;
114114+115115++ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
116116+ for (inputobj = info->input_bfds;
117117+ inputobj;
118118+ inputobj = inputobj->link_next)
119119+@@ -5789,7 +5803,11 @@
120120+ if (s)
121121+ {
122122+ if (s->flags & SEC_CODE)
123123+- exec = PF_X;
124124++ {
125125++ elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP;
126126++ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
127127++ exec = PF_X;
128128++ }
129129+ notesec = s;
130130+ }
131131+ else if (bed->default_execstack)
132132+--- binutils-2.15.94.0.2.2.orig/binutils/readelf.c 2005-02-18 07:14:30.000000000 +0100
133133++++ binutils-2.15.94.0.2.2/binutils/readelf.c 2005-02-20 13:13:17.470541784 +0100
134134+@@ -2293,6 +2293,7 @@
135135+ return "GNU_EH_FRAME";
136136+ case PT_GNU_STACK: return "GNU_STACK";
137137+ case PT_GNU_RELRO: return "GNU_RELRO";
138138++ case PT_PAX_FLAGS: return "PAX_FLAGS";
139139+140140+ default:
141141+ if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
142142+--- binutils-2.15.94.0.2.2.orig/include/bfdlink.h 2004-11-22 21:33:32.000000000 +0100
143143++++ binutils-2.15.94.0.2.2/include/bfdlink.h 2005-02-20 13:13:17.476540872 +0100
144144+@@ -313,6 +313,14 @@
145145+ flags. */
146146+ unsigned int noexecstack: 1;
147147+148148++ /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT
149149++ flags. */
150150++ unsigned int execheap: 1;
151151++
152152++ /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT
153153++ flags. */
154154++ unsigned int noexecheap: 1;
155155++
156156+ /* TRUE if PT_GNU_RELRO segment should be created. */
157157+ unsigned int relro: 1;
158158+159159+--- binutils-2.15.94.0.2.2.orig/include/elf/common.h 2004-11-22 21:33:32.000000000 +0100
160160++++ binutils-2.15.94.0.2.2/include/elf/common.h 2005-02-20 13:13:17.482539960 +0100
161161+@@ -423,6 +423,7 @@
162162+ #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */
163163+ #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */
164164+ #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */
165165++#define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */
166166+167167+ /* Program segment permissions, in program header p_flags field. */
168168+169169+@@ -433,6 +434,19 @@
170170+ #define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */
171171+ #define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */
172172+173173++#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */
174174++#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */
175175++#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */
176176++#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */
177177++#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */
178178++#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */
179179++#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */
180180++#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */
181181++#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */
182182++#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */
183183++#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */
184184++#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */
185185++
186186+ /* Values for section header, sh_type field. */
187187+188188+ #define SHT_NULL 0 /* Section header table entry unused */
189189+--- binutils-2.18.50.0.1/ld/emultempl/elf32.em.orig 2007-09-08 19:34:12.000000000 +0200
190190++++ binutils-2.18.50.0.1/ld/emultempl/elf32.em 2007-09-15 21:41:35.688212063 +0200
191191+@@ -2139,6 +2139,16 @@
192192+ link_info.noexecstack = TRUE;
193193+ link_info.execstack = FALSE;
194194+ }
195195++ else if (strcmp (optarg, "execheap") == 0)
196196++ {
197197++ link_info.execheap = TRUE;
198198++ link_info.noexecheap = FALSE;
199199++ }
200200++ else if (strcmp (optarg, "noexecheap") == 0)
201201++ {
202202++ link_info.noexecheap = TRUE;
203203++ link_info.execheap = FALSE;
204204++ }
205205+ EOF
206206+207207+ if test -n "$COMMONPAGESIZE"; then
208208+--- binutils-2.15.94.0.2.2.orig/ld/ldgram.y 2004-11-22 21:33:32.000000000 +0100
209209++++ binutils-2.15.94.0.2.2/ld/ldgram.y 2005-02-20 13:13:17.499537376 +0100
210210+@@ -1073,6 +1073,8 @@
211211+ $$ = exp_intop (0x6474e550);
212212+ else if (strcmp (s, "PT_GNU_STACK") == 0)
213213+ $$ = exp_intop (0x6474e551);
214214++ else if (strcmp (s, "PT_PAX_FLAGS") == 0)
215215++ $$ = exp_intop (0x65041580);
216216+ else
217217+ {
218218+ einfo (_("\
219219+--- binutils-2.26/ld/lexsup.c.orig 2015-11-13 09:27:42.000000000 +0100
220220++++ binutils-2.26/ld/lexsup.c 2016-01-26 21:08:41.787138458 +0100
221221+@@ -1793,8 +1793,12 @@
222222+ fprintf (file, _("\
223223+ -z muldefs Allow multiple definitions\n"));
224224+ fprintf (file, _("\
225225++ -z execheap Mark executable as requiring executable heap\n"));
226226++ fprintf (file, _("\
227227+ -z execstack Mark executable as requiring executable stack\n"));
228228+ fprintf (file, _("\
229229++ -z noexecheap Mark executable as not requiring executable heap\n"));
230230++ fprintf (file, _("\
231231+ -z noexecstack Mark executable as not requiring executable stack\n"));
232232+ }
233233+
+4-12
pkgs/stdenv/generic/setup.sh
···214214for i in $initialPath; do
215215 if [ "$i" = / ]; then i=; fi
216216 addToSearchPath PATH $i/bin
217217- addToSearchPath PATH $i/sbin
218217done
219218220219if [ "$NIX_DEBUG" = 1 ]; then
···262261 source "$pkg"
263262 fi
264263264264+ if [ -d $1/bin ]; then
265265+ addToSearchPath _PATH $1/bin
266266+ fi
267267+265268 if [ -f "$pkg/nix-support/setup-hook" ]; then
266269 source "$pkg/nix-support/setup-hook"
267270 fi
···289292_addToNativeEnv() {
290293 local pkg=$1
291294292292- if [ -d $1/bin ]; then
293293- addToSearchPath _PATH $1/bin
294294- fi
295295-296295 # Run the package-specific hooks set by the setup-hook scripts.
297296 runHook envHook "$pkg"
298297}
···303302304303_addToCrossEnv() {
305304 local pkg=$1
306306-307307- # Some programs put important build scripts (freetype-config and similar)
308308- # into their crossDrv bin path. Intentionally these should go after
309309- # the nativePkgs in PATH.
310310- if [ -d $1/bin ]; then
311311- addToSearchPath _PATH $1/bin
312312- fi
313305314306 # Run the package-specific hooks set by the setup-hook scripts.
315307 runHook crossEnvHook "$pkg"
+3-3
pkgs/stdenv/linux/default.nix
···187187 name = "bootstrap-gcc-wrapper";
188188189189 overrides = pkgs: {
190190- inherit (stage1.pkgs) perl binutils paxctl;
190190+ inherit (stage1.pkgs) perl binutils paxctl gnum4 bison;
191191 # This also contains the full, dynamically linked, final Glibc.
192192 };
193193 };
···204204 name = "bootstrap-gcc-wrapper";
205205206206 overrides = pkgs: rec {
207207- inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders;
207207+ inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders gnum4 bison;
208208 # Link GCC statically against GMP etc. This makes sense because
209209 # these builds of the libraries are only used by GCC, so it
210210 # reduces the size of the stdenv closure.
···238238 # because gcc (since JAR support) already depends on zlib, and
239239 # then if we already have a zlib we want to use that for the
240240 # other purposes (binutils and top-level pkgs) too.
241241- inherit (stage3.pkgs) gettext gnum4 gmp perl glibc zlib linuxHeaders;
241241+ inherit (stage3.pkgs) gettext gnum4 bison gmp perl glibc zlib linuxHeaders;
242242243243 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
244244 nativeTools = false;