···146147 # Finally, add `-rpath' switches.
148 for i in $rpath; do
149- extra=(${extra[@]} -rpath $i)
000000000000150 done
000151fi
152153
···146147 # Finally, add `-rpath' switches.
148 for i in $rpath; do
149+ extra+=(-rpath $i)
150+ done
151+fi
152+153+154+# Only add --build-id if this is a final link. FIXME: should build gcc
155+# with --enable-linker-build-id instead?
156+if [ "$NIX_SET_BUILD_ID" = 1 ]; then
157+ for p in "${params[@]}"; do
158+ if [ "$p" = "-r" -o "$p" = "--relocatable" -o "$p" = "-i" ]; then
159+ relocatable=1
160+ break
161+ fi
162 done
163+ if [ -z "$relocatable" ]; then
164+ extra+=(--build-id)
165+ fi
166fi
167168
+6-6
pkgs/build-support/cc-wrapper/setup-hook.sh
···2223# Note: these come *after* $out in the PATH (see setup.sh).
2425-if [ -n "@cc@" ]; then
26- addToSearchPath PATH @cc@/bin
27fi
2829-if [ -n "@binutils@" ]; then
30- addToSearchPath PATH @binutils@/bin
31fi
3233if [ -n "@libc@" ]; then
34- addToSearchPath PATH @libc@/bin
35fi
3637if [ -n "@coreutils@" ]; then
38- addToSearchPath PATH @coreutils@/bin
39fi
4041if [ -z "$crossConfig" ]; then
···2223# Note: these come *after* $out in the PATH (see setup.sh).
2425+if [ -n "@binutils@" ]; then
26+ addToSearchPath _PATH @binutils@/bin
27fi
2829+if [ -n "@cc@" ]; then
30+ addToSearchPath _PATH @cc@/bin
31fi
3233if [ -n "@libc@" ]; then
34+ addToSearchPath _PATH @libc@/bin
35fi
3637if [ -n "@coreutils@" ]; then
38+ addToSearchPath _PATH @coreutils@/bin
39fi
4041if [ -z "$crossConfig" ]; then
···1-export NIX_LDFLAGS+=" --build-id"
2-export NIX_CFLAGS_COMPILE+=" -ggdb"
03dontStrip=1
45fixupOutputHooks+=(_separateDebugInfo)
···25 # Extract the debug info.
26 header "separating debug info from $i (build ID $id)"
27 mkdir -p "$dst/${id:0:2}"
28- objcopy --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug" --compress-debug-sections
29 strip --strip-debug "$i"
3031 # Also a create a symlink <original-name>.debug.
32 ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
33 done < <(find "$prefix" -type f -print0)
34}
35-36-# - We might prefer to compress the debug info during link-time already,
37-# but our ld doesn't support --compress-debug-sections=zlib (yet).
38-# - Debug info may cause problems due to excessive memory usage during linking.
39-# Using -Wa,--compress-debug-sections should help with that;
40-# further interesting information: https://gcc.gnu.org/wiki/DebugFission
41-# - Another related tool: https://fedoraproject.org/wiki/Features/DwarfCompressor
42-
···1+export NIX_SET_BUILD_ID=1
2+export NIX_LDFLAGS+=" --compress-debug-sections=zlib"
3+export NIX_CFLAGS_COMPILE+=" -ggdb -Wa,--compress-debug-sections"
4dontStrip=1
56fixupOutputHooks+=(_separateDebugInfo)
···26 # Extract the debug info.
27 header "separating debug info from $i (build ID $id)"
28 mkdir -p "$dst/${id:0:2}"
29+ objcopy --only-keep-debug "$i" "$dst/${id:0:2}/${id:2}.debug"
30 strip --strip-debug "$i"
3132 # Also a create a symlink <original-name>.debug.
33 ln -sfn ".build-id/${id:0:2}/${id:2}.debug" "$dst/../$(basename "$i")"
34 done < <(find "$prefix" -type f -print0)
35}
00000000
+1
pkgs/development/compilers/go/1.4.nix
···8788 patches = [
89 ./remove-tools-1.4.patch
090 ];
9192 GOOS = if stdenv.isDarwin then "darwin" else "linux";
···8788 patches = [
89 ./remove-tools-1.4.patch
90+ ./new-binutils.patch
91 ];
9293 GOOS = if stdenv.isDarwin then "darwin" else "linux";
···1+https://github.com/golang/go/issues/13114
2+https://gnats.netbsd.org/50777
3+4+--- a/src/cmd/6l/asm.c 2015-09-23 06:20:05.000000000 +0200
5++++ b/src/cmd/6l/asm.c 2016-03-10 21:00:29.032083210 +0100
6+@@ -118,6 +118,8 @@
7+ return;
8+9+ case 256 + R_X86_64_GOTPCREL:
10++ case 256 + R_X86_64_GOTPCRELX:
11++ case 256 + R_X86_64_REX_GOTPCRELX:
12+ if(targ->type != SDYNIMPORT) {
13+ // have symbol
14+ if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
15+--- a/src/cmd/8l/asm.c 2015-09-23 06:20:05.000000000 +0200
16++++ b/src/cmd/8l/asm.c 2016-03-10 21:02:16.702064080 +0100
17+@@ -115,6 +115,7 @@
18+ return;
19+20+ case 256 + R_386_GOT32:
21++ case 256 + R_386_GOT32X:
22+ if(targ->type != SDYNIMPORT) {
23+ // have symbol
24+ if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
25+--- a/src/cmd/ld/elf.h 2015-09-23 06:20:05.000000000 +0200
26++++ b/src/cmd/ld/elf.h 2016-03-10 21:00:29.033083211 +0100
27+@@ -478,32 +478,47 @@
28+ * Relocation types.
29+ */
30+31+-#define R_X86_64_NONE 0 /* No relocation. */
32+-#define R_X86_64_64 1 /* Add 64 bit symbol value. */
33+-#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */
34+-#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */
35+-#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */
36+-#define R_X86_64_COPY 5 /* Copy data from shared object. */
37+-#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */
38+-#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */
39+-#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */
40+-#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */
41+-#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */
42+-#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */
43+-#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */
44+-#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */
45+-#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */
46+-#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */
47+-#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
48+-#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */
49+-#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */
50+-#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */
51+-#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */
52+-#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
53+-#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */
54+-#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */
55+-
56+-#define R_X86_64_COUNT 24 /* Count of defined relocation types. */
57++#define R_X86_64_NONE 0
58++#define R_X86_64_64 1
59++#define R_X86_64_PC32 2
60++#define R_X86_64_GOT32 3
61++#define R_X86_64_PLT32 4
62++#define R_X86_64_COPY 5
63++#define R_X86_64_GLOB_DAT 6
64++#define R_X86_64_JMP_SLOT 7
65++#define R_X86_64_RELATIVE 8
66++#define R_X86_64_GOTPCREL 9
67++#define R_X86_64_32 10
68++#define R_X86_64_32S 11
69++#define R_X86_64_16 12
70++#define R_X86_64_PC16 13
71++#define R_X86_64_8 14
72++#define R_X86_64_PC8 15
73++#define R_X86_64_DTPMOD64 16
74++#define R_X86_64_DTPOFF64 17
75++#define R_X86_64_TPOFF64 18
76++#define R_X86_64_TLSGD 19
77++#define R_X86_64_TLSLD 20
78++#define R_X86_64_DTPOFF32 21
79++#define R_X86_64_GOTTPOFF 22
80++#define R_X86_64_TPOFF32 23
81++#define R_X86_64_PC64 24
82++#define R_X86_64_GOTOFF64 25
83++#define R_X86_64_GOTPC32 26
84++#define R_X86_64_GOT64 27
85++#define R_X86_64_GOTPCREL64 28
86++#define R_X86_64_GOTPC64 29
87++#define R_X86_64_GOTPLT64 30
88++#define R_X86_64_PLTOFF64 31
89++#define R_X86_64_SIZE32 32
90++#define R_X86_64_SIZE64 33
91++#define R_X86_64_GOTPC32_TLSDEC 34
92++#define R_X86_64_TLSDESC_CALL 35
93++#define R_X86_64_TLSDESC 36
94++#define R_X86_64_IRELATIVE 37
95++#define R_X86_64_PC32_BND 40
96++#define R_X86_64_GOTPCRELX 41
97++#define R_X86_64_REX_GOTPCRELX 42
98+99+100+ #define R_ALPHA_NONE 0 /* No reloc */
101+@@ -581,39 +596,42 @@
102+ #define R_ARM_COUNT 38 /* Count of defined relocation types. */
103+104+105+-#define R_386_NONE 0 /* No relocation. */
106+-#define R_386_32 1 /* Add symbol value. */
107+-#define R_386_PC32 2 /* Add PC-relative symbol value. */
108+-#define R_386_GOT32 3 /* Add PC-relative GOT offset. */
109+-#define R_386_PLT32 4 /* Add PC-relative PLT offset. */
110+-#define R_386_COPY 5 /* Copy data from shared object. */
111+-#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */
112+-#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */
113+-#define R_386_RELATIVE 8 /* Add load address of shared object. */
114+-#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */
115+-#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */
116+-#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */
117+-#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */
118+-#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */
119+-#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */
120+-#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */
121+-#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */
122+-#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */
123+-#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */
124+-#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */
125+-#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */
126+-#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */
127+-#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */
128+-#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */
129+-#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */
130+-#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */
131+-#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */
132+-#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */
133+-#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */
134+-#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */
135+-#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */
136+-
137+-#define R_386_COUNT 38 /* Count of defined relocation types. */
138++#define R_386_NONE 0
139++#define R_386_32 1
140++#define R_386_PC32 2
141++#define R_386_GOT32 3
142++#define R_386_PLT32 4
143++#define R_386_COPY 5
144++#define R_386_GLOB_DAT 6
145++#define R_386_JMP_SLOT 7
146++#define R_386_RELATIVE 8
147++#define R_386_GOTOFF 9
148++#define R_386_GOTPC 10
149++#define R_386_TLS_TPOFF 14
150++#define R_386_TLS_IE 15
151++#define R_386_TLS_GOTIE 16
152++#define R_386_TLS_LE 17
153++#define R_386_TLS_GD 18
154++#define R_386_TLS_LDM 19
155++#define R_386_TLS_GD_32 24
156++#define R_386_TLS_GD_PUSH 25
157++#define R_386_TLS_GD_CALL 26
158++#define R_386_TLS_GD_POP 27
159++#define R_386_TLS_LDM_32 28
160++#define R_386_TLS_LDM_PUSH 29
161++#define R_386_TLS_LDM_CALL 30
162++#define R_386_TLS_LDM_POP 31
163++#define R_386_TLS_LDO_32 32
164++#define R_386_TLS_IE_32 33
165++#define R_386_TLS_LE_32 34
166++#define R_386_TLS_DTPMOD32 35
167++#define R_386_TLS_DTPOFF32 36
168++#define R_386_TLS_TPOFF32 37
169++#define R_386_TLS_GOTDESC 39
170++#define R_386_TLS_DESC_CALL 40
171++#define R_386_TLS_DESC 41
172++#define R_386_IRELATIVE 42
173++#define R_386_GOT32X 43
174+175+ #define R_PPC_NONE 0 /* No relocation. */
176+ #define R_PPC_ADDR32 1
177+--- a/src/cmd/ld/ldelf.c 2015-09-23 06:20:05.000000000 +0200
178++++ b/src/cmd/ld/ldelf.c 2016-03-10 21:00:29.033083211 +0100
179+@@ -888,12 +888,15 @@
180+ case R('6', R_X86_64_PC32):
181+ case R('6', R_X86_64_PLT32):
182+ case R('6', R_X86_64_GOTPCREL):
183++ case R('6', R_X86_64_GOTPCRELX):
184++ case R('6', R_X86_64_REX_GOTPCRELX):
185+ case R('8', R_386_32):
186+ case R('8', R_386_PC32):
187+ case R('8', R_386_GOT32):
188+ case R('8', R_386_PLT32):
189+ case R('8', R_386_GOTOFF):
190+ case R('8', R_386_GOTPC):
191++ case R('8', R_386_GOT32X):
192+ *siz = 4;
193+ break;
194+ case R('6', R_X86_64_64):
+4
pkgs/development/libraries/glibc/builder.sh
···3738 # Get rid of more unnecessary stuff.
39 rm -rf $out/var $out/sbin/sln
000040}
4142genericBuild
···3738 # Get rid of more unnecessary stuff.
39 rm -rf $out/var $out/sbin/sln
40+41+ for i in $out/lib/*.a; do
42+ strip -S "$i"
43+ done
44}
4546genericBuild
+3-16
pkgs/development/libraries/glibc/default.nix
···2, installLocales ? true
3, profilingLibraries ? false
4, gccCross ? null
5-, debugSymbols ? false
6, withGd ? false, gd ? null, libpng ? null
7}:
8···13 cross = if gccCross != null then gccCross.target else null;
14in
15 build cross ({
16- name = "glibc"
17- + lib.optionalString debugSymbols "-debug"
18- + lib.optionalString withGd "-gd";
1920 inherit lib stdenv fetchurl linuxHeaders installLocales
21 profilingLibraries gccCross withGd gd libpng;
···38 fi
39 '';
400041 meta.description = "The GNU C Library";
42 }
43-44- //
45-46- (if debugSymbols
47- then {
48- # Build with debugging symbols, but leave optimizations on and don't
49- # attempt to keep the build tree.
50- dontStrip = true;
51- dontCrossStrip = true;
52- NIX_STRIP_DEBUG = 0;
53- }
54- else {})
5556 //
57
···1+http://lists.gnu.org/archive/html/bug-binutils/2016-01/msg00193.html
2+https://sourceware.org/bugzilla/show_bug.cgi?id=19615
3+4+From 1dab972d797c060e17229c2e10da01852ba82629 Mon Sep 17 00:00:00 2001
5+From: "H.J. Lu" <hjl.tools@gmail.com>
6+Date: Thu, 11 Feb 2016 15:31:15 -0800
7+Subject: [PATCH] Enable -Bsymbolic and -Bsymbolic-functions to PIE
8+9+Before binutils 2.26, -Bsymbolic and -Bsymbolic-functions were also
10+applied to PIE so that "ld -pie -Bsymbolic -E" can be used to export
11+symbols in PIE with local binding. This patch re-enables -Bsymbolic
12+and -Bsymbolic-functions for PIE.
13+14+diff --git a/ld/lexsup.c b/ld/lexsup.c
15+index 4cad209..e2fb212 100644
16+--- a/ld/lexsup.c
17++++ b/ld/lexsup.c
18+@@ -1586,15 +1586,14 @@ parse_args (unsigned argc, char **argv)
19+ /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data,
20+ --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and
21+ --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are
22+- for shared libraries. -Bsymbolic overrides all others and vice
23+- versa. */
24++ for PIC outputs. -Bsymbolic overrides all others and vice versa. */
25+ switch (command_line.symbolic)
26+ {
27+ case symbolic_unset:
28+ break;
29+ case symbolic:
30+- /* -Bsymbolic is for shared library only. */
31+- if (bfd_link_dll (&link_info))
32++ /* -Bsymbolic is for PIC output only. */
33++ if (bfd_link_pic (&link_info))
34+ {
35+ link_info.symbolic = TRUE;
36+ /* Should we free the unused memory? */
37+@@ -1603,8 +1602,8 @@ parse_args (unsigned argc, char **argv)
38+ }
39+ break;
40+ case symbolic_functions:
41+- /* -Bsymbolic-functions is for shared library only. */
42+- if (bfd_link_dll (&link_info))
43++ /* -Bsymbolic-functions is for PIC output only. */
44++ if (bfd_link_pic (&link_info))
45+ command_line.dynamic_list = dynamic_list_data;
46+ break;
47+ }
···1+--- binutils-2.15.94.0.2.2.orig/bfd/elf-bfd.h 2005-02-07 20:42:44.000000000 +0100
2++++ binutils-2.15.94.0.2.2/bfd/elf-bfd.h 2005-02-20 13:13:17.362558200 +0100
3+@@ -1266,6 +1266,9 @@
4+ /* Should the PT_GNU_RELRO segment be emitted? */
5+ bfd_boolean relro;
6+7++ /* Segment flags for the PT_PAX_FLAGS segment. */
8++ unsigned int pax_flags;
9++
10+ /* Symbol version definitions in external objects. */
11+ Elf_Internal_Verdef *verdef;
12+13+--- binutils-2.17.50.0.18/bfd/elf.c.orig 2007-08-01 11:12:02.000000000 -0400
14++++ binutils-2.17.50.0.18/bfd/elf.c 2007-08-01 14:27:36.086986774 -0400
15+@@ -1085,6 +1085,7 @@
16+ case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
17+ case PT_GNU_STACK: pt = "STACK"; break;
18+ case PT_GNU_RELRO: pt = "RELRO"; break;
19++ case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break;
20+ default: pt = NULL; break;
21+ }
22+ return pt;
23+@@ -2346,6 +2347,9 @@
24+ case PT_GNU_RELRO:
25+ return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "relro");
26+27++ case PT_PAX_FLAGS:
28++ return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "pax_flags");
29++
30+ default:
31+ /* Check for any processor-specific program segment types. */
32+ bed = get_elf_backend_data (abfd);
33+@@ -3326,6 +3330,11 @@
34+ ++segs;
35+ }
36+37++ {
38++ /* We need a PT_PAX_FLAGS segment. */
39++ ++segs;
40++ }
41++
42+ for (s = abfd->sections; s != NULL; s = s->next)
43+ {
44+ if ((s->flags & SEC_LOAD) != 0
45+@@ -3945,6 +3954,20 @@
46+ pm = &m->next;
47+ }
48+49++ {
50++ amt = sizeof (struct elf_segment_map);
51++ m = bfd_zalloc (abfd, amt);
52++ if (m == NULL)
53++ goto error_return;
54++ m->next = NULL;
55++ m->p_type = PT_PAX_FLAGS;
56++ m->p_flags = elf_tdata (abfd)->pax_flags;
57++ m->p_flags_valid = 1;
58++
59++ *pm = m;
60++ pm = &m->next;
61++ }
62++
63+ free (sections);
64+ elf_tdata (abfd)->segment_map = mfirst;
65+ }
66+@@ -5129,7 +5152,8 @@
67+ 5. PT_GNU_STACK segments do not include any sections.
68+ 6. PT_TLS segment includes only SHF_TLS sections.
69+ 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments.
70+- 8. PT_DYNAMIC should not contain empty sections at the beginning
71++ 8. PT_PAX_FLAGS segments do not include any sections.
72++ 9. PT_DYNAMIC should not contain empty sections at the beginning
73+ (with the possible exception of .dynamic). */
74+ #define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed) \
75+ ((((segment->p_paddr \
76+@@ -5138,6 +5162,7 @@
77+ && (section->flags & SEC_ALLOC) != 0) \
78+ || IS_COREFILE_NOTE (segment, section)) \
79+ && segment->p_type != PT_GNU_STACK \
80++ && segment->p_type != PT_PAX_FLAGS \
81+ && (segment->p_type != PT_TLS \
82+ || (section->flags & SEC_THREAD_LOCAL)) \
83+ && (segment->p_type == PT_LOAD \
84+--- binutils-2.23.52.0.1/bfd/elflink.c.orig 2013-02-27 21:28:03.000000000 +0100
85++++ binutils-2.23.52.0.1/bfd/elflink.c 2013-03-01 17:32:44.922717879 +0100
86+@@ -5764,18 +5764,32 @@
87+ && ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
88+ return FALSE;
89+90++ elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC;
91++
92++ if (info->execheap)
93++ elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT;
94++ else if (info->noexecheap)
95++ elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT;
96++
97+ /* Determine any GNU_STACK segment requirements, after the backend
98+ has had a chance to set a default segment size. */
99+ if (info->execstack)
100++ {
101+ elf_stack_flags (output_bfd) = PF_R | PF_W | PF_X;
102++ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
103++ }
104+ else if (info->noexecstack)
105++ {
106+ elf_stack_flags (output_bfd) = PF_R | PF_W;
107++ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
108++ }
109+ else
110+ {
111+ bfd *inputobj;
112+ asection *notesec = NULL;
113+ int exec = 0;
114+115++ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP;
116+ for (inputobj = info->input_bfds;
117+ inputobj;
118+ inputobj = inputobj->link_next)
119+@@ -5789,7 +5803,11 @@
120+ if (s)
121+ {
122+ if (s->flags & SEC_CODE)
123+- exec = PF_X;
124++ {
125++ elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP;
126++ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP;
127++ exec = PF_X;
128++ }
129+ notesec = s;
130+ }
131+ else if (bed->default_execstack)
132+--- binutils-2.15.94.0.2.2.orig/binutils/readelf.c 2005-02-18 07:14:30.000000000 +0100
133++++ binutils-2.15.94.0.2.2/binutils/readelf.c 2005-02-20 13:13:17.470541784 +0100
134+@@ -2293,6 +2293,7 @@
135+ return "GNU_EH_FRAME";
136+ case PT_GNU_STACK: return "GNU_STACK";
137+ case PT_GNU_RELRO: return "GNU_RELRO";
138++ case PT_PAX_FLAGS: return "PAX_FLAGS";
139+140+ default:
141+ if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
142+--- binutils-2.15.94.0.2.2.orig/include/bfdlink.h 2004-11-22 21:33:32.000000000 +0100
143++++ binutils-2.15.94.0.2.2/include/bfdlink.h 2005-02-20 13:13:17.476540872 +0100
144+@@ -313,6 +313,14 @@
145+ flags. */
146+ unsigned int noexecstack: 1;
147+148++ /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT
149++ flags. */
150++ unsigned int execheap: 1;
151++
152++ /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT
153++ flags. */
154++ unsigned int noexecheap: 1;
155++
156+ /* TRUE if PT_GNU_RELRO segment should be created. */
157+ unsigned int relro: 1;
158+159+--- binutils-2.15.94.0.2.2.orig/include/elf/common.h 2004-11-22 21:33:32.000000000 +0100
160++++ binutils-2.15.94.0.2.2/include/elf/common.h 2005-02-20 13:13:17.482539960 +0100
161+@@ -423,6 +423,7 @@
162+ #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */
163+ #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */
164+ #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */
165++#define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */
166+167+ /* Program segment permissions, in program header p_flags field. */
168+169+@@ -433,6 +434,19 @@
170+ #define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */
171+ #define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */
172+173++#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */
174++#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */
175++#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */
176++#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */
177++#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */
178++#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */
179++#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */
180++#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */
181++#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */
182++#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */
183++#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */
184++#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */
185++
186+ /* Values for section header, sh_type field. */
187+188+ #define SHT_NULL 0 /* Section header table entry unused */
189+--- binutils-2.18.50.0.1/ld/emultempl/elf32.em.orig 2007-09-08 19:34:12.000000000 +0200
190++++ binutils-2.18.50.0.1/ld/emultempl/elf32.em 2007-09-15 21:41:35.688212063 +0200
191+@@ -2139,6 +2139,16 @@
192+ link_info.noexecstack = TRUE;
193+ link_info.execstack = FALSE;
194+ }
195++ else if (strcmp (optarg, "execheap") == 0)
196++ {
197++ link_info.execheap = TRUE;
198++ link_info.noexecheap = FALSE;
199++ }
200++ else if (strcmp (optarg, "noexecheap") == 0)
201++ {
202++ link_info.noexecheap = TRUE;
203++ link_info.execheap = FALSE;
204++ }
205+ EOF
206+207+ if test -n "$COMMONPAGESIZE"; then
208+--- binutils-2.15.94.0.2.2.orig/ld/ldgram.y 2004-11-22 21:33:32.000000000 +0100
209++++ binutils-2.15.94.0.2.2/ld/ldgram.y 2005-02-20 13:13:17.499537376 +0100
210+@@ -1073,6 +1073,8 @@
211+ $$ = exp_intop (0x6474e550);
212+ else if (strcmp (s, "PT_GNU_STACK") == 0)
213+ $$ = exp_intop (0x6474e551);
214++ else if (strcmp (s, "PT_PAX_FLAGS") == 0)
215++ $$ = exp_intop (0x65041580);
216+ else
217+ {
218+ einfo (_("\
219+--- binutils-2.26/ld/lexsup.c.orig 2015-11-13 09:27:42.000000000 +0100
220++++ binutils-2.26/ld/lexsup.c 2016-01-26 21:08:41.787138458 +0100
221+@@ -1793,8 +1793,12 @@
222+ fprintf (file, _("\
223+ -z muldefs Allow multiple definitions\n"));
224+ fprintf (file, _("\
225++ -z execheap Mark executable as requiring executable heap\n"));
226++ fprintf (file, _("\
227+ -z execstack Mark executable as requiring executable stack\n"));
228+ fprintf (file, _("\
229++ -z noexecheap Mark executable as not requiring executable heap\n"));
230++ fprintf (file, _("\
231+ -z noexecstack Mark executable as not requiring executable stack\n"));
232+ }
233+
+4-12
pkgs/stdenv/generic/setup.sh
···214for i in $initialPath; do
215 if [ "$i" = / ]; then i=; fi
216 addToSearchPath PATH $i/bin
217- addToSearchPath PATH $i/sbin
218done
219220if [ "$NIX_DEBUG" = 1 ]; then
···262 source "$pkg"
263 fi
2640000265 if [ -f "$pkg/nix-support/setup-hook" ]; then
266 source "$pkg/nix-support/setup-hook"
267 fi
···289_addToNativeEnv() {
290 local pkg=$1
291292- if [ -d $1/bin ]; then
293- addToSearchPath _PATH $1/bin
294- fi
295-296 # Run the package-specific hooks set by the setup-hook scripts.
297 runHook envHook "$pkg"
298}
···303304_addToCrossEnv() {
305 local pkg=$1
306-307- # Some programs put important build scripts (freetype-config and similar)
308- # into their crossDrv bin path. Intentionally these should go after
309- # the nativePkgs in PATH.
310- if [ -d $1/bin ]; then
311- addToSearchPath _PATH $1/bin
312- fi
313314 # Run the package-specific hooks set by the setup-hook scripts.
315 runHook crossEnvHook "$pkg"
···214for i in $initialPath; do
215 if [ "$i" = / ]; then i=; fi
216 addToSearchPath PATH $i/bin
0217done
218219if [ "$NIX_DEBUG" = 1 ]; then
···261 source "$pkg"
262 fi
263264+ if [ -d $1/bin ]; then
265+ addToSearchPath _PATH $1/bin
266+ fi
267+268 if [ -f "$pkg/nix-support/setup-hook" ]; then
269 source "$pkg/nix-support/setup-hook"
270 fi
···292_addToNativeEnv() {
293 local pkg=$1
2940000295 # Run the package-specific hooks set by the setup-hook scripts.
296 runHook envHook "$pkg"
297}
···302303_addToCrossEnv() {
304 local pkg=$1
0000000305306 # Run the package-specific hooks set by the setup-hook scripts.
307 runHook crossEnvHook "$pkg"
+3-3
pkgs/stdenv/linux/default.nix
···187 name = "bootstrap-gcc-wrapper";
188189 overrides = pkgs: {
190- inherit (stage1.pkgs) perl binutils paxctl;
191 # This also contains the full, dynamically linked, final Glibc.
192 };
193 };
···204 name = "bootstrap-gcc-wrapper";
205206 overrides = pkgs: rec {
207- inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders;
208 # Link GCC statically against GMP etc. This makes sense because
209 # these builds of the libraries are only used by GCC, so it
210 # reduces the size of the stdenv closure.
···238 # because gcc (since JAR support) already depends on zlib, and
239 # then if we already have a zlib we want to use that for the
240 # other purposes (binutils and top-level pkgs) too.
241- inherit (stage3.pkgs) gettext gnum4 gmp perl glibc zlib linuxHeaders;
242243 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
244 nativeTools = false;
···187 name = "bootstrap-gcc-wrapper";
188189 overrides = pkgs: {
190+ inherit (stage1.pkgs) perl binutils paxctl gnum4 bison;
191 # This also contains the full, dynamically linked, final Glibc.
192 };
193 };
···204 name = "bootstrap-gcc-wrapper";
205206 overrides = pkgs: rec {
207+ inherit (stage2.pkgs) binutils glibc perl patchelf linuxHeaders gnum4 bison;
208 # Link GCC statically against GMP etc. This makes sense because
209 # these builds of the libraries are only used by GCC, so it
210 # reduces the size of the stdenv closure.
···238 # because gcc (since JAR support) already depends on zlib, and
239 # then if we already have a zlib we want to use that for the
240 # other purposes (binutils and top-level pkgs) too.
241+ inherit (stage3.pkgs) gettext gnum4 bison gmp perl glibc zlib linuxHeaders;
242243 gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
244 nativeTools = false;