summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-devel/binutils-apple')
-rw-r--r--sys-devel/binutils-apple/Manifest21
-rw-r--r--sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild214
-rw-r--r--sys-devel/binutils-apple/binutils-apple-3.2.6.ebuild254
-rw-r--r--sys-devel/binutils-apple/binutils-apple-3.2.ebuild234
-rw-r--r--sys-devel/binutils-apple/binutils-apple-4.2-r1.ebuild328
-rw-r--r--sys-devel/binutils-apple/binutils-apple-4.2.ebuild312
-rw-r--r--sys-devel/binutils-apple/binutils-apple-4.3-r1.ebuild316
-rw-r--r--sys-devel/binutils-apple/binutils-apple-4.3.ebuild309
-rw-r--r--sys-devel/binutils-apple/binutils-apple-5.1.ebuild356
-rw-r--r--sys-devel/binutils-apple/binutils-apple-6.1.ebuild355
-rw-r--r--sys-devel/binutils-apple/files/Makefile12
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-as-dir.patch69
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-as.patch98
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-libtool-ranlib.patch17
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-nmedit.patch15
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-efi-man.patch38
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-headers.patch15
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-oss-dir.patch17
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-ranlib.patch53
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.1-testsuite.patch102
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.1.2-as-Makefile.patch11
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.2-armv7-defines.patch10
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.2.2-as.patch101
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-3.2.3-ranlib.patch59
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.0-as-dir.patch67
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.0-as.patch99
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.0-no-oss-dir.patch15
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.2-as-dir.patch45
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.2-globals-extern.patch29
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.2-lto.patch34
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.5-as.patch100
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-5.1-as-dir.patch47
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-5.1-constant-types.patch26
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-5.1-extraneous-includes.patch31
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-5.1-nolto.patch43
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-5.1-otool-stdc.patch23
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-5.1-ranlib.patch15
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-5.1-strnlen.patch45
-rw-r--r--sys-devel/binutils-apple/files/cctools-839-intel-retf.patch14
-rw-r--r--sys-devel/binutils-apple/files/ld64-123.2-Makefile47
-rw-r--r--sys-devel/binutils-apple/files/ld64-123.2-darwin8-no-mlong-branch-warning.patch17
-rw-r--r--sys-devel/binutils-apple/files/ld64-123.2-debug-backtrace.patch15
-rw-r--r--sys-devel/binutils-apple/files/ld64-123.2.1-lto.patch218
-rw-r--r--sys-devel/binutils-apple/files/ld64-127.2-Makefile50
-rw-r--r--sys-devel/binutils-apple/files/ld64-127.2-extraneous-headers.patch12
-rw-r--r--sys-devel/binutils-apple/files/ld64-127.2-lto.patch214
-rw-r--r--sys-devel/binutils-apple/files/ld64-127.2-ppc-range-warning.patch16
-rw-r--r--sys-devel/binutils-apple/files/ld64-127.2-thread_state.patch13
-rw-r--r--sys-devel/binutils-apple/files/ld64-128.2-1010.patch20
-rw-r--r--sys-devel/binutils-apple/files/ld64-128.2-Makefile47
-rw-r--r--sys-devel/binutils-apple/files/ld64-128.2-Makefile-250
-rw-r--r--sys-devel/binutils-apple/files/ld64-128.2-stdlib.patch14
-rw-r--r--sys-devel/binutils-apple/files/ld64-136-Makefile48
-rw-r--r--sys-devel/binutils-apple/files/ld64-136-compile_stubs.h53
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-Makefile51
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-arm64-fixup.patch17
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-constant-types.patch61
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-crashreporter.patch23
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-gcc.patch1038
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-missing-cputypes.patch10
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-noarm.patch1236
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-nolto.patch219
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-noppc.patch26
-rw-r--r--sys-devel/binutils-apple/files/ld64-236.3-nosnapshots.patch644
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-arm64-cputype.patch17
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-atomic-volatile.patch27
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-cc_md5.patch24
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-extraneous-includes.patch13
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-gcc.patch1029
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-get-comm-align.patch30
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-lto-noremarks.patch107
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-noarm.patch1288
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-nosnapshots.patch644
-rw-r--r--sys-devel/binutils-apple/files/ld64-241.9-register-names.patch50
-rw-r--r--sys-devel/binutils-apple/files/ld64-95.2.12-Makefile26
-rw-r--r--sys-devel/binutils-apple/files/ld64-95.2.12-darwin8-no-mlong-branch-warning.patch15
-rw-r--r--sys-devel/binutils-apple/files/libunwind-30-Makefile23
-rw-r--r--sys-devel/binutils-apple/metadata.xml9
78 files changed, 11410 insertions, 0 deletions
diff --git a/sys-devel/binutils-apple/Manifest b/sys-devel/binutils-apple/Manifest
new file mode 100644
index 000000000000..9c32c170d0ad
--- /dev/null
+++ b/sys-devel/binutils-apple/Manifest
@@ -0,0 +1,21 @@
+DIST binutils-apple-3.2-unwind-patches-5.tar.xz 26924 SHA256 65a3b979df5c2033ac34e830d8a77b92b436b6d5707483c619c90a1c2ea46428 SHA512 9f3ec399274060b67c51193029da5af2199c45bf923a2fa513143111cf3f1c899256c993f4927f4da85a21570d0bc9ff0872e663f90284b2cdbb3f609ea8484e WHIRLPOOL 877410e6e0b442df9e9b7cdef51cc28bd636856949ea42ac53e97ebfc41c2f50309a054729d4fc3498d6eccac96170ffb59dd5700237e59684773832218793cc
+DIST binutils-apple-LP64-patches-1.tar.bz2 10235 SHA256 a107459f3914d57524e51ec4cb5e800f6715d40003514c79add0b5b4521cf809 SHA512 5632d4033c39e47de3ec275d02100ed53408a63122fe722c26dda1b02275c397524b113e51e1334d3235fc7f0a3bb8e53d4ccc1c2e40f24c6129282846da22e1 WHIRLPOOL c46d2021c85cee46e87871687ca7217169d14061848d12b4fa203db5d76a89969313ce55b345f2ad9fdba65fd39bdd34b146393332566fd539b2bdfc3f1e4304
+DIST cctools-698.1.tar.gz 2318018 SHA256 383f1c0c78a2b3efdfdf7ce01adb7e2f8ee9985164dba6ab1c0fae800a211cec SHA512 05e64df9bead958e6035b3cf449a2cb21b19cef10278348ebea8b47816b05a77ebd7f72fd90270400784a231b5d55c8f909653e8177cbe1332d7f7d618453f12 WHIRLPOOL 6ae1244ca97b13378e864609aa62efc4bf028b3e55bfb00cdbf9d20ed6cedd917c64ce337b2635dcabce334b8f994e2558fbda36055b951bf769a21950673e12
+DIST cctools-750.tar.gz 1947953 SHA256 188855640da114e37e4ddd4824ff6cdc1ea89dfb6c90a23905c9ca315342f356 SHA512 e2e152a9fb7db47c60fe450e1fc92c6866ab89682c7fdc594b97e419ce93ea1353654bd4419bf3df99d119f554aa0f32993dc645dd7c4680840cd01b7dce2f67 WHIRLPOOL 98e48fca183ee47d138426c65401138954a86abc3b80bfc4c5d105b97b8eb583ae350657f1a7dc1154259d0bcdfe1d60dc0a63409826e9a24b178674a5afdf21
+DIST cctools-795.tar.gz 1993795 SHA256 7fab7044b648e92a9fefd493a1bb6daa4246f24c5838d8b5c913a446e6bbd2ef SHA512 5a34a73dc71d3574a357f6b0f26a48a99dd0995d62695b309cdfe85c4960934b410455b1ba6bdbc9a4e32106bb45b35555604975d2a80ad1be21f5d4eac69254 WHIRLPOOL 2bd074ac8ef8542c2c3df5fae91a0bece2e1c31d6c6c771c55e7c7a3d90929f9a7cd420760dcb5ecffb9dd279abed4ba5ebf840c9e9bb983a806707d735cd735
+DIST cctools-809.tar.gz 2014410 SHA256 03ba62749b843b131c7304a044a98c6ffacd65b1399b921d69add0375f79d8ad SHA512 1349b3e6b3b48d9fa88dade187c05c80f161c3895fc6451a530880a256eb82dc93376b3cfd0f4d65e83f5fe00dc2baab386c5f78ce5b096f2c69fe53e1a55e24 WHIRLPOOL bd06ed88a7ab0bca173c0ee03c39cf60c719b9e0f03d21df9189e3e4a62e4fb452be46b0b0b05eafc70aed88bccc0a621d9165a1df63ea0eb071f9e5dda43c25
+DIST cctools-822.tar.gz 2024412 SHA256 dfaa9bdbd023524d47429674f64d2d5ea393123dabf90868be0aa17f61f45289 SHA512 8b02cc837d5e0520f35da445f25ba86b5042d5caa27b49a599e829ed89428cf78dbd1831bcf6c18301f941fbfb31ac2114e248041d98008a466e1574f4fe1586 WHIRLPOOL 81191ab46e8a9e47e4267146f978438ff64314b0363296b973a02f361918a5cd69057753a1b40766b93d3d4a3ed10585a27f6da2953992a406be61d1dcc1d06c
+DIST cctools-855.tar.gz 1699635 SHA256 751748ddf32c8ea84c175f32792721fa44424dad6acbf163f84f41e9617dbc58 SHA512 50f5d015ce807aa5ca274dd2deea810b8b375110e60b5e334ca4b2170526b738ea5f86a5436caebbdb748badc3b89601d0f450f5b867d8393c89e336a3db4b3f WHIRLPOOL fa493a29e32583f60c3553794bbb6d01a7b5ef797d8e8ba8161c9cbf237906ebbfaff560366da2d5b852bfcbdd55e874c00edf5b3169b16b357a54fcf3c07c4c
+DIST cctools-862.tar.gz 1702345 SHA256 1bf29f620b91c901ad3116b47738ab5076c1aed75d13869cd3bc7f067b4aaadb SHA512 faa401c1dc55bfb9cd2a9a9cc7bc9d473ee63b019607967c8b0da325514d6a1f7b1f52404370bcc018e86d30d75a4b01183f49b793f577110663efe43871360a WHIRLPOOL 371307f3264361f5e2e48d83177aff1a8f435cf2bdc1f4998cc5780c5b3760048a29a7620d2390db8f0c9378cd2f3b2f130b6aca9d402e3d428c4f4d353db097
+DIST dyld-195.5.tar.gz 411615 SHA256 2cf0484c87cf79b606b351a7055a247dae84093ae92c747a74e0cde2c8c8f83c SHA512 f316d32f3e417cf0898a8e231df66572d3424765831375863799d3ff30f8e28342ca692426d0ece7a8d069b341a3b9ca79c625edc322d90e3f26f528ea555324 WHIRLPOOL e0e231653ad37ad8fdb7d5fbd372fe1dc34b80e41f7dafa8bb46f4c8fa4f5acb4574f4cd346304dfaca1f074667f381931ca5ff7a7efddaea770fb35d30539dc
+DIST dyld-195.6.tar.gz 412518 SHA256 69296e9b4192bdac778ea899fffc18b02be62b51b5e8474b4cf85ae5f2b08aa4 SHA512 58a9ea27efc02e66f9d99bfa250af1d90326385385431e5279386bbd9ab53366bf7e8236543296908b7214c33523c8f60098a6298a7393b3180e2a6bce18e7c5 WHIRLPOOL e37b11d3996559f8a1843577a5fa42f96e4d42419f205276600f0ed79fcd2490da1f8a77eecf29f111b3db62a65e8e9cd77a154e3b389d633a7ac1525273b9b5
+DIST dyld-353.2.1.tar.gz 510036 SHA256 051089e284c5a4d671b21b73866abd01d54e5ea1912cadf3a9b916890fb31540 SHA512 a9488620499f682e245b55b7e0e4ec02fc0bcf03bd8a70d4a4ee0ba762067ade2f41c188990c101727476d41c19368b4cc89cccf2df40231da1c777742c7391f WHIRLPOOL 3164746ed8c866df993f08e405e7e329db427af8eeded681d5fb88031ef2c025363d5bfb647e9315738024adf9f48efacf49226f86f27def584ec7f538da292e
+DIST ld64-127.2.tar.gz 496975 SHA256 97b75547b2bd761306ab3e15ae297f01e7ab9760b922bc657f4ef72e4e052142 SHA512 a87181eca9307518aa21fc52a4d665c11ad51106c318c229d7f08650228f771484fd0b8c01c63639d577503aa9bc86d0792a3524643dc18cff19c3754aed9fc8 WHIRLPOOL 94f58da977da3d2d0c5a907a7d2c02e4a0d8323d04b8429d133e377b8495b0d344eec93dd1baaf369aa0a1517c7666cbef1d98d3cc6e8fd5d51c9622a2edcdf1
+DIST ld64-128.2.tar.gz 494361 SHA256 96a912464e2d4d3d7cdaab0744003b0fa93d139f203c82867f659ee94b4ae9f7 SHA512 f50a3c396e6f4fddc685bb3f59f9a260bd2f47060535d24259b2b411e4f759e48daa35819da682ad9bceaa1b9a1981eb34716387d988cdc4b7eec9ab2169726e WHIRLPOOL 78dec40124ae11c80483b362860b01c833fcaff67bae6b6cb3b72371daffdf3be809186f5daca4bb6ace77441cb43168939eb60eedf9f8c05ae3ec644c2a0502
+DIST ld64-236.3.tar.gz 624400 SHA256 8ef36729b643201081ab45ebd8586ede8f9968bc17614b679a940faa82875ca6 SHA512 e103fc5efd4d4161c7dc55b1ad53aebd455cfcd72de7873ebfdf5ba896b7b0da9c9aeb12e1e1a76425768ac1dc85d864a4ce33b5b841ba115eeab96a2e2965aa WHIRLPOOL d122e325518860c810b9efde7016ebecb6b59c56bb40ae1f041a840be764a5d9b90c7db1922fd9037c18f4caae7ace0d395591ffb3db704c87b92837ef997a17
+DIST ld64-241.9.tar.gz 639944 SHA256 3594e87c626c3b5abab6470cac6f27b367f1efcee60eb3d0f6b6d4ecf9b24230 SHA512 6958e7064f4fd8b47501225fc4cbc6292e5da63d7f4103ad79add177ef7382c8de3c732f14d19a9c11356b8070f578392383caccc3795e2ab8ef7b7ddbde88da WHIRLPOOL 5b07a336efde52b00b2601866907513517593a113583f05a9c45b98b4d6f394d87add887a7e44a95f462b6c2b5617ce497376b94a523e5cdf0f69d4d10ef3407
+DIST ld64-85.2.1.tar.gz 598524 SHA256 4bcbcbdfd62efdc46c51700b8f5dae2cbd1638e9e50f649d5c7f242d32fca804 SHA512 b5ffaffc43e74f22688fecd9fb3023a59160cf051f9412f34e6b0acf1c4f9d43ba641e199d8d6b1c6cf3bbbbf117645988fd879ded1fec8be056b6941fe79999 WHIRLPOOL 7c50f462eb41808b57ea06b82bdf576460bddb4150abe7a678af541aa0b179105d994a2b6fd10152481aa28acc903265160945b4aae9dcfce0a1a1cfe4b9460a
+DIST ld64-97.17.tar.gz 421947 SHA256 02bd46af0809eaa415d096d7d41c3e8e7d80f7d8d181840866fb87f036b4e089 SHA512 841774a1a7c0e2f661ac7e66703f7578d8f11274897ffa15f8c49daf290a23465763f264a4dae99f15754891f44c425c0d327652112007b499bc8f755a7fc9d6 WHIRLPOOL 7225b44d845b13c6b6d1a685170f2b6e15b81c48320fa3b570771938ed457a59452e80873996a4b2712a8f6813486063afd73acf979a97d823afb3d510d74678
+DIST libunwind-30.tar.gz 82811 SHA256 6ac97d18cc2b05e6de1269bf5af03b81948bd2200dae827527f3dc618b82bd41 SHA512 57106eafa1516791b4e0db2de6c6336bc0c1cbd8bf098a6d3a809fafa457802c95a7aeae9137f4ca5922a3018dfd8f597907ea4187b0afbbf267500eae00041f WHIRLPOOL c3caf5ba593cffa2f0a9cdb256f518524e9500eaf0a013c4973dc9881b16efa0c388e70407bbed1fd331f100af2da01ddeee12d33b3afc1213d69c32ab5e1d0b
+DIST libunwind-35.3.tar.gz 90002 SHA256 2bcc95553a44fa3edca41993ccfac65ba267830cb37c85dca760b34094722e56 SHA512 b7d9a86ef24f1fe9ca14517471e03a910219a229af9f0d4cf94435115971360640451107ba20c93fb1aab788f8b6eb5ed580ee08fdaa990b9fa43e9ae360c6b4 WHIRLPOOL 838912e46031b3a6796bfe854f0244991ce5bc3b59b95855224c9e84639e57b69f541b7993658360721423533dca75037248ea90f5e274b332f27319fdd85a9a
+DIST libunwind-llvm-115426.tar.bz2 74622 SHA256 e77a42c04eda5e3db61fc8b5bc98a55c6a015a9b02a74aab0f35d551fc38272f SHA512 01d78852632072ae48e95cfcf893dbb5325d4a3f4535a3cd3bc2afd5388c5f76995454219c8c6c2c2767abb2edc23bfe0212508c57b1d6db1c4a5d80cc5d4f9a WHIRLPOOL 0c7c8b8493b83e9c1337ab323697cfc255d1ef3e9ae2042df3a4f7480948a25fd571eb88a49e33168587d0994ec2d1371f2ef4d7834d7b41f77722d9693e8d55
diff --git a/sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild b/sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild
new file mode 100644
index 000000000000..fb391099ac31
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-3.1.2.ebuild
@@ -0,0 +1,214 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test" # the test suite will test what's installed.
+
+LD64=ld64-85.2.1
+CCTOOLS=cctools-698.1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools 3.1.2"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.gentoo.org/~grobian/distfiles/${LD64}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${CCTOOLS}.tar.gz"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x86-macos"
+IUSE="test"
+SLOT="0"
+
+RDEPEND="sys-devel/binutils-config"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}"
+else
+ SLOT="0"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+prepare_ld64() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/Makefile .
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64}\\n\""
+ sed -i \
+ -e '/^#define LTO_SUPPORT 1/s:1:0:' \
+ ObjectDump.cpp
+ echo '#undef LTO_SUPPORT' > configure.h
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ elog "Deleted $c tests that were bound to fail"
+}
+
+src_prepare() {
+ prepare_ld64
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-3.1.1-as.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-efi-man.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.1.2-as-Makefile.patch
+ cd "${S}"/${LD64}
+ epatch "${FILESDIR}"/${PN}-3.1.1-testsuite.patch
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+compile_ld64() {
+ cd "${S}"/${LD64}/src
+ # 'struct linkedit_data_command' is defined in mach-o/loader.h on leopard,
+ # but not on tiger.
+ [[ ${CHOST} == *-apple-darwin8 ]] && \
+ append-flags -isystem "${S}"/${CCTOOLS}/include/
+ emake || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LTO= \
+ EFITOOLS= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ RC_CFLAGS="${CFLAGS}" || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ tc-export CC CXX
+ compile_cctools
+ compile_ld64
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-3.2.6.ebuild b/sys-devel/binutils-apple/binutils-apple-3.2.6.ebuild
new file mode 100644
index 000000000000..ad64539d97ef
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-3.2.6.ebuild
@@ -0,0 +1,254 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test" # the test suite will test what's installed.
+
+LD64=ld64-97.17
+CCTOOLS=cctools-795
+# http://lists.apple.com/archives/Darwin-dev/2009/Sep/msg00025.html
+UNWIND=binutils-apple-3.2-unwind-patches-5
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${UNWIND}.tar.xz"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test"
+SLOT="0"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ >=sys-devel/gcc-apple-4.2.1"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}"
+else
+ SLOT="0"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+src_prepare() {
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-3.2.2-as.patch
+ epatch "${FILESDIR}"/${PN}-4.0-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.2.3-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-oss-dir.patch
+
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/ld64-95.2.12-Makefile Makefile
+
+ ln -s ../../${CCTOOLS}/include
+ cp "${WORKDIR}"/ld64-unwind/compact_unwind_encoding.h include/mach-o/
+ cp other/prune_trie.h include/mach-o/ || die
+ # use our own copy of lto.h, which doesn't require llvm build-env
+ mkdir -p include/llvm-c || die
+ cp "${WORKDIR}"/ld64-unwind/ld64-97.14-llvm-lto.h include/llvm-c/lto.h || die
+
+ echo '' > configure.h
+ echo '' > linker_opts
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${WORKDIR}"/ld64-unwind/ld64-97.14-unlibunwind.patch
+ [[ ${CHOST} == powerpc*-darwin* ]] && \
+ epatch "${FILESDIR}"/ld64-95.2.12-darwin8-no-mlong-branch-warning.patch
+ if use !lto ; then
+ sed -i -e '/#define LTO_SUPPORT 1/d' other/ObjectDump.cpp || die
+ fi
+
+ # clean up test suite
+ cd "${S}"/${LD64}
+ epatch "${FILESDIR}"/${PN}-3.1.1-testsuite.patch
+
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+src_configure() {
+ tc-export CC CXX AR
+ if use lto ; then
+ append-flags -DLTO_SUPPORT
+ append-ldflags -L"${EPREFIX}"/usr/$(get_libdir)/llvm
+ append-libs LTO
+ else
+ append-flags -ULTO_SUPPORT
+ fi
+}
+
+compile_ld64() {
+ cd "${S}"/${LD64}/src
+ # remove antiquated copy that's available on any OSX system and
+ # breaks ld64 compilation
+ mv include/mach-o/dyld.h{,.disable}
+ emake \
+ CFLAGS="${CFLAGS}" \
+ CXXFLAGS="${CXXFLAGS}" \
+ LDFLAGS="${LDFLAGS} ${LIBS}" \
+ || die "emake failed for ld64"
+ use test && emake build_test
+ # restore, it's necessary for cctools' install
+ mv include/mach-o/dyld.h{.disable,}
+}
+
+compile_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= LTO= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= LTO= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-3.2.ebuild b/sys-devel/binutils-apple/binutils-apple-3.2.ebuild
new file mode 100644
index 000000000000..77555c644ecd
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-3.2.ebuild
@@ -0,0 +1,234 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test" # the test suite will test what's installed.
+
+# LD64=ld64-95.2.12 # can't compile this one, missing libunwind/* includes
+# http://lists.apple.com/archives/Darwin-dev/2009/Sep/msg00025.html
+LD64=ld64-85.2.1 # from 3.1.2
+CCTOOLS=cctools-750
+LP64PATCHES=binutils-apple-LP64-patches-1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools 3.2"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.gentoo.org/~grobian/distfiles/${LD64}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${CCTOOLS}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${LP64PATCHES}.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="test"
+SLOT="0"
+
+RDEPEND="sys-devel/binutils-config"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}"
+else
+ SLOT="0"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+prepare_ld64() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/Makefile .
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ sed -i \
+ -e '/^#define LTO_SUPPORT 1/s:1:0:' \
+ ObjectDump.cpp || die
+ echo '#undef LTO_SUPPORT' > configure.h
+ echo '' > linker_opts
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ elog "Deleted $c tests that were bound to fail"
+}
+
+src_prepare() {
+ prepare_ld64
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-3.1.1-as.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-oss-dir.patch
+ epatch "${FILESDIR}"/${P}-armv7-defines.patch
+
+ cd "${S}"/${LD64}
+ epatch "${FILESDIR}"/${PN}-3.1.1-testsuite.patch
+ epatch "${WORKDIR}"/LP64/ld64/*.patch
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+compile_ld64() {
+ cd "${S}"/${LD64}/src
+ # 'struct linkedit_data_command' is defined in mach-o/loader.h on leopard,
+ # but not on tiger.
+ [[ ${CHOST} == *-apple-darwin8 ]] && \
+ append-flags -isystem "${S}"/${CCTOOLS}/include/
+ emake || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LTO= \
+ TRIE= \
+ EFITOOLS= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ tc-export CC CXX
+ compile_cctools
+ compile_ld64
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-4.2-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-4.2-r1.ebuild
new file mode 100644
index 000000000000..406cd3e102a0
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-4.2-r1.ebuild
@@ -0,0 +1,328 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-127.2
+CCTOOLS_VERSION=809
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+CCTOOLS_HEADERS=cctools-855
+LIBUNWIND=libunwind-30
+DYLD=dyld-195.5
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS_HEADERS}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ || ( >=sys-devel/gcc-apple-4.2.1 sys-devel/llvm )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-4"
+else
+ SLOT="4"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+src_prepare() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/ld64-127.2-Makefile Makefile
+ epatch "${FILESDIR}"/${LD64}-lto.patch
+ epatch "${FILESDIR}"/ld64-128.2-stdlib.patch
+ epatch "${FILESDIR}"/${LD64}-ppc-range-warning.patch
+ epatch "${FILESDIR}"/ld64-127.2-extraneous-headers.patch
+ epatch "${FILESDIR}"/ld64-241.9-register-names.patch
+ epatch "${FILESDIR}"/ld64-241.9-get-comm-align.patch
+ epatch "${FILESDIR}"/ld64-241.9-cc_md5.patch
+ epatch "${FILESDIR}"/ld64-128.2-1010.patch
+
+ # We used to use our own copy of lto.h, which doesn't require llvm
+ # build-env. Current versions of llvm provide
+ # $EPREFIX/usr/include/llvm-c/lto.h as well as
+ # $EPREFIX/usr/lib/libLTO.{so,dylib}, so we just use these.
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${FILESDIR}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${FILESDIR}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${FILESDIR}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${FILESDIR}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-4.0-as.patch
+ epatch "${FILESDIR}"/${PN}-4.2-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.2.3-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-4.2-lto.patch
+ epatch "${FILESDIR}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${FILESDIR}"/${PN}-4.2-globals-extern.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+ # __darwin_i386_float_state missing on <= 10.4
+ cp -a ../${CCTOOLS_HEADERS}/include/mach/i386 include/mach
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # Provide patched version information to the tools. This is normally
+ # done by the Makefile using vers_string. As an added benefit, the
+ # build will not fail on later OS Xes where that tool doesn't exist any
+ # more.
+
+ # Those tools don't even use their version information. Just make make
+ # happy.
+ touch {ar,gprof,otool}/vers.c
+
+ # for the others defining apple_version suffices nicely although the
+ # Makefile does a lot more.
+ VER_STR="${CCTOOLS} (Gentoo ${PN}-${PVR})"
+ echo "const char apple_version[] = \"${VER_STR}\";" \
+ >> as/apple_version.c || die
+ echo "const char apple_version[] = \"${VER_STR})\";" \
+ >> misc/vers.c || die
+ # the rest we don't even build
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ CCTOOLS_LTO=
+ LD64_LTO=0
+ if use lto ; then
+ CCTOOLS_LTO="-DLTO_SUPPORT"
+ LD64_LTO=1
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ cat <<EOF > ${LD64}/src/configure.h
+#define DEFAULT_MACOSX_MIN_VERSION "${MACOSX_DEPLOYMENT_TARGET}"
+EOF
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${LD64_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${CCTOOLS_LTO}" \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="clang -ccc-install-dir $PWD" \
+ CXX="clang++ -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-4.2.ebuild b/sys-devel/binutils-apple/binutils-apple-4.2.ebuild
new file mode 100644
index 000000000000..42439672c4de
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-4.2.ebuild
@@ -0,0 +1,312 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test" # the test suite will test what's installed.
+
+LD64=ld64-127.2
+CCTOOLS=cctools-809
+LIBUNWIND=libunwind-30
+DYLD=dyld-195.5
+# http://lists.apple.com/archives/Darwin-dev/2009/Sep/msg00025.html
+UNWIND=binutils-apple-3.2-unwind-patches-5
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${UNWIND}.tar.xz
+ http://www.gentoo.org/~grobian/distfiles/libunwind-llvm-115426.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ >=sys-devel/gcc-apple-4.2.1"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-4"
+else
+ SLOT="4"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+src_prepare() {
+ cd "${S}"/${LIBUNWIND}/src
+ cp "${FILESDIR}"/${LIBUNWIND}-Makefile Makefile
+
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/ld64-123.2-Makefile Makefile
+ epatch "${FILESDIR}"/${LD64}-lto.patch
+ epatch "${FILESDIR}"/${LD64}-ppc-range-warning.patch
+
+ ln -s ../../${CCTOOLS}/include
+ cp other/prune_trie.h include/mach-o/ || die
+ # use our own copy of lto.h, which doesn't require llvm build-env
+ mkdir -p include/llvm-c || die
+ cp "${WORKDIR}"/ld64-unwind/ld64-97.14-llvm-lto.h include/llvm-c/lto.h || die
+ # make libunwind sources known
+ ln -s ../../${LIBUNWIND}/src libunwind || die
+ cp ../../${LIBUNWIND}/include/*.h include/ || die
+ # mimic OS X Lion-style Availability.h macros
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 10 ]] ; then
+ {
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) "
+ echo "#define __OSX_AVAILABLE_BUT_DEPRECATED(a,b,c,d) "
+ } > include/Availability.h
+ fi
+
+ echo '' > configure.h
+ echo '' > linker_opts
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${FILESDIR}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${FILESDIR}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ sed -i -e '/#include <mach-o\/loader.h>/a\#include <mach/i386/thread_status.h>' \
+ ld/HeaderAndLoadCommands.hpp || die
+ fi
+ if use !lto ; then
+ sed -i -e '/#define LTO_SUPPORT 1/d' other/ObjectDump.cpp || die
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-4.0-as.patch
+ epatch "${FILESDIR}"/${PN}-4.2-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.2.3-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-4.2-lto.patch
+
+ local program
+ for program in ar efitools gprof libmacho misc otool ; do
+ VER_STR="@(#)PROGRAM:${program} PROJECT:${CCTOOLS} (Gentoo ${PN}-${PVR}) DEVELOPER:${PORTAGE_ROOT_USER} BUILT:$(date)"
+ cat > ${program}/vers.c <<- _EOF
+ #include <sys/cdefs.h>
+ __IDSTRING(SGS_VERS,"${VER_STR}\n");
+ _EOF
+ [[ ${program} != "libmacho" ]] && \
+ echo '__IDSTRING(VERS_NUM,"apple");' >> ${program}/vers.c
+ done
+
+ VER_STR="${CCTOOLS} (Gentoo ${PN}-${PVR})"
+ echo "const char apple_version[] = \"${VER_STR}\";" \
+ >> as/apple_version.c || die
+ echo "const char apple_version[] = \"${VER_STR})\";" \
+ >> efitools/vers.c || die
+ echo "const char apple_version[] = \"${VER_STR})\";" \
+ >> ld/ld_vers.c || die
+ echo "const char apple_version[] = \"${VER_STR})\";" \
+ >> misc/vers.c || die
+
+ # clean up test suite
+ cd "${S}"/${LD64}
+# epatch "${FILESDIR}"/${PN}-3.1.1-testsuite.patch
+
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+src_configure() {
+ tc-export CC CXX AR
+ if use lto ; then
+ append-cppflags -DLTO_SUPPORT
+ append-ldflags -L"${EPREFIX}"/usr/$(get_libdir)/llvm
+ append-libs LTO
+ LTO=1
+ else
+ append-cppflags -ULTO_SUPPORT
+ LTO=0
+ fi
+ append-cppflags -DNDEBUG
+ append-cppflags -I"${WORKDIR}"/libunwind/include
+}
+
+compile_libunwind() {
+ # not used, just for testing, and possible use in the future
+ einfo "building ${LIBUNWIND}"
+ cd "${S}"/${LIBUNWIND}/src
+ emake DYLDINCS=-I../../${DYLD}/include || die
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ # remove antiquated copy that's available on any OSX system and
+ # breaks ld64 compilation
+ mv include/mach-o/dyld.h{,.disable}
+ emake \
+ LTO=${LTO} \
+ CFLAGS="${CFLAGS}" \
+ CXXFLAGS="${CXXFLAGS} -I../../${DYLD}/include" \
+ LDFLAGS="${LDFLAGS} ${LIBS}" \
+ || die "emake failed for ld64"
+ use test && emake build_test
+ # restore, it's necessary for cctools' install
+ mv include/mach-o/dyld.h{.disable,}
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= LTO= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= LTO= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-4.3-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-4.3-r1.ebuild
new file mode 100644
index 000000000000..5594369e4d9b
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-4.3-r1.ebuild
@@ -0,0 +1,316 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-128.2
+CCTOOLS_VERSION=822
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+CCTOOLS_HEADERS=cctools-855
+LIBUNWIND=libunwind-30
+DYLD=dyld-195.6
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS_HEADERS}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz"
+
+LICENSE="APSL-2"
+KEYWORDS="~x64-macos ~x86-macos"
+IUSE="lto test"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ || ( >=sys-devel/gcc-apple-4.2.1 sys-devel/llvm )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-4"
+else
+ SLOT="4"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+src_prepare() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/ld64-128.2-Makefile-2 Makefile
+ epatch "${FILESDIR}"/ld64-127.2-lto.patch
+ epatch "${FILESDIR}"/ld64-128.2-stdlib.patch
+ epatch "${FILESDIR}"/ld64-241.9-register-names.patch
+ epatch "${FILESDIR}"/ld64-241.9-get-comm-align.patch
+ epatch "${FILESDIR}"/ld64-241.9-cc_md5.patch
+ epatch "${FILESDIR}"/ld64-128.2-1010.patch
+
+ # We used to use our own copy of lto.h, which doesn't require llvm
+ # build-env. Current versions of llvm provide
+ # $EPREFIX/usr/include/llvm-c/lto.h as well as
+ # $EPREFIX/usr/lib/libLTO.{so,dylib}, so we just use these.
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${FILESDIR}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${FILESDIR}"/ld64-123.2-debug-backtrace.patch
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-4.0-as.patch
+ epatch "${FILESDIR}"/${PN}-4.2-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.2.3-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-4.2-lto.patch
+ epatch "${FILESDIR}"/${PN}-5.1-extraneous-includes.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+ # __darwin_i386_float_state missing on <= 10.4
+ cp -a ../${CCTOOLS_HEADERS}/include/mach/i386 include/mach
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ CCTOOLS_LTO=
+ LD64_LTO=0
+ if use lto ; then
+ CCTOOLS_LTO="-DLTO_SUPPORT"
+ LD64_LTO=1
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ cat <<EOF > ${LD64}/src/configure.h
+#define DEFAULT_MACOSX_MIN_VERSION "${MACOSX_DEPLOYMENT_TARGET}"
+EOF
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${LD64_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${CCTOOLS_LTO}" \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="clang -ccc-install-dir $PWD" \
+ CXX="clang++ -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-4.3.ebuild b/sys-devel/binutils-apple/binutils-apple-4.3.ebuild
new file mode 100644
index 000000000000..4a0809df76d9
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-4.3.ebuild
@@ -0,0 +1,309 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test" # the test suite will test what's installed.
+
+LD64=ld64-128.2
+CCTOOLS=cctools-822
+LIBUNWIND=libunwind-30
+DYLD=dyld-195.6
+# http://lists.apple.com/archives/Darwin-dev/2009/Sep/msg00025.html
+UNWIND=binutils-apple-3.2-unwind-patches-5
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${UNWIND}.tar.xz
+ http://www.gentoo.org/~grobian/distfiles/libunwind-llvm-115426.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~x64-macos ~x86-macos"
+IUSE="lto test"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ >=sys-devel/gcc-apple-4.2.1"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-4"
+else
+ SLOT="4"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+src_prepare() {
+ cd "${S}"/${LIBUNWIND}/src
+ cp "${FILESDIR}"/${LIBUNWIND}-Makefile Makefile
+
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/ld64-128.2-Makefile Makefile
+ epatch "${FILESDIR}"/ld64-127.2-lto.patch
+ epatch "${FILESDIR}"/ld64-128.2-stdlib.patch
+
+ ln -s ../../${CCTOOLS}/include
+ cp other/prune_trie.h include/mach-o/ || die
+ # use our own copy of lto.h, which doesn't require llvm build-env
+ mkdir -p include/llvm-c || die
+ cp "${WORKDIR}"/ld64-unwind/ld64-97.14-llvm-lto.h include/llvm-c/lto.h || die
+ # make libunwind sources known
+ ln -s ../../${LIBUNWIND}/src libunwind || die
+ cp ../../${LIBUNWIND}/include/*.h include/ || die
+ # mimic OS X Lion-style Availability.h macros
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 10 ]] ; then
+ {
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) "
+ echo "#define __OSX_AVAILABLE_BUT_DEPRECATED(a,b,c,d) "
+ } > include/Availability.h
+ fi
+
+ echo '' > configure.h
+ echo '' > linker_opts
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${FILESDIR}"/ld64-123.2-debug-backtrace.patch
+ if use !lto ; then
+ sed -i -e '/#define LTO_SUPPORT 1/d' other/ObjectDump.cpp || die
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-4.0-as.patch
+ epatch "${FILESDIR}"/${PN}-4.2-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.2.3-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-4.2-lto.patch
+
+ local program
+ for program in ar efitools gprof libmacho misc otool ; do
+ VER_STR="@(#)PROGRAM:${program} PROJECT:${CCTOOLS} (Gentoo ${PN}-${PVR}) DEVELOPER:${PORTAGE_ROOT_USER} BUILT:$(date)"
+ cat > ${program}/vers.c <<- _EOF
+ #include <sys/cdefs.h>
+ __IDSTRING(SGS_VERS,"${VER_STR}\n");
+ _EOF
+ [[ ${program} != "libmacho" ]] && \
+ echo '__IDSTRING(VERS_NUM,"apple");' >> ${program}/vers.c
+ done
+
+ VER_STR="${CCTOOLS} (Gentoo ${PN}-${PVR})"
+ echo "const char apple_version[] = \"${VER_STR}\";" \
+ >> as/apple_version.c || die
+ echo "const char apple_version[] = \"${VER_STR})\";" \
+ >> efitools/vers.c || die
+ echo "const char apple_version[] = \"${VER_STR})\";" \
+ >> ld/ld_vers.c || die
+ echo "const char apple_version[] = \"${VER_STR})\";" \
+ >> misc/vers.c || die
+
+ # clean up test suite
+ cd "${S}"/${LD64}
+# epatch "${FILESDIR}"/${PN}-3.1.1-testsuite.patch
+
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+src_configure() {
+ tc-export CC CXX AR
+ if use lto ; then
+ append-cppflags -DLTO_SUPPORT
+ append-ldflags -L"${EPREFIX}"/usr/$(get_libdir)/llvm
+ append-libs LTO
+ LTO=1
+ else
+ append-cppflags -ULTO_SUPPORT
+ LTO=0
+ fi
+ append-cppflags -DNDEBUG
+ append-cppflags -I"${WORKDIR}"/libunwind/include
+}
+
+compile_libunwind() {
+ # not used, just for testing, and possible use in the future
+ einfo "building ${LIBUNWIND}"
+ cd "${S}"/${LIBUNWIND}/src
+ emake DYLDINCS=-I../../${DYLD}/include || die
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ # remove antiquated copy that's available on any OSX system and
+ # breaks ld64 compilation
+ mv include/mach-o/dyld.h{,.disable}
+ emake \
+ LTO=${LTO} \
+ CFLAGS="${CFLAGS}" \
+ CXXFLAGS="${CXXFLAGS} -I../../${DYLD}/include" \
+ LDFLAGS="${LDFLAGS} ${LIBS}" \
+ || die "emake failed for ld64"
+ use test && emake build_test
+ # restore, it's necessary for cctools' install
+ mv include/mach-o/dyld.h{.disable,}
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= LTO= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= LTO= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-5.1.ebuild b/sys-devel/binutils-apple/binutils-apple-5.1.ebuild
new file mode 100644
index 000000000000..d6355c49deaf
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-5.1.ebuild
@@ -0,0 +1,356 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-236.3
+CCTOOLS_VERSION=855
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-353.2.1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz"
+
+LICENSE="APSL-2"
+KEYWORDS="~x64-macos ~x86-macos"
+IUSE="lto test libcxx"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )
+ libcxx? ( sys-libs/libcxx )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ || ( >=sys-devel/gcc-apple-4.2.1 sys-devel/llvm )
+ libcxx? ( sys-devel/llvm )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-5"
+else
+ SLOT="5"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+src_prepare() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${FILESDIR}"/ld64-236.3-Makefile Makefile
+
+ epatch "${FILESDIR}"/ld64-236.3-nolto.patch
+ epatch "${FILESDIR}"/ld64-241.9-extraneous-includes.patch
+ epatch "${FILESDIR}"/ld64-241.9-atomic-volatile.patch
+ epatch "${FILESDIR}"/ld64-236.3-arm64-fixup.patch
+ epatch "${FILESDIR}"/ld64-241.9-arm64-cputype.patch
+ epatch "${FILESDIR}"/ld64-236.3-crashreporter.patch
+ epatch "${FILESDIR}"/ld64-236.3-gcc.patch
+ epatch "${FILESDIR}"/ld64-236.3-constant-types.patch
+ epatch "${FILESDIR}"/ld64-236.3-nosnapshots.patch
+ epatch "${FILESDIR}"/ld64-236.3-noppc.patch
+ epatch "${FILESDIR}"/ld64-236.3-noarm.patch
+ epatch "${FILESDIR}"/ld64-241.9-register-names.patch
+ epatch "${FILESDIR}"/ld64-241.9-get-comm-align.patch
+ epatch "${FILESDIR}"/ld64-241.9-cc_md5.patch
+
+ # We used to use our own copy of lto.h, which doesn't require llvm
+ # build-env. Current versions of llvm provide
+ # $EPREFIX/usr/include/llvm-c/lto.h as well as
+ # $EPREFIX/usr/lib/libLTO.{so,dylib}, so we just use these.
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${FILESDIR}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${FILESDIR}"/ld64-123.2-debug-backtrace.patch
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-4.5-as.patch
+ epatch "${FILESDIR}"/${PN}-5.1-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-5.1-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-5.1-nolto.patch
+ epatch "${FILESDIR}"/cctools-839-intel-retf.patch
+ epatch "${FILESDIR}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${FILESDIR}"/${PN}-5.1-otool-stdc.patch
+ epatch "${FILESDIR}"/${PN}-5.1-constant-types.patch
+ epatch "${FILESDIR}"/${PN}-5.1-strnlen.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ CCTOOLS_LTO=
+ LD64_LTO=0
+ if use lto ; then
+ CCTOOLS_LTO="-DLTO_SUPPORT"
+ LD64_LTO=1
+ fi
+
+ if [ "${CXX/*clang*/yes}" = "yes" ] ; then
+ if use libcxx ; then
+ append-cxxflags -stdlib=libc++
+ CXXLIB=-stdlib=libc++
+ else
+ # force libstdc++ for systems where libc++ is default (OS X 10.9+?)
+ append-cxxflags -stdlib=libstdc++
+ CXXLIB=-stdlib=libstdc++
+ fi
+ else
+ use libcxx && \
+ ewarn "libcxx only available with clang and your C++ compiler ($CXX) does not seem to be clang"
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ # RC_SUPPORTED_ARCHS="i386 x86_64 x86_64h armv6 ..." can be used to
+ # override architectures (there are more arms to add) but we configure
+ # with the default to be in line with Xcode's ld.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="" \
+ ${LD64}/src/create_configure
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${LD64_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${CCTOOLS_LTO}" \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ CXXLIB="${CXXLIB}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="clang -ccc-install-dir $PWD" \
+ CXX="clang++ -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-6.1.ebuild b/sys-devel/binutils-apple/binutils-apple-6.1.ebuild
new file mode 100644
index 000000000000..7554c4e88581
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-6.1.ebuild
@@ -0,0 +1,355 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-241.9
+CCTOOLS_VERSION=862
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-353.2.1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz"
+
+LICENSE="APSL-2"
+KEYWORDS="~x64-macos ~x86-macos"
+IUSE="lto test libcxx"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )
+ libcxx? ( sys-libs/libcxx )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ || ( >=sys-devel/gcc-apple-4.2.1 sys-devel/llvm )
+ libcxx? ( sys-devel/llvm )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-6"
+else
+ SLOT="6"
+fi
+
+LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+INCPATH=${LIBPATH}/include
+DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+fi
+
+S=${WORKDIR}
+
+src_prepare() {
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${FILESDIR}"/ld64-236.3-Makefile Makefile
+
+ epatch "${FILESDIR}"/ld64-236.3-nolto.patch
+ epatch "${FILESDIR}"/ld64-241.9-extraneous-includes.patch
+ epatch "${FILESDIR}"/ld64-241.9-atomic-volatile.patch
+ epatch "${FILESDIR}"/ld64-241.9-arm64-cputype.patch
+ epatch "${FILESDIR}"/ld64-236.3-crashreporter.patch
+ epatch "${FILESDIR}"/ld64-241.9-gcc.patch
+ epatch "${FILESDIR}"/ld64-236.3-constant-types.patch
+ epatch "${FILESDIR}"/ld64-241.9-nosnapshots.patch
+ epatch "${FILESDIR}"/ld64-241.9-noarm.patch
+ epatch "${FILESDIR}"/ld64-241.9-register-names.patch
+ epatch "${FILESDIR}"/ld64-241.9-get-comm-align.patch
+ epatch "${FILESDIR}"/ld64-241.9-cc_md5.patch
+ epatch "${FILESDIR}"/ld64-241.9-lto-noremarks.patch
+
+ # We used to use our own copy of lto.h, which doesn't require llvm
+ # build-env. Current versions of llvm provide
+ # $EPREFIX/usr/include/llvm-c/lto.h as well as
+ # $EPREFIX/usr/lib/libLTO.{so,dylib}, so we just use these.
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${FILESDIR}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${FILESDIR}"/ld64-123.2-debug-backtrace.patch
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-4.5-as.patch
+ epatch "${FILESDIR}"/${PN}-5.1-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-5.1-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-5.1-nolto.patch
+ epatch "${FILESDIR}"/cctools-839-intel-retf.patch
+ epatch "${FILESDIR}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${FILESDIR}"/${PN}-5.1-otool-stdc.patch
+ epatch "${FILESDIR}"/${PN}-5.1-constant-types.patch
+ epatch "${FILESDIR}"/${PN}-5.1-strnlen.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ CCTOOLS_LTO=
+ LD64_LTO=0
+ if use lto ; then
+ CCTOOLS_LTO="-DLTO_SUPPORT"
+ LD64_LTO=1
+ fi
+
+ if [ "${CXX/*clang*/yes}" = "yes" ] ; then
+ if use libcxx ; then
+ append-cxxflags -stdlib=libc++
+ CXXLIB=-stdlib=libc++
+ else
+ # force libstdc++ for systems where libc++ is default (OS X 10.9+?)
+ append-cxxflags -stdlib=libstdc++
+ CXXLIB=-stdlib=libstdc++
+ fi
+ else
+ use libcxx && \
+ ewarn "libcxx only available with clang and your C++ compiler ($CXX) does not seem to be clang"
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ # RC_SUPPORTED_ARCHS="i386 x86_64 x86_64h armv6 ..." can be used to
+ # override architectures (there are more arms to add) but we configure
+ # with the default to be in line with Xcode's ld.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="" \
+ ${LD64}/src/create_configure
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${LD64_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${CCTOOLS_LTO}" \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ CXXLIB="${CXXLIB}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="clang -ccc-install-dir $PWD" \
+ CXX="clang++ -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/files/Makefile b/sys-devel/binutils-apple/files/Makefile
new file mode 100644
index 000000000000..9d8f92818a87
--- /dev/null
+++ b/sys-devel/binutils-apple/files/Makefile
@@ -0,0 +1,12 @@
+all: ld64 rebase
+
+build_test: machocheck ObjectDump
+
+ld64: debugline.o Options.o ld.o version.o
+ $(CXX) $(LDFLAGS) -o $@ $^
+
+machocheck: machochecker.o
+ $(CXX) $(LDFLAGS) -o $@ $^
+
+ObjectDump: ObjectDump.o debugline.o
+ $(CXX) $(LDFLAGS) -o $@ $^
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as-dir.patch
new file mode 100644
index 000000000000..8d9203e33953
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as-dir.patch
@@ -0,0 +1,69 @@
+handles the libexecdir for as and other fixes
+
+--- cctools-698/as/driver.c
++++ cctools-698/as/driver.c
+@@ -27,6 +27,9 @@
+ char **envp)
+ {
+ const char *LIB =
++#ifdef ASLIBEXECDIR
++ ASLIBEXECDIR;
++#else
+ #if defined(__OPENSTEP__) || defined(__HERA__) || \
+ defined(__GONZO_BUNSEN_BEAKER__) || defined(__KODIAK__)
+ "/usr/libexec/";
+@@ -40,6 +42,7 @@
+ #else
+ "/usr/local/libexec/gcc/darwin/";
+ #endif
++#endif
+ const char *AS = "/as";
+
+ int i;
+@@ -170,7 +170,11 @@
+ }
+
+ }
++#ifndef ASLIBEXECDIR
+ as = makestr(prefix, LIB, arch_name, AS, NULL);
++#else
++ as = makestr(LIB, arch_name, AS, NULL);
++#endif
+
+ /*
+ * If this assembler exist try to run it else print an error message.
+@@ -182,6 +182,9 @@
+ else
+ exit(1);
+ }
++#ifdef ASLIBEXECDIR
++ as_local = "";
++#else
+ as_local = makestr(prefix, LOCALLIB, arch_name, AS, NULL);
+ if(access(as_local, F_OK) == 0){
+ argv[0] = as_local;
+@@ -193,6 +198,8 @@
+ exit(1);
+ }
+ else{
++#endif
++ {
+ printf("%s: assembler (%s or %s) for architecture %s not "
+ "installed\n", progname, as, as_local, arch_name);
+ arch_flags = get_arch_flags();
+@@ -183,6 +190,7 @@
+ printf("%s for architecture %s\n", as, arch_flags[i].name);
+ count++;
+ }
++#ifndef ASLIBEXECDIR
+ else{
+ as_local = makestr(LOCALLIB, arch_flags[i].name, AS, NULL);
+ if(access(as_local, F_OK) == 0){
+@@ -193,6 +201,7 @@
+ count++;
+ }
+ }
++#endif
+ }
+ if(count == 0)
+ printf("%s: no assemblers installed\n", progname);
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as.patch
new file mode 100644
index 000000000000..c0cff44550db
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-as.patch
@@ -0,0 +1,98 @@
+make building for obsolete architectures optional.
+
+--- cctools-698/as/Makefile
++++ cctools-698/as/Makefile
+@@ -1,3 +1,4 @@
++BUILD_OBSOLETE_ARCH = yes
+ RC_OS = macos
+ export USE_APPLE_PB_SUPPORT = all
+ OFLAG = -Os
+@@ -31,26 +32,34 @@
+ SYMROOT = .
+ OBJROOT = .
+ SYM_DIRS = $(SYMROOT)/driver_dir \
+- $(SYMROOT)/a68_dir \
+- $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a386_dir \
+ $(SYMROOT)/ax86_64_dir \
+ $(SYMROOT)/appc_dir \
+- $(SYMROOT)/appc64_dir \
++ $(SYMROOT)/appc64_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++SYM_DIRS += \
++ $(SYMROOT)/a68_dir \
++ $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a860_dir \
+ $(SYMROOT)/ahppa_dir \
+ $(SYMROOT)/asparc_dir
++endif
+
+ OFILE_DIRS = $(OBJROOT)/driver_dir \
+- $(OBJROOT)/a68_dir \
+- $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a386_dir \
+ $(OBJROOT)/ax86_64_dir \
+ $(OBJROOT)/appc_dir \
+- $(OBJROOT)/appc64_dir \
++ $(OBJROOT)/appc64_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++OFILE_DIRS += \
++ $(OBJROOT)/a68_dir \
++ $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a860_dir \
+ $(OBJROOT)/ahppa_dir \
+ $(OBJROOT)/asparc_dir
++endif
+
+ BINDIR = /bin
+ USRBINDIR = /usr/bin
+@@ -109,9 +118,13 @@
+ OBJS_hppa = $(CFILES_hppa:.c=.o)
+ OBJS_sparc = $(CFILES_sparc:.c=.o)
+
+-all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a68_build a88_build a386_build \
+- ax86_64_build a860_build appc_build appc64_build ahppa_build \
+- $(A_BUILD) asparc_build
++all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a386_build \
++ ax86_64_build appc_build appc64_build \
++ $(A_BUILD)
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++all: a68_build a88_build a860_build ahppa_build asparc_build
++endif
+
+ all_test: a68_test a88_test a860_test a386_test appc_test ahppa_test
+
+@@ -414,12 +427,14 @@
+ $(MKDIRS) $(DSTROOT)$(LIBDIR)/ppc64
+ install -c -s -m 555 $(SYMROOT)/appc64_dir/as \
+ $(DSTROOT)$(LIBDIR)/ppc64/as
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m68k
+ install -c -s -m 555 $(SYMROOT)/a68_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m68k/as
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/sparc
+ install -c -s -m 555 $(SYMROOT)/asparc_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/sparc/as
++endif
+
+ nextstep_install: common_install
+ $(MKDIRS) $(DSTROOT)$(BINDIR)
+@@ -439,6 +454,7 @@
+ $(DSTROOT)$(LOCLIBDIR)/ppc/as
+
+ common_install:
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m88k
+ install -c -s -m 555 $(SYMROOT)/a88_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m88k/as
+@@ -448,6 +464,7 @@
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/i860
+ install -s -m 555 $(SYMROOT)/a860_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/i860/as
++endif
+
+ $(OFILE_DIRS) $(SYM_DIRS):
+ $(MKDIRS) $@
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-libtool-ranlib.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-libtool-ranlib.patch
new file mode 100644
index 000000000000..fc86ddea118a
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-libtool-ranlib.patch
@@ -0,0 +1,17 @@
+match "ranlib" at the back of the string, such that <CHOST>-ranlib also
+works correctly
+
+--- cctools-698/misc/libtool.c
++++ cctools-698/misc/libtool.c
+@@ -336,8 +336,9 @@
+ p++;
+ else
+ p = argv[0];
+- if(strncmp(p, "ranlib", sizeof("ranlib") - 1) == 0)
+- cmd_flags.ranlib = TRUE;
++ if ((i = strlen(p)) >= sizeof("ranlib") - 1 &&
++ strcmp(p + (i - (sizeof("ranlib") - 1)), "ranlib") == 0)
++ cmd_flags.ranlib = TRUE;
+
+ /* The default is to used long names */
+ cmd_flags.use_long_names = TRUE;
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-nmedit.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-nmedit.patch
new file mode 100644
index 000000000000..3b14e3dd4e69
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-nmedit.patch
@@ -0,0 +1,15 @@
+don't create a symlink to nmedit from the dir nmedit is in
+
+--- cctools-698/misc/Makefile
++++ cctools-698/misc/Makefile
+@@ -427,8 +427,10 @@
+ install -c -s -m 555 $(SYMROOT)/redo_prebinding.NEW \
+ $(DSTROOT)$(USRBINDIR)/redo_prebinding
+ install -c -s -m 555 $(SYMROOT)/nmedit.NEW $(DSTROOT)$(USRBINDIR)/nmedit
++ifneq "$(USRBINDIR)" "$(LOCBINDIR)"
+ (cd $(DSTROOT)$(LOCBINDIR); rm -f nmedit; \
+ ln -s $(USRBINDIR)/nmedit nmedit)
++endif
+ install -c -s -m 555 $(SYMROOT)/install_name_tool.NEW \
+ $(DSTROOT)$(USRBINDIR)/install_name_tool
+ install -c -s -m 555 $(SYMROOT)/codesign_allocate.NEW \
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-efi-man.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-efi-man.patch
new file mode 100644
index 000000000000..978f1aba9aee
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-efi-man.patch
@@ -0,0 +1,38 @@
+don't install efi's manpages since we don't install efi
+
+--- cctools-698/man/Makefile
++++ cctools-698/man/Makefile
+@@ -27,14 +27,21 @@
+ MANL3 = libsyminfo.3 redo_prebinding.3
+
+ INSTALL_FILES = Makefile $(COMMON_MAN1) $(OTHER_MAN1) $(MAN3) $(MAN5) $(MANL) \
+- $(MANL3) $(DYLD_MAN1) $(DYLD_MAN3) $(DYLD_MANL3) $(EFI1) notes
++ $(MANL3) $(DYLD_MAN1) $(DYLD_MAN3) $(DYLD_MANL3) notes
++
++ifeq "$(EFITOOLS)" "efitools"
++ INSTALL_FILES += $(EFI1)
++endif
+
+ MANDIR = /usr/share/man
+ LOCMANDIR = /usr/local/man
+ EFIMANDIR = /usr/local/efi/share/man
+ DSTDIRS = $(DSTROOT)$(MANDIR)/man1 $(DSTROOT)$(MANDIR)/man3 \
+ $(DSTROOT)$(MANDIR)/man5 $(DSTROOT)$(LOCMANDIR)/man1 \
+- $(DSTROOT)$(LOCMANDIR)/man3 $(DSTROOT)$(EFIMANDIR)/man1
++ $(DSTROOT)$(LOCMANDIR)/man3
++ifeq "$(EFITOOLS)" "efitools"
++ DSTDIR += $(DSTROOT)$(EFIMANDIR)/man1
++endif
+
+ install: $(DSTDIRS) $(COMMON_MAN1) $(OTHER_MAN1) $(MAN3) $(MAN5) $(MANL) \
+ $(RC_OS) $(MANL3)
+@@ -51,7 +58,9 @@
+ install -c -m 444 $(MAN5) $(DSTROOT)$(MANDIR)/man5
+ install -c -m 444 $(MANL) $(DSTROOT)$(LOCMANDIR)/man1
+ install -c -m 444 $(MANL3) $(DSTROOT)$(LOCMANDIR)/man3
++ifeq "$(EFITOOLS)" "efitools"
+ install -c -m 444 $(EFI1) $(DSTROOT)$(EFIMANDIR)/man1
++endif
+ if [ $(OLD_DYLD_STUFF) ]; \
+ then \
+ install -c -m 444 $(DYLD_MANL3) $(DSTROOT)$(LOCMANDIR)/man3;\
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-headers.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-headers.patch
new file mode 100644
index 000000000000..098a95fb0de5
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-headers.patch
@@ -0,0 +1,15 @@
+get rid of libraries, includes, and obsolete manpages
+
+--- cctools-698/Makefile
++++ cctools-698/Makefile
+@@ -170,7 +170,9 @@
+ DSTROOT=$$DSTROOT install_tools lib_ofiles_install; \
+ fi
+
+-install_tools: installhdrs
++install_tools: installhdrs install_all_but_headers
++
++install_all_but_headers:
+ @if [ $(SRCROOT) ]; \
+ then \
+ CWD=`pwd`; cd "$(DSTROOT)"; DSTROOT=`pwd`; cd "$$CWD"; \
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-oss-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-oss-dir.patch
new file mode 100644
index 000000000000..5ed823752357
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-no-oss-dir.patch
@@ -0,0 +1,17 @@
+don't create an OpenSource dir
+
+--- cctools-698/as/Makefile
++++ cctools-698/as/Makefile
+@@ -408,12 +408,6 @@
+ $(MKDIRS) $(DSTROOT)$(USRBINDIR)
+ install -c -s -m 555 $(SYMROOT)/driver_dir/driver \
+ $(DSTROOT)$(USRBINDIR)/as
+- $(MKDIRS) $(DSTROOT)/usr/local/OpenSourceVersions/
+- install -c -s -m 444 $(SRCROOT)/cctools.plist \
+- $(DSTROOT)/usr/local/OpenSourceVersions/cctools.plist
+- $(MKDIRS) $(DSTROOT)/usr/local/OpenSourceLicenses/
+- install -c -s -m 444 $(SRCROOT)/COPYING \
+- $(DSTROOT)/usr/local/OpenSourceLicenses/cctools.txt
+ $(MKDIRS) $(DSTROOT)$(LIBDIR)/ppc
+ install -c -s -m 555 $(SYMROOT)/appc_dir/as \
+ $(DSTROOT)$(LIBDIR)/ppc/as
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-ranlib.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-ranlib.patch
new file mode 100644
index 000000000000..94865fb126dd
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-ranlib.patch
@@ -0,0 +1,53 @@
+run ranlib before installation so we needn't touch permissions
+
+--- cctools-698/libmacho/Makefile
++++ cctools-698/libmacho/Makefile
+@@ -316,29 +316,29 @@
+ $(MKDIRS) $(DSTROOT)$(SYSTEMDIR)
+ if [ $(SRCROOT) = . ]; \
+ then \
++ ranlib dtmp_obj/libmacho.a; \
+ install -c -m 444 dtmp_obj/libmacho.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho.a; \
+ (cd $(DSTROOT)$(SYSTEMDIR) ; \
+ rm -f libmacho_debug.a ; ln -s libmacho.a libmacho_debug.a); \
++ ranlib ptmp_obj/libmacho_pg.a; \
+ install -c -m 444 ptmp_obj/libmacho_pg.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho_profile.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho_profile.a; \
++ ranlib otmp_obj/libmacho_static.a; \
+ install -c -m 444 otmp_obj/libmacho_static.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho_static.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho_static.a; \
+ else \
++ ranlib $(SYMROOT)/libmacho.a; \
+ install -c -m 444 $(SYMROOT)/libmacho.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho.a; \
+ (cd $(DSTROOT)$(SYSTEMDIR) ; \
+ rm -f libmacho_debug.a ; ln -s libmacho.a libmacho_debug.a); \
++ ranlib $(SYMROOT)/libmacho_pg.a; \
+ install -c -m 444 $(SYMROOT)/libmacho_pg.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho_profile.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho_profile.a; \
++ ranlib $(SYMROOT)/libmacho_static.a; \
+ install -c -m 444 $(SYMROOT)/libmacho_static.a \
+ $(DSTROOT)$(SYSTEMDIR)/libmacho_static.a; \
+- ranlib $(DSTROOT)$(SYSTEMDIR)/libmacho_static.a; \
+ fi
+
+ teflon_lib_ofiles_install nextstep_lib_ofiles_install:
+--- cctools-698/cbtlibs/Makefile
++++ cctools-698/cbtlibs/Makefile
+@@ -80,9 +80,9 @@
+
+ lib_ofiles_install: lib_ofiles
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)
++ ranlib $(SYMROOT)/libsyminfo.a
+ install -p -c -m 444 $(SYMROOT)/libsyminfo.a \
+ $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+- ranlib $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+
+ -include $(OFILE_DIR)/Makedep
+
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.1-testsuite.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-testsuite.patch
new file mode 100644
index 000000000000..b3913262db26
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.1-testsuite.patch
@@ -0,0 +1,102 @@
+fix the test suite so it is even usable
+
+--- ld64-85.2.2/unit-tests/test-cases/commons-alignment/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/commons-alignment/Makefile
+@@ -29,9 +29,9 @@
+
+ all:
+ ${CC} ${CCFLAGS} foo.s -c -o foo.o
+- nm -m foo.o | grep '(alignment 2^6)' | ${FAIL_IF_EMPTY}
++ nm -m foo.o | fgrep '(alignment 2^6)' | ${FAIL_IF_EMPTY}
+ ${LD} foo.o -r -o foo2.o
+- nm -m foo2.o | grep '(alignment 2^6)' | ${PASS_IFF_STDIN}
++ nm -m foo2.o | fgrep '(alignment 2^6)' | ${PASS_IFF_STDIN}
+
+ clean:
+ rm -rf foo.o foo2.o
+--- ld64-85.2.2/unit-tests/test-cases/order_file/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/order_file/Makefile
+@@ -33,7 +33,7 @@
+ run: all
+
+ all:
+- as -arch ${ARCH} -L extra.s -o extra.o
++ as -L extra.s -o extra.o
+ ${CC} ${CCFLAGS} main.c extra.o -o main1 -Wl,-order_file -Wl,main1.order
+ ${FAIL_IF_BAD_MACHO} main1
+ nm -n -g -j main1 | grep "_main" > main1.nm
+@@ -44,7 +44,7 @@
+ nm -n -j main2 | egrep '^_[a-z]+[0-9]$$' > main2.nm
+ ${PASS_IFF} diff main2.nm main2.expected
+
+- ${CC} -arch ${ARCH} -c main.c -o main.o
++ ${CC} -c main.c -o main.o
+ ${CC} ${CCFLAGS} main.o extra.o -o main3 -Wl,-order_file -Wl,main3.order
+ ${FAIL_IF_BAD_MACHO} main3
+ nm -n -g -j main3 | grep "_main" > main3.nm
+--- ld64-85.2.2/unit-tests/test-cases/16-byte-alignment/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/16-byte-alignment/Makefile
+@@ -30,13 +30,13 @@
+ run: all
+
+ all:
+- ${FAIL_IF_ERROR} ${CC} ${CCFLAGS} -arch ${ARCH} -c -O2 tl_test2.c -o tl_test2-${ARCH}.o
++ ${FAIL_IF_ERROR} ${CC} ${CCFLAGS} -c -O2 tl_test2.c -o tl_test2-${ARCH}.o
+
+ # verify that the alignment is correct in the .o
+ ObjectDump -only _ai -align -no_content tl_test2-${ARCH}.o|${FAIL_IF_ERROR} grep '\<0 mod 16\>' >/dev/null
+
+ # now verify the executable
+- ${FAIL_IF_ERROR} ${CC} ${CCFLAGS} -arch ${ARCH} -O2 tl_test2-${ARCH}.o -o tl_test2-${ARCH}
++ ${FAIL_IF_ERROR} ${CC} ${CCFLAGS} -O2 tl_test2-${ARCH}.o -o tl_test2-${ARCH}
+ ${FAIL_IF_ERROR} sh -c "nm tl_test2-${ARCH}|grep '0 D _ai\>' >/dev/null"
+ ${PASS_IFF_GOOD_MACHO} tl_test2-${ARCH}
+
+--- ld64-85.2.2/unit-tests/test-cases/eh-strip-test/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/eh-strip-test/Makefile
+@@ -27,7 +27,7 @@
+
+
+ all:
+- ${FAIL_IF_ERROR} $(CXX) main.cxx -arch ${ARCH} -o main
++ ${FAIL_IF_ERROR} $(CXX) main.cxx -o main
+ ${FAIL_IF_ERROR} nm -j main | grep '\.eh$$'| ${FAIL_IF_STDIN}
+ ${PASS_IFF_GOOD_MACHO} main
+ clean:
+--- ld64-85.2.2/unit-tests/test-cases/strip-test2/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/strip-test2/Makefile
+@@ -50,10 +50,10 @@
+
+
+ all:
+- $(CXX) main.cxx -arch ${ARCH} -o main
++ $(CXX) main.cxx -o main
+ ${FAIL_IF_BAD_MACHO} main
+ ${FAIL_IF_ERROR} nm -j main >main-no-strip.nm
+- $(CXX) main.cxx -arch ${ARCH} -o main
++ $(CXX) main.cxx -o main
+ ${FAIL_IF_BAD_MACHO} main
+
+ # Make sure there are no symbols in the stripped file that aren't
+--- ld64-85.2.2/unit-tests/test-cases/literals-coalesce/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/literals-coalesce/Makefile
+@@ -32,7 +32,7 @@
+
+ all:
+ ${CC} ${ASMFLAGS} literals.s -c -o literals-${ARCH}.o
+- ${FAIL_IF_ERROR} ${OBJECTDUMP} literals-${ARCH}.o | grep 'name:'| uniq -c | grep -v '^ [1|2]' | ${FAIL_IF_STDIN}
++ ${FAIL_IF_ERROR} ${OBJECTDUMP} literals-${ARCH}.o | grep 'name:'| uniq -c | grep -v '^ *[1|2]' | ${FAIL_IF_STDIN}
+ ${LD} -arch ${ARCH} -r literals-${ARCH}.o -o literals-r-${ARCH}.o
+ ${FAIL_IF_ERROR} ${OBJECTDUMP} literals-r-${ARCH}.o | grep 'name:' | uniq -d | ${PASS_IFF_EMPTY}
+
+--- ld64-85.2.2/unit-tests/test-cases/stabs-coalesce/Makefile
++++ ld64-85.2.2/unit-tests/test-cases/stabs-coalesce/Makefile
+@@ -38,7 +38,7 @@
+ ${FAIL_IF_BAD_MACHO} stabs-hello-${ARCH}
+ nm -ap stabs-hello-${ARCH} | grep FUN | grep _Z3fooi | wc -l > stabs-hello-foo-count
+ echo " 1" > one
+- ${PASS_IFF} diff stabs-hello-foo-count one
++ ${PASS_IFF} diff -w stabs-hello-foo-count one
+
+ hello.o : hello.cxx
+ ${CXX} ${CCXXFLAGS} -gstabs+ -gused hello.cxx -c -o $@
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.1.2-as-Makefile.patch b/sys-devel/binutils-apple/files/binutils-apple-3.1.2-as-Makefile.patch
new file mode 100644
index 000000000000..554fed1cbe39
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.1.2-as-Makefile.patch
@@ -0,0 +1,11 @@
+--- as/Makefile
++++ as/Makefile
+@@ -343,7 +343,7 @@
+ makeUser.o $(LIBSTUFF_DIR) $(LIBSTUFF)
+ $(CC) $(CFLAGS) $(RC_CFLAGS) -o $(SYMROOT)/as $(SYMROOT)/as.private.o
+
+-makeUser.c messages.c: make.h
++makeUser.c ../messages.c: make.h
+
+ make.h makeUser.c: make.defs
+ $(MIG) $(MIG_FLAGS) $(SRCROOT)/make.defs
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.2-armv7-defines.patch b/sys-devel/binutils-apple/files/binutils-apple-3.2-armv7-defines.patch
new file mode 100644
index 000000000000..d89a0c19f2c6
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.2-armv7-defines.patch
@@ -0,0 +1,10 @@
+--- cctools/include/mach/machine.h
++++ cctools/include/mach/machine.h
+@@ -306,6 +306,7 @@
+ #define CPU_SUBTYPE_ARM_V6 ((cpu_subtype_t) 6)
+ #define CPU_SUBTYPE_ARM_V5TEJ ((cpu_subtype_t) 7)
+ #define CPU_SUBTYPE_ARM_XSCALE ((cpu_subtype_t) 8)
++#define CPU_SUBTYPE_ARM_V7 ((cpu_subtype_t) 9)
+
+ /*
+ * MC88000 subtypes
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.2.2-as.patch b/sys-devel/binutils-apple/files/binutils-apple-3.2.2-as.patch
new file mode 100644
index 000000000000..f032e1b5571d
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.2.2-as.patch
@@ -0,0 +1,101 @@
+make building for obsolete architectures optional.
+
+--- as/Makefile
++++ as/Makefile
+@@ -1,3 +1,4 @@
++BUILD_OBSOLETE_ARCH = yes
+ RC_OS = macos
+ export USE_APPLE_PB_SUPPORT = all
+ OFLAG =
+@@ -32,28 +33,36 @@
+ SYMROOT = .
+ OBJROOT = .
+ SYM_DIRS = $(SYMROOT)/driver_dir \
+- $(SYMROOT)/a68_dir \
+- $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a386_dir \
+ $(SYMROOT)/ax86_64_dir \
+ $(SYMROOT)/appc_dir \
+ $(SYMROOT)/appc64_dir \
++ $(SYMROOT)/aarm_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++SYM_DIRS += \
++ $(SYMROOT)/a68_dir \
++ $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a860_dir \
+ $(SYMROOT)/ahppa_dir \
+- $(SYMROOT)/asparc_dir \
+- $(SYMROOT)/aarm_dir
++ $(SYMROOT)/asparc_dir
++endif
+
+ OFILE_DIRS = $(OBJROOT)/driver_dir \
+- $(OBJROOT)/a68_dir \
+- $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a386_dir \
+ $(OBJROOT)/ax86_64_dir \
+ $(OBJROOT)/appc_dir \
+ $(OBJROOT)/appc64_dir \
++ $(OBJROOT)/aarm_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++OFILE_DIRS += \
++ $(OBJROOT)/a68_dir \
++ $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a860_dir \
+ $(OBJROOT)/ahppa_dir \
+- $(OBJROOT)/asparc_dir \
+- $(OBJROOT)/aarm_dir
++ $(OBJROOT)/asparc_dir
++endif
+
+ BINDIR = /bin
+ USRBINDIR = /usr/bin
+@@ -115,9 +124,12 @@
+ OBJS_sparc = $(CFILES_sparc:.c=.o)
+ OBJS_arm = $(CFILES_arm:.c=.o)
+
+-all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a68_build a88_build a386_build \
+- ax86_64_build a860_build appc_build appc64_build ahppa_build \
+- aarm_build asparc_build
++all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a386_build \
++ ax86_64_build appc_build appc64_build aarm_build
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++all: a68_build a88_build a860_build ahppa_build asparc_build
++endif
+
+ all_test: a68_test a88_test a860_test a386_test appc_test ahppa_test
+
+@@ -429,12 +441,14 @@
+ $(MKDIRS) $(DSTROOT)$(LIBDIR)/ppc64
+ install -c -s -m 555 $(SYMROOT)/appc64_dir/as \
+ $(DSTROOT)$(LIBDIR)/ppc64/as
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m68k
+ install -c -s -m 555 $(SYMROOT)/a68_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m68k/as
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/sparc
+ install -c -s -m 555 $(SYMROOT)/asparc_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/sparc/as
++endif
+ $(MKDIRS) $(DSTROOT)$(LIBDIR)/arm
+ install -c -s -m 555 $(SYMROOT)/aarm_dir/as \
+ $(DSTROOT)$(LIBDIR)/arm/as
+@@ -457,6 +471,7 @@
+ $(DSTROOT)$(LOCLIBDIR)/ppc/as
+
+ common_install:
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m88k
+ install -s -m 555 $(SYMROOT)/a88_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m88k/as
+@@ -466,6 +481,7 @@
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/i860
+ install -s -m 555 $(SYMROOT)/a860_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/i860/as
++endif
+
+ $(OFILE_DIRS) $(SYM_DIRS):
+ $(MKDIRS) $@
diff --git a/sys-devel/binutils-apple/files/binutils-apple-3.2.3-ranlib.patch b/sys-devel/binutils-apple/files/binutils-apple-3.2.3-ranlib.patch
new file mode 100644
index 000000000000..e5292746eadf
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-3.2.3-ranlib.patch
@@ -0,0 +1,59 @@
+run ranlib before installation so we needn't touch permissions
+
+--- cctools-782/cbtlibs/Makefile 2009-12-16 20:34:18.000000000 +0100
++++ cctools-782/cbtlibs/Makefile.new 2010-07-30 20:08:22.000000000 +0200
+@@ -84,9 +84,9 @@ libsyminfo.a: libsyminfo.o
+
+ lib_ofiles_install: lib_ofiles
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)
++ ranlib $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+ install -p -c -m 444 $(SYMROOT)/libsyminfo.a \
+ $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+- ranlib $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+
+ -include $(OFILE_DIR)/Makedep
+
+--- cctools-782/libmacho/Makefile 2010-03-30 00:57:21.000000000 +0200
++++ cctools-782/libmacho/Makefile.new 2010-07-30 20:07:57.000000000 +0200
+@@ -357,17 +357,17 @@ macos_lib_ofiles_install: all
+ $(MKDIRS) $(DSTROOT)$(ARCHIVEDIR) $(DSTROOT)$(DYLIBDIR)
+ if [ $(SRCROOT) = . ]; \
+ then \
++ ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho.a; \
+ install -c -m 444 dtmp_obj/libmacho.a \
+ $(DSTROOT)$(ARCHIVEDIR)/libmacho.a; \
+- ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho.a; \
+ (cd $(DSTROOT)$(ARCHIVEDIR) ; \
+ rm -f libmacho_debug.a ; ln -s libmacho.a libmacho_debug.a); \
++ ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho_profile.a; \
+ install -c -m 444 ptmp_obj/libmacho_pg.a \
+ $(DSTROOT)$(ARCHIVEDIR)/libmacho_profile.a; \
+- ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho_profile.a; \
++ ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho_static.a; \
+ install -c -m 444 otmp_obj/libmacho_static.a \
+ $(DSTROOT)$(ARCHIVEDIR)/libmacho_static.a; \
+- ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho_static.a; \
+ install -c -m 555 dtmp_obj/libmacho.dylib \
+ $(DSTROOT)$(DYLIBDIR)/libmacho.dylib; \
+ strip -S $(DSTROOT)$(DYLIBDIR)/libmacho.dylib; \
+@@ -378,17 +378,17 @@ macos_lib_ofiles_install: all
+ $(DSTROOT)$(DYLIBDIR)/libmacho_debug.dylib; \
+ strip -S $(DSTROOT)$(DYLIBDIR)/libmacho_debug.dylib; \
+ else \
++ ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho.a; \
+ install -c -m 444 $(SYMROOT)/libmacho.a \
+ $(DSTROOT)$(ARCHIVEDIR)/libmacho.a; \
+- ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho.a; \
+ (cd $(DSTROOT)$(ARCHIVEDIR) ; \
+ rm -f libmacho_debug.a ; ln -s libmacho.a libmacho_debug.a); \
++ ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho_profile.a; \
+ install -c -m 444 $(SYMROOT)/libmacho_pg.a \
+ $(DSTROOT)$(ARCHIVEDIR)/libmacho_profile.a; \
+- ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho_profile.a; \
++ ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho_static.a; \
+ install -c -m 444 $(SYMROOT)/libmacho_static.a \
+ $(DSTROOT)$(ARCHIVEDIR)/libmacho_static.a; \
+- ranlib $(DSTROOT)$(ARCHIVEDIR)/libmacho_static.a; \
+ install -c -m 555 $(SYMROOT)/libmacho.dylib \
+ $(DSTROOT)$(DYLIBDIR)/libmacho.dylib; \
+ strip -S $(DSTROOT)$(DYLIBDIR)/libmacho.dylib; \
diff --git a/sys-devel/binutils-apple/files/binutils-apple-4.0-as-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-4.0-as-dir.patch
new file mode 100644
index 000000000000..0a6664ce1633
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.0-as-dir.patch
@@ -0,0 +1,67 @@
+--- as/driver.c
++++ as/driver.c
+@@ -28,6 +28,9 @@
+ char **envp)
+ {
+ const char *LIB =
++#ifdef ASLIBEXECDIR
++ ASLIBEXECDIR;
++#else
+ #if defined(__OPENSTEP__) || defined(__HERA__) || \
+ defined(__GONZO_BUNSEN_BEAKER__) || defined(__KODIAK__)
+ "../libexec/";
+@@ -41,6 +44,7 @@
+ #else
+ "../local/libexec/gcc/darwin/";
+ #endif
++#endif
+ const char *AS = "/as";
+ const char *LLVM_MC = "llvm-mc";
+
+@@ -240,7 +244,11 @@
+
+ }
+
++#ifndef ASLIBEXECDIR
+ as = makestr(prefix, LIB, arch_name, AS, NULL);
++#else
++ as = makestr(LIB, arch_name, AS, NULL);
++#endif
+
+ /*
+ * If this assembler exist try to run it else print an error message.
+@@ -252,6 +260,10 @@
+ else
+ exit(1);
+ }
++#ifdef ASLIBEXECDIR
++ as_local = "";
++ {
++#else
+ as_local = makestr(prefix, LOCALLIB, arch_name, AS, NULL);
+ if(access(as_local, F_OK) == 0){
+ argv[0] = as_local;
+@@ -261,6 +273,7 @@
+ exit(1);
+ }
+ else{
++#endif
+ printf("%s: assembler (%s or %s) for architecture %s not "
+ "installed\n", progname, as, as_local, arch_name);
+ arch_flags = get_arch_flags();
+@@ -273,6 +286,7 @@
+ printf("%s for architecture %s\n", as, arch_flags[i].name);
+ count++;
+ }
++#ifndef ASLIBEXECDIR
+ else{
+ as_local = makestr(prefix, LOCALLIB, arch_flags[i].name,
+ AS, NULL);
+@@ -284,6 +298,7 @@
+ count++;
+ }
+ }
++#endif
+ }
+ if(count == 0)
+ printf("%s: no assemblers installed\n", progname);
diff --git a/sys-devel/binutils-apple/files/binutils-apple-4.0-as.patch b/sys-devel/binutils-apple/files/binutils-apple-4.0-as.patch
new file mode 100644
index 000000000000..8df58775d650
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.0-as.patch
@@ -0,0 +1,99 @@
+--- as/Makefile
++++ as/Makefile
+@@ -1,3 +1,4 @@
++BUILD_OBSOLETE_ARCH = yes
+ RC_OS = macos
+ export USE_APPLE_PB_SUPPORT = all
+ OFLAG = -Os
+@@ -32,28 +33,36 @@
+ SYMROOT = .
+ OBJROOT = .
+ SYM_DIRS = $(SYMROOT)/driver_dir \
+- $(SYMROOT)/a68_dir \
+- $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a386_dir \
+ $(SYMROOT)/ax86_64_dir \
+ $(SYMROOT)/appc_dir \
+ $(SYMROOT)/appc64_dir \
++ $(SYMROOT)/aarm_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++SYM_DIRS += \
++ $(SYMROOT)/a68_dir \
++ $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a860_dir \
+ $(SYMROOT)/ahppa_dir \
+- $(SYMROOT)/asparc_dir \
+- $(SYMROOT)/aarm_dir
++ $(SYMROOT)/asparc_dir
++endif
+
+ OFILE_DIRS = $(OBJROOT)/driver_dir \
+- $(OBJROOT)/a68_dir \
+- $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a386_dir \
+ $(OBJROOT)/ax86_64_dir \
+ $(OBJROOT)/appc_dir \
+ $(OBJROOT)/appc64_dir \
++ $(OBJROOT)/aarm_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++OFILE_DIRS += \
++ $(OBJROOT)/a68_dir \
++ $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a860_dir \
+ $(OBJROOT)/ahppa_dir \
+- $(OBJROOT)/asparc_dir \
+- $(OBJROOT)/aarm_dir
++ $(OBJROOT)/asparc_dir
++endif
+
+ BINDIR = /bin
+ USRBINDIR = /usr/bin
+@@ -115,9 +124,12 @@
+ OBJS_sparc = $(CFILES_sparc:.c=.o)
+ OBJS_arm = $(CFILES_arm:.c=.o)
+
+-all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a68_build a88_build a386_build \
+- ax86_64_build a860_build appc_build appc64_build ahppa_build \
+- aarm_build asparc_build
++all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a386_build \
++ ax86_64_build appc_build appc64_build aarm_build
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++all: a68_build a88_build a860_build ahppa_build asparc_build
++endif
+
+ all_test: a68_test a88_test a860_test a386_test appc_test ahppa_test
+
+@@ -452,12 +464,14 @@
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/ppc64
+ install -c -s -m 555 $(SYMROOT)/appc64_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/ppc64/as
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m68k
+ install -c -s -m 555 $(SYMROOT)/a68_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m68k/as
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/sparc
+ install -c -s -m 555 $(SYMROOT)/asparc_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/sparc/as
++endif
+ $(MKDIRS) $(DSTROOT)$(LIBDIR)/arm
+ install -c -s -m 555 $(SYMROOT)/aarm_dir/as \
+ $(DSTROOT)$(LIBDIR)/arm/as
+@@ -480,6 +494,7 @@
+ $(DSTROOT)$(LOCLIBDIR)/ppc/as
+
+ common_install:
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m88k
+ install -c -s -m 555 $(SYMROOT)/a88_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m88k/as
+@@ -489,6 +504,7 @@
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/i860
+ install -s -m 555 $(SYMROOT)/a860_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/i860/as
++endif
+
+ $(OFILE_DIRS) $(SYM_DIRS):
+ $(MKDIRS) $@
diff --git a/sys-devel/binutils-apple/files/binutils-apple-4.0-no-oss-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-4.0-no-oss-dir.patch
new file mode 100644
index 000000000000..fcce015e1980
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.0-no-oss-dir.patch
@@ -0,0 +1,15 @@
+--- as/Makefile
++++ as/Makefile
+@@ -452,12 +452,6 @@
+ $(MKDIRS) $(DSTROOT)$(USRBINDIR)
+ install -c -s -m 555 $(SYMROOT)/driver_dir/driver \
+ $(DSTROOT)$(USRBINDIR)/as
+- $(MKDIRS) $(DSTROOT)/usr/local/OpenSourceVersions/
+- install -c -s -m 444 $(SRCROOT)/cctools.plist \
+- $(DSTROOT)/usr/local/OpenSourceVersions/cctools.plist
+- $(MKDIRS) $(DSTROOT)/usr/local/OpenSourceLicenses/
+- install -c -s -m 444 $(SRCROOT)/COPYING \
+- $(DSTROOT)/usr/local/OpenSourceLicenses/cctools.txt
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/ppc
+ install -c -s -m 555 $(SYMROOT)/appc_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/ppc/as
diff --git a/sys-devel/binutils-apple/files/binutils-apple-4.2-as-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-4.2-as-dir.patch
new file mode 100644
index 000000000000..b3047f6215fd
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.2-as-dir.patch
@@ -0,0 +1,45 @@
+--- as/driver.c
++++ as/driver.c
+@@ -230,7 +230,11 @@
+ /*
+ * If this assembler exist try to run it else print an error message.
+ */
++#ifndef ASLIBEXECDIR
+ as = makestr(prefix, LIB, arch_name, AS, NULL);
++#else
++ as = makestr(ASLIBEXECDIR, arch_name, AS, NULL);
++#endif
+ if(access(as, F_OK) == 0){
+ argv[0] = as;
+ if(execute(argv, verbose))
+@@ -238,6 +242,9 @@
+ else
+ exit(1);
+ }
++#ifdef ASLIBEXECDIR
++ as_local = "";
++#else
+ as_local = makestr(prefix, LOCALLIB, arch_name, AS, NULL);
+ if(access(as_local, F_OK) == 0){
+ argv[0] = as_local;
+@@ -246,10 +253,12 @@
+ else
+ exit(1);
+ }
++#endif
+ printf("%s: assembler (%s or %s) for architecture %s not installed\n",
+ progname, as, as_local, arch_name);
+ arch_flags = get_arch_flags();
+ count = 0;
++#ifndef ASLIBEXECDIR
+ for(i = 0; arch_flags[i].name != NULL; i++){
+ as = makestr(prefix, LIB, arch_flags[i].name, AS, NULL);
+ if(access(as, F_OK) == 0){
+@@ -270,6 +279,7 @@
+ }
+ }
+ }
++#endif
+ if(count == 0)
+ printf("%s: no assemblers installed\n", progname);
+ exit(1);
diff --git a/sys-devel/binutils-apple/files/binutils-apple-4.2-globals-extern.patch b/sys-devel/binutils-apple/files/binutils-apple-4.2-globals-extern.patch
new file mode 100644
index 000000000000..76419ad90780
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.2-globals-extern.patch
@@ -0,0 +1,29 @@
+Externally referenced globals should be marked extern to avoid stuff like this happening:
+
+ld: warning: tentative definition of '_subsections_via_symbols' with size 16 from 'app.o' is being replaced by real definition of smaller size 4 from 'as.o'
+ld: warning: tentative definition of '_subsections_via_symbols' with size 16 from 'atof-ieee.o' is being replaced by real definition of smaller size 4 from 'as.o'
+...
+
+--- cctools-809/as/as.h.orig 2015-01-28 23:52:40.000000000 +0100
++++ cctools-809/as/as.h 2015-01-28 23:52:52.000000000 +0100
+@@ -179,7 +179,7 @@
+ extern char *specific_archflag;
+
+ /* TRUE if the .subsections_via_symbols directive was seen */
+-int subsections_via_symbols;
++extern int subsections_via_symbols;
+
+ /* -I path options for .includes */
+ struct directory_stack {
+--- cctools-809/as/arm.c.orig 2015-01-28 23:57:23.000000000 +0100
++++ cctools-809/as/arm.c 2015-01-28 23:57:35.000000000 +0100
+@@ -151,8 +151,7 @@
+ # define N_(String) (String)
+
+ /* STUFF FROM gas/as.h */
+-#define COMMON
+-COMMON subsegT now_subseg;
++extern subsegT now_subseg;
+
+ /* STUFF FROM gas/config/tc-arm.h */
+ #define ARM_FLAG_THUMB (1 << 0) /* The symbol is a Thumb symbol rather than an Arm symbol. */
diff --git a/sys-devel/binutils-apple/files/binutils-apple-4.2-lto.patch b/sys-devel/binutils-apple/files/binutils-apple-4.2-lto.patch
new file mode 100644
index 000000000000..791a922dd425
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.2-lto.patch
@@ -0,0 +1,34 @@
+--- misc/lipo.c
++++ misc/lipo.c
+@@ -1191,6 +1191,7 @@
+ thin->fat_arch.align = 0;
+ }
+ else{
++#ifdef LTO_SUPPORT
+ if(is_llvm_bitcode_from_memory(addr, size, &input->arch_flag,
+ NULL) != 0){
+ /* create a thin file struct for it */
+@@ -1204,6 +1205,7 @@
+ thin->fat_arch.align = 0;
+ }
+ else
++#endif
+ fatal("can't figure out the architecture type of: %s",
+ input->name);
+ }
+@@ -1444,6 +1446,7 @@
+ if(strncmp(ar_name, SYMDEF, sizeof(SYMDEF) - 1) != 0){
+ ar_addr = addr + offset + ar_name_size;
+ ar_size = strtoul(ar_hdr->ar_size, NULL, 10);
++#ifdef LTO_SUPPORT
+ if(is_llvm_bitcode_from_memory(ar_addr, ar_size,
+ &arch_flag, NULL) != 0){
+ if(*cputype == 0){
+@@ -1466,6 +1464,7 @@
+ (*cpusubtype) & ~CPU_SUBTYPE_MASK);
+ }
+ }
++#endif
+ }
+ }
+ }
diff --git a/sys-devel/binutils-apple/files/binutils-apple-4.5-as.patch b/sys-devel/binutils-apple/files/binutils-apple-4.5-as.patch
new file mode 100644
index 000000000000..0769016c5682
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.5-as.patch
@@ -0,0 +1,100 @@
+Allow to disable build of as backends for obsolete architectures.
+
+diff --git a/as/Makefile b/as/Makefile
+index a4b016e..9e8bcc3 100644
+--- a/as/Makefile
++++ b/as/Makefile
+@@ -1,3 +1,4 @@
++BUILD_OBSOLETE_ARCH = yes
+ export USE_APPLE_PB_SUPPORT = all
+
+ ifneq "" "$(SDKROOT)"
+@@ -20,28 +21,36 @@ SRCROOT = .
+ SYMROOT = .
+ OBJROOT = .
+ SYM_DIRS = $(SYMROOT)/driver_dir \
+- $(SYMROOT)/a68_dir \
+- $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a386_dir \
+ $(SYMROOT)/ax86_64_dir \
+ $(SYMROOT)/appc_dir \
+ $(SYMROOT)/appc64_dir \
++ $(SYMROOT)/aarm_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++SYM_DIRS += \
++ $(SYMROOT)/a68_dir \
++ $(SYMROOT)/a88_dir \
+ $(SYMROOT)/a860_dir \
+ $(SYMROOT)/ahppa_dir \
+- $(SYMROOT)/asparc_dir \
+- $(SYMROOT)/aarm_dir
++ $(SYMROOT)/asparc_dir
++endif
+
+ OFILE_DIRS = $(OBJROOT)/driver_dir \
+- $(OBJROOT)/a68_dir \
+- $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a386_dir \
+ $(OBJROOT)/ax86_64_dir \
+ $(OBJROOT)/appc_dir \
+ $(OBJROOT)/appc64_dir \
++ $(OBJROOT)/aarm_dir
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++OFILE_DIRS += \
++ $(OBJROOT)/a68_dir \
++ $(OBJROOT)/a88_dir \
+ $(OBJROOT)/a860_dir \
+ $(OBJROOT)/ahppa_dir \
+- $(OBJROOT)/asparc_dir \
+- $(OBJROOT)/aarm_dir
++ $(OBJROOT)/asparc_dir
++endif
+
+ BINDIR = /bin
+ USRBINDIR = /usr/bin
+@@ -88,9 +97,13 @@ OBJS_hppa = $(CFILES_hppa:.c=.o)
+ OBJS_sparc = $(CFILES_sparc:.c=.o)
+ OBJS_arm = $(CFILES_arm:.c=.o)
+
+-all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a68_build a88_build a386_build \
+- ax86_64_build a860_build appc_build appc64_build ahppa_build \
+- aarm_build asparc_build
++all: $(OFILE_DIRS) $(SYM_DIRS) driver_build a386_build \
++ ax86_64_build appc_build appc64_build aarm_build
++
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
++all: a68_build a88_build a860_build ahppa_build asparc_build
++endif
++
+
+ all_test: a68_test a88_test a860_test a386_test appc_test ahppa_test
+
+@@ -406,15 +419,18 @@ install: all
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/ppc64
+ install -c -s -m 555 $(SYMROOT)/appc64_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/ppc64/as
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m68k
+ install -c -s -m 555 $(SYMROOT)/a68_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m68k/as
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/sparc
+ install -c -s -m 555 $(SYMROOT)/asparc_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/sparc/as
++endif
+ $(MKDIRS) $(DSTROOT)$(LIBDIR)/arm
+ install -c -s -m 555 $(SYMROOT)/aarm_dir/as \
+ $(DSTROOT)$(LIBDIR)/arm/as
++ifeq "yes" "$(BUILD_OBSOLETE_ARCH)"
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/m88k
+ install -c -s -m 555 $(SYMROOT)/a88_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/m88k/as
+@@ -424,6 +440,7 @@ install: all
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)/i860
+ install -s -m 555 $(SYMROOT)/a860_dir/as \
+ $(DSTROOT)$(LOCLIBDIR)/i860/as
++endif
+
+ $(OFILE_DIRS) $(SYM_DIRS):
+ $(MKDIRS) $@
diff --git a/sys-devel/binutils-apple/files/binutils-apple-5.1-as-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-5.1-as-dir.patch
new file mode 100644
index 000000000000..1c7c6360a6a8
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-5.1-as-dir.patch
@@ -0,0 +1,47 @@
+Allow to set directory for as backends from the outside.
+
+--- cctools-855/as/driver.c.orig 2014-04-05 00:42:22.000000000 +0200
++++ cctools-855/as/driver.c 2014-11-13 13:07:09.000000000 +0100
+@@ -365,7 +365,11 @@
+ /*
+ * If this assembler exist try to run it else print an error message.
+ */
++#ifndef ASLIBEXECDIR
+ as = makestr(prefix, LIB, arch_name, AS, NULL);
++#else
++ as = makestr(ASLIBEXECDIR, arch_name, AS, NULL);
++#endif
+ new_argv = allocate((argc + 1) * sizeof(char *));
+ new_argv[0] = as;
+ j = 1;
+@@ -387,6 +391,9 @@
+ else
+ exit(1);
+ }
++#ifdef ASLIBEXECDIR
++ as_local = "";
++#else
+ as_local = makestr(prefix, LOCALLIB, arch_name, AS, NULL);
+ new_argv[0] = as_local;
+ if(access(as_local, F_OK) == 0){
+@@ -396,10 +403,12 @@
+ else
+ exit(1);
+ }
++#endif
+ printf("%s: assembler (%s or %s) for architecture %s not installed\n",
+ progname, as, as_local, arch_name);
+ arch_flags = get_arch_flags();
+ count = 0;
++#ifndef ASLIBEXECDIR
+ for(i = 0; arch_flags[i].name != NULL; i++){
+ as = makestr(prefix, LIB, arch_flags[i].name, AS, NULL);
+ if(access(as, F_OK) == 0){
+@@ -420,6 +429,7 @@
+ }
+ }
+ }
++#endif
+ if(count == 0)
+ printf("%s: no assemblers installed\n", progname);
+ exit(1);
diff --git a/sys-devel/binutils-apple/files/binutils-apple-5.1-constant-types.patch b/sys-devel/binutils-apple/files/binutils-apple-5.1-constant-types.patch
new file mode 100644
index 000000000000..066ce57a6f59
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-5.1-constant-types.patch
@@ -0,0 +1,26 @@
+Avoid error with gcc on 32bit platforms:
+ld/LinkEdit.hpp:1329: error: integer constant is too large for 'long' type
+
+--- cctools-855/include/llvm-c/Disassembler.h.orig 2015-01-14 18:36:22.000000000 +0100
++++ cctools-855/include/llvm-c/Disassembler.h 2015-01-14 18:36:39.000000000 +0100
+@@ -133,15 +133,15 @@
+ #define LLVMDisassembler_ReferenceType_In_PCrel_Load 2
+
+ /* The input reference is from an ARM64::ADRP instruction. */
+-#define LLVMDisassembler_ReferenceType_In_ARM64_ADRP 0x100000001
++#define LLVMDisassembler_ReferenceType_In_ARM64_ADRP 0x100000001ULL
+ /* The input reference is from an ARM64::ADDXri instruction. */
+-#define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri 0x100000002
++#define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri 0x100000002ULL
+ /* The input reference is from an ARM64::LDRXui instruction. */
+-#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui 0x100000003
++#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui 0x100000003ULL
+ /* The input reference is from an ARM64::LDRXl instruction. */
+-#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl 0x100000004
++#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl 0x100000004ULL
+ /* The input reference is from an ARM64::ADR instruction. */
+-#define LLVMDisassembler_ReferenceType_In_ARM64_ADR 0x100000005
++#define LLVMDisassembler_ReferenceType_In_ARM64_ADR 0x100000005ULL
+
+ /* The output reference is to as symbol stub. */
+ #define LLVMDisassembler_ReferenceType_Out_SymbolStub 1
diff --git a/sys-devel/binutils-apple/files/binutils-apple-5.1-extraneous-includes.patch b/sys-devel/binutils-apple/files/binutils-apple-5.1-extraneous-includes.patch
new file mode 100644
index 000000000000..2e0a109223f9
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-5.1-extraneous-includes.patch
@@ -0,0 +1,31 @@
+Remove extraneous includes that contain clang language extensions on Mac OS X
+10.10 (xpc/base.h - __has_extension).
+
+--- ./cctools-855/as/messages.c.orig 2015-01-12 18:49:02.000000000 +0100
++++ ./cctools-855/as/messages.c 2015-01-12 18:49:06.000000000 +0100
+@@ -23,11 +23,6 @@
+ #include <string.h>
+ #include <mach/mach.h>
+ #include <mach/mach_init.h>
+-#if defined(__OPENSTEP__) || defined(__GONZO_BUNSEN_BEAKER__)
+-#include <servers/netname.h>
+-#else
+-#include <servers/bootstrap.h>
+-#endif
+ #include "as.h"
+ #include "input-scrub.h"
+ #include "messages.h"
+--- ./cctools-855/misc/libtool.c.orig 2015-01-12 18:48:29.000000000 +0100
++++ ./cctools-855/misc/libtool.c 2015-01-12 18:48:40.000000000 +0100
+@@ -53,11 +53,6 @@
+ #endif /* LTO_SUPPORT */
+
+ #include <mach/mach_init.h>
+-#if defined(__OPENSTEP__) || defined(__GONZO_BUNSEN_BEAKER__)
+-#include <servers/netname.h>
+-#else
+-#include <servers/bootstrap.h>
+-#endif
+
+ /*
+ * This is used internally to build the table of contents.
diff --git a/sys-devel/binutils-apple/files/binutils-apple-5.1-nolto.patch b/sys-devel/binutils-apple/files/binutils-apple-5.1-nolto.patch
new file mode 100644
index 000000000000..62490ef8ce46
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-5.1-nolto.patch
@@ -0,0 +1,43 @@
+Allow to fully disable LTO.
+
+diff --git a/libstuff/lto.c b/libstuff/lto.c
+index 6f5758d..5ba7996 100644
+--- a/libstuff/lto.c
++++ b/libstuff/lto.c
+@@ -381,4 +381,18 @@ void *mod)
+ lto_dispose(mod);
+ }
+
++#else
++
++#include <stdlib.h>
++#include "stuff/ofile.h"
++
++__private_extern__
++int
++is_llvm_bitcode(
++ struct ofile *ofile,
++ char *addr,
++ size_t size)
++{
++ return 0;
++}
+ #endif /* LTO_SUPPORT */
+diff --git a/misc/libtool.c b/misc/libtool.c
+index f9c7557..ff829cc 100644
+--- a/misc/libtool.c
++++ b/misc/libtool.c
+@@ -1370,8 +1370,11 @@ void)
+ }
+ }
+ }
+- else if(ofiles[i].arch_type == OFILE_Mach_O ||
+- ofiles[i].arch_type == OFILE_LLVM_BITCODE){
++ else if(ofiles[i].arch_type == OFILE_Mach_O
++#ifdef LTO_SUPPORT
++ || ofiles[i].arch_type == OFILE_LLVM_BITCODE
++#endif
++ ){
+ if(cmd_flags.ranlib == TRUE){
+ error("for architecture: %s file: %s is not an "
+ "archive (no processing done on this file)",
diff --git a/sys-devel/binutils-apple/files/binutils-apple-5.1-otool-stdc.patch b/sys-devel/binutils-apple/files/binutils-apple-5.1-otool-stdc.patch
new file mode 100644
index 000000000000..ca02e643a45e
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-5.1-otool-stdc.patch
@@ -0,0 +1,23 @@
+Do not use C++/C11(?) style local variable declaration.
+
+--- cctools-855/otool/dyld_bind_info.c.orig 2015-01-12 18:55:04.000000000 +0100
++++ cctools-855/otool/dyld_bind_info.c 2015-01-12 18:56:35.000000000 +0100
+@@ -353,7 +353,9 @@
+ skip = read_uleb128(&p, end);
+ sectName = sectionName(segIndex, segStartAddr + segOffset,
+ segs, nsegs, segs64, nsegs64);
+- for (uint32_t i=0; i < count; ++i) {
++ {
++ uint32_t i;
++ for (i=0; i < count; ++i) {
+ if(pass == 2){
+ (*dbi)[n].segname = segName;
+ (*dbi)[n].sectname = sectName;
+@@ -367,6 +369,7 @@
+ n++;
+ segOffset += skip + sizeof_pointer;
+ }
++ }
+ break;
+ default:
+ return; /* throwf("bad bind opcode %d", *p); */
diff --git a/sys-devel/binutils-apple/files/binutils-apple-5.1-ranlib.patch b/sys-devel/binutils-apple/files/binutils-apple-5.1-ranlib.patch
new file mode 100644
index 000000000000..1930dfc82d27
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-5.1-ranlib.patch
@@ -0,0 +1,15 @@
+Run ranlib before installation of the libary.
+
+--- ./cctools-855/cbtlibs/Makefile.ranlib 2014-04-05 00:42:22.000000000 +0200
++++ ./cctools-855/cbtlibs/Makefile 2014-08-29 14:49:41.000000000 +0200
+@@ -61,9 +61,9 @@
+
+ lib_ofiles_install: lib_ofiles
+ $(MKDIRS) $(DSTROOT)$(LOCLIBDIR)
++ $(RANLIB) $(SYMROOT)/libsyminfo.a
+ install -p -c -m 444 $(SYMROOT)/libsyminfo.a \
+ $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+- $(RANLIB) $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
+
+ $(OFILE_DIR) $(SYMROOT):
+ $(MKDIRS) $@
diff --git a/sys-devel/binutils-apple/files/binutils-apple-5.1-strnlen.patch b/sys-devel/binutils-apple/files/binutils-apple-5.1-strnlen.patch
new file mode 100644
index 000000000000..887e15628b31
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-5.1-strnlen.patch
@@ -0,0 +1,45 @@
+Provide strnlen on platforms where it's missing.
+
+--- cctools-855/otool/ofile_print.c.orig 2015-01-14 18:33:14.000000000 +0100
++++ cctools-855/otool/ofile_print.c 2015-01-14 18:34:03.000000000 +0100
+@@ -3647,6 +3647,40 @@
+ printf(" pad %u\n", ec->pad);
+ }
+
++/* borrowed from gnulib */
++#include <AvailabilityMacros.h>
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
++/* Find the length of STRING, but scan at most MAXLEN characters.
++ * Copyright (C) 2005-2007, 2009-2015 Free Software Foundation, Inc.
++ * Written by Simon Josefsson.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2, or (at your option)
++ * any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, see <http://www.gnu.org/licenses/>. */
++
++#include <string.h>
++
++/* Find the length of STRING, but scan at most MAXLEN characters.
++ * If no '\0' terminator is found in that many characters, return MAXLEN. */
++
++size_t
++strnlen (const char *string, size_t maxlen)
++{
++ const char *end = memchr (string, '\0', maxlen);
++ return end ? (size_t) (end - string) : maxlen;
++}
++#endif
++
+ /*
+ * print an LC_LINKER_OPTION command. The linker_option_command structure
+ * specified must be aligned correctly and in the host byte sex. The lc is
diff --git a/sys-devel/binutils-apple/files/cctools-839-intel-retf.patch b/sys-devel/binutils-apple/files/cctools-839-intel-retf.patch
new file mode 100644
index 000000000000..d9bd9a8425b9
--- /dev/null
+++ b/sys-devel/binutils-apple/files/cctools-839-intel-retf.patch
@@ -0,0 +1,14 @@
+diff --git a/as/i386-opcode.h b/as/i386-opcode.h
+index 4ba397f..862449a 100644
+--- a/as/i386-opcode.h
++++ b/as/i386-opcode.h
+@@ -415,6 +415,9 @@ static const template i386_optab[] =
+ {"ret", 1, 0xc2, X, Cpu64, wq_Suf|DefaultSize|NoRex64,{ Imm16, 0, 0} },
+ {"lret", 0, 0xcb, X, 0, wlq_Suf|DefaultSize, { 0, 0, 0} },
+ {"lret", 1, 0xca, X, 0, wlq_Suf|DefaultSize, { Imm16, 0, 0} },
++// intel syntax
++{"retf", 0, 0xcb, X, 0, wlq_Suf|DefaultSize, { 0, 0, 0} },
++{"retf", 1, 0xca, X, 0, wlq_Suf|DefaultSize, { Imm16, 0, 0} },
+ {"enter", 2, 0xc8, X, Cpu186|CpuNo64, wl_Suf|DefaultSize, { Imm16, Imm8, 0} },
+ {"enter", 2, 0xc8, X, Cpu64, wq_Suf|DefaultSize|NoRex64, { Imm16, Imm8, 0} },
+ {"leave", 0, 0xc9, X, Cpu186|CpuNo64, wl_Suf|DefaultSize, { 0, 0, 0} },
diff --git a/sys-devel/binutils-apple/files/ld64-123.2-Makefile b/sys-devel/binutils-apple/files/ld64-123.2-Makefile
new file mode 100644
index 000000000000..47af12d4b2ec
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-123.2-Makefile
@@ -0,0 +1,47 @@
+CPPFLAGS += "-DCPU_SUBTYPE_X86_ALL=((cpu_subtype_t)3)" -Iinclude -Iabstraction -Ild -Ild/parsers -Iother -I.
+
+# dropped machocheck due to compilation failures
+all: rebase unwinddump dyldinfo ld64 ObjectDump
+
+libprunetrie.a: other/PruneTrie.o other/prune_trie.h
+ $(AR) -s -r -c libprunetrie.a other/PruneTrie.o
+
+LD64LIBS=ld/parsers/archive_file.o ld/parsers/macho_relocatable_file.o \
+ ld/parsers/opaque_section_file.o \
+ ld/parsers/macho_dylib_file.o \
+ ld/passes/branch_island.o ld/passes/dylibs.o ld/passes/order_file.o \
+ ld/passes/branch_shim.o ld/passes/got.o ld/passes/tlvp.o \
+ ld/passes/compact_unwind.o ld/passes/huge.o \
+ ld/passes/dtrace_dof.o ld/passes/objc.o \
+ ld/passes/stubs/stubs.o \
+ ld/InputFiles.o ld/OutputFile.o ld/SymbolTable.o \
+ ld/Options.o ld/Resolver.o ld/debugline.o ld/ld.o
+
+ifeq ($(LTO),1)
+CPPFLAGS += "-DLTO"
+LTO_OBJ = ld/parsers/lto_file.o
+LIBLTO = -lLTO
+else
+CPPFLAGS += "-ULTO"
+LTO_OBJ =
+LIBLTO =
+endif
+
+ld64: libprunetrie.a version.o $(LD64LIBS) $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+rebase: other/rebase.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+dyldinfo: other/dyldinfo.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+unwinddump: other/unwinddump.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+ObjectDump: other/ObjectDump.o ld/debugline.o ld/parsers/macho_relocatable_file.o $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+machocheck: other/machochecker.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
diff --git a/sys-devel/binutils-apple/files/ld64-123.2-darwin8-no-mlong-branch-warning.patch b/sys-devel/binutils-apple/files/ld64-123.2-darwin8-no-mlong-branch-warning.patch
new file mode 100644
index 000000000000..c8a303e1c9d6
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-123.2-darwin8-no-mlong-branch-warning.patch
@@ -0,0 +1,17 @@
+On Tiger (Darwin 8) the whole system (/usr/bin/crt0.o for example) is
+long-branch compiled, so *any* linkage operation causes this warning to
+be raised. Don't do it.
+
+
+--- ld/parsers/macho_relocatable_file.cpp
++++ ld/parsers/macho_relocatable_file.cpp
+@@ -5532,9 +5532,6 @@
+ // this is from -mlong-branch codegen. We ignore the jump island and make reference to the real target
+ if ( nextReloc->r_type() != PPC_RELOC_PAIR )
+ throw "PPC_RELOC_JBSR missing following pair";
+- if ( !parser._hasLongBranchStubs )
+- warning("object file compiled with -mlong-branch which is no longer needed. "
+- "To remove this warning, recompile without -mlong-branch: %s", parser._path);
+ parser._hasLongBranchStubs = true;
+ result = true;
+ if ( reloc->r_extern() ) {
diff --git a/sys-devel/binutils-apple/files/ld64-123.2-debug-backtrace.patch b/sys-devel/binutils-apple/files/ld64-123.2-debug-backtrace.patch
new file mode 100644
index 000000000000..f1126503b424
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-123.2-debug-backtrace.patch
@@ -0,0 +1,15 @@
+execinfo.h isn't available <10.5, so make sure it is only included when
+actually necessary
+
+--- ld/ld.cpp
++++ ld/ld.cpp
+@@ -37,7 +37,9 @@
+ #include <errno.h>
+ #include <limits.h>
+ #include <unistd.h>
++#ifndef NDEBUG
+ #include <execinfo.h>
++#endif
+ #include <mach/mach_time.h>
+ #include <mach/vm_statistics.h>
+ #include <mach/mach_init.h>
diff --git a/sys-devel/binutils-apple/files/ld64-123.2.1-lto.patch b/sys-devel/binutils-apple/files/ld64-123.2.1-lto.patch
new file mode 100644
index 000000000000..17bac81ca291
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-123.2.1-lto.patch
@@ -0,0 +1,218 @@
+diff -ur ld.orig/InputFiles.cpp ld/InputFiles.cpp
+--- ld.orig/InputFiles.cpp 2010-10-05 01:57:50.000000000 +0200
++++ ld/InputFiles.cpp 2011-09-03 20:33:40.000000000 +0200
+@@ -58,7 +58,9 @@
+ #include "macho_relocatable_file.h"
+ #include "macho_dylib_file.h"
+ #include "archive_file.h"
++#ifdef LTO
+ #include "lto_file.h"
++#endif
+ #include "opaque_section_file.h"
+
+
+@@ -175,9 +177,11 @@
+ if ( result != NULL )
+ return result;
+
++#ifdef LTO
+ result = lto::archName(p, len);
+ if ( result != NULL )
+ return result;
++#endif
+
+ if ( strncmp((const char*)p, "!<arch>\n", 8) == 0 )
+ return "archive";
+@@ -264,10 +268,12 @@
+ if ( objResult != NULL )
+ return this->addObject(objResult, info, len);
+
++#if LTO
+ // see if it is an llvm object file
+ objResult = lto::parse(p, len, info.path, info.modTime, _nextInputOrdinal, _options.architecture(), _options.subArchitecture(), _options.logAllFiles());
+ if ( objResult != NULL )
+ return this->addObject(objResult, info, len);
++#endif
+
+ // see if it is a dynamic library
+ ld::dylib::File* dylibResult = mach_o::dylib::parse(p, len, info.path, info.modTime, _options, _nextInputOrdinal, info.options.fBundleLoader);
+@@ -286,6 +292,7 @@
+ if ( archiveResult != NULL )
+ return this->addArchive(archiveResult, info, len);
+
++#ifdef LTO
+ // does not seem to be any valid linker input file, check LTO misconfiguration problems
+ if ( lto::archName((uint8_t*)p, len) != NULL ) {
+ if ( lto::libLTOisLoaded() ) {
+@@ -310,6 +317,7 @@
+ throwf("could not process llvm bitcode object file, because %s could not be loaded", libLTO);
+ }
+ }
++#endif
+
+ // error handling
+ if ( ((fat_header*)p)->magic == OSSwapBigToHostInt32(FAT_MAGIC) ) {
+diff -ur ld.orig/Options.cpp ld/Options.cpp
+--- ld.orig/Options.cpp 2011-03-08 03:06:35.000000000 +0100
++++ ld/Options.cpp 2011-09-03 21:06:28.000000000 +0200
+@@ -36,10 +36,12 @@
+ #include "Architectures.hpp"
+ #include "MachOFileAbstraction.hpp"
+
++#ifdef LTO
+ // upward dependency on lto::version()
+ namespace lto {
+ extern const char* version();
+ }
++#endif
+
+ // magic to place command line in crash reports
+ const int crashreporterBufferSize = 2000;
+@@ -2786,9 +2788,11 @@
+ fprintf(stderr, "%s", ldVersionString);
+ // if only -v specified, exit cleanly
+ if ( argc == 2 ) {
++#ifdef LTO
+ const char* ltoVers = lto::version();
+ if ( ltoVers != NULL )
+ fprintf(stderr, "%s\n", ltoVers);
++#endif
+ exit(0);
+ }
+ }
+diff -ur ld.orig/Resolver.cpp ld/Resolver.cpp
+--- ld.orig/Resolver.cpp 2010-12-10 23:39:41.000000000 +0100
++++ ld/Resolver.cpp 2011-09-03 20:38:24.000000000 +0200
+@@ -58,7 +58,9 @@
+ #include "InputFiles.h"
+ #include "SymbolTable.h"
+ #include "Resolver.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+
+
+ namespace ld {
+@@ -1275,6 +1277,7 @@
+
+ void Resolver::linkTimeOptimize()
+ {
++#ifdef LTO
+ // only do work here if some llvm obj files where loaded
+ if ( ! _haveLLVMObjs )
+ return;
+@@ -1375,6 +1378,9 @@
+ // check new code does not override some dylib
+ this->checkDylibSymbolCollisions();
+ }
++#else
++ return;
++#endif
+ }
+
+
+diff -ur ld.orig/ld.cpp ld/ld.cpp
+--- ld.orig/ld.cpp 2011-09-03 20:24:07.000000000 +0200
++++ ld/ld.cpp 2011-09-03 20:40:06.000000000 +0200
+@@ -85,7 +85,9 @@
+ #include "parsers/archive_file.h"
+ #include "parsers/macho_relocatable_file.h"
+ #include "parsers/macho_dylib_file.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+ #include "parsers/opaque_section_file.h"
+
+
+diff -ur ld.orig/parsers/archive_file.cpp ld/parsers/archive_file.cpp
+--- ld.orig/parsers/archive_file.cpp 2010-09-29 02:26:13.000000000 +0200
++++ ld/parsers/archive_file.cpp 2011-09-03 21:01:55.000000000 +0200
+@@ -38,7 +38,9 @@
+ #include "Architectures.hpp"
+
+ #include "macho_relocatable_file.h"
++#ifdef LTO
+ #include "lto_file.h"
++#endif
+ #include "archive_file.h"
+
+
+@@ -87,8 +89,10 @@
+ private:
+ static bool validMachOFile(const uint8_t* fileContent, uint64_t fileLength,
+ const mach_o::relocatable::ParserOptions& opts);
++#ifdef LTO
+ static bool validLTOFile(const uint8_t* fileContent, uint64_t fileLength,
+ const mach_o::relocatable::ParserOptions& opts);
++#endif
+ static cpu_type_t architecture();
+
+
+@@ -232,12 +236,13 @@
+ return mach_o::relocatable::isObjectFile(fileContent, fileLength, opts);
+ }
+
++#ifdef LTO
+ template <typename A>
+ bool File<A>::validLTOFile(const uint8_t* fileContent, uint64_t fileLength, const mach_o::relocatable::ParserOptions& opts)
+ {
+ return lto::isObjectFile(fileContent, fileLength, opts.architecture, opts.subType);
+ }
+-
++#endif
+
+
+ template <typename A>
+@@ -256,7 +261,11 @@
+ if ( (p==start) && ((strcmp(memberName, SYMDEF_SORTED) == 0) || (strcmp(memberName, SYMDEF) == 0)) )
+ continue;
+ // archive is valid if first .o file is valid
+- return (validMachOFile(p->content(), p->contentSize(), opts) || validLTOFile(p->content(), p->contentSize(), opts));
++ return (validMachOFile(p->content(), p->contentSize(), opts)
++#ifdef LTO
++ || validLTOFile(p->content(), p->contentSize(), opts)
++#endif
++ );
+ }
+ // empty archive
+ return true;
+@@ -342,12 +351,14 @@
+ this->ordinal() + memberIndex, _objOpts);
+ if ( result != NULL )
+ return result;
++#ifdef LTO
+ // see if member is llvm bitcode file
+ result = lto::parse(member->content(), member->contentSize(),
+ mPath, member->modificationTime(), this->ordinal() + memberIndex,
+ _objOpts.architecture, _objOpts.subType, _logAllFiles);
+ if ( result != NULL )
+ return result;
++#endif
+
+ throwf("archive member '%s' with length %d is not mach-o or llvm bitcode", memberName, member->contentSize());
+ }
+--- other/ObjectDump.cpp.orig 2011-09-03 21:15:10.000000000 +0200
++++ other/ObjectDump.cpp 2011-09-03 21:14:37.000000000 +0200
+@@ -33,7 +33,9 @@
+
+ #include "MachOFileAbstraction.hpp"
+ #include "parsers/macho_relocatable_file.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+
+ static bool sDumpContent= true;
+ static bool sDumpStabs = false;
+@@ -1121,10 +1123,12 @@
+ if ( objResult != NULL )
+ return objResult;
+
++#ifdef LTO
+ // see if it is an llvm object file
+ objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, 0, sPreferredArch, sPreferredSubArch, false);
+ if ( objResult != NULL )
+ return objResult;
++#endif
+
+ throwf("not a mach-o object file: %s", path);
+ #else
diff --git a/sys-devel/binutils-apple/files/ld64-127.2-Makefile b/sys-devel/binutils-apple/files/ld64-127.2-Makefile
new file mode 100644
index 000000000000..74aef560a23e
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-127.2-Makefile
@@ -0,0 +1,50 @@
+CPPFLAGS += -Iinclude -Iabstraction -Ild -Ild/parsers -Iother -I.
+
+# some files generate warnings about applying offsetof to a non-POD type.
+# Upstream seems aware of that and ignores by setting
+# GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO in the xcode project.
+CXXFLAGS += -Wno-invalid-offsetof
+
+all: rebase unwinddump dyldinfo ld64 ObjectDump machocheck
+
+libprunetrie.a: other/PruneTrie.o other/prune_trie.h
+ $(AR) -s -r -c libprunetrie.a other/PruneTrie.o
+
+LD64LIBS=ld/parsers/archive_file.o ld/parsers/macho_relocatable_file.o \
+ ld/parsers/opaque_section_file.o \
+ ld/parsers/macho_dylib_file.o \
+ ld/passes/branch_island.o ld/passes/dylibs.o ld/passes/order_file.o \
+ ld/passes/branch_shim.o ld/passes/got.o ld/passes/tlvp.o \
+ ld/passes/compact_unwind.o ld/passes/huge.o \
+ ld/passes/dtrace_dof.o ld/passes/objc.o \
+ ld/passes/stubs/stubs.o \
+ ld/InputFiles.o ld/OutputFile.o ld/SymbolTable.o \
+ ld/Options.o ld/Resolver.o ld/debugline.o ld/ld.o
+
+ifeq ($(LTO),1)
+CPPFLAGS += -DLTO
+LTO_OBJ = ld/parsers/lto_file.o
+LIBLTO = -lLTO
+else
+LTO_OBJ =
+LIBLTO =
+endif
+
+ld64: libprunetrie.a version.o $(LD64LIBS) $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+rebase: other/rebase.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+dyldinfo: other/dyldinfo.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+unwinddump: other/unwinddump.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+ObjectDump: other/ObjectDump.o ld/debugline.o ld/parsers/macho_relocatable_file.o $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+machocheck: other/machochecker.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
diff --git a/sys-devel/binutils-apple/files/ld64-127.2-extraneous-headers.patch b/sys-devel/binutils-apple/files/ld64-127.2-extraneous-headers.patch
new file mode 100644
index 000000000000..34d508063df1
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-127.2-extraneous-headers.patch
@@ -0,0 +1,12 @@
+Remove unused header that doesn't exist on older OS Xes.
+
+--- ld64-127.2/src/ld/parsers/libunwind/AddressSpace.hpp.orig 2015-01-27 23:24:49.000000000 +0100
++++ ld64-127.2/src/ld/parsers/libunwind/AddressSpace.hpp 2015-01-27 23:26:21.000000000 +0100
+@@ -37,7 +37,6 @@
+ #include <mach-o/getsect.h>
+ #include <mach-o/dyld_priv.h>
+ #include <mach/i386/thread_status.h>
+-#include <Availability.h>
+
+ #include "FileAbstraction.hpp"
+ #include "libunwind.h"
diff --git a/sys-devel/binutils-apple/files/ld64-127.2-lto.patch b/sys-devel/binutils-apple/files/ld64-127.2-lto.patch
new file mode 100644
index 000000000000..b9a3f14042c5
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-127.2-lto.patch
@@ -0,0 +1,214 @@
+--- src/ld/InputFiles.cpp
++++ src/ld/InputFiles.cpp
+@@ -58,7 +58,9 @@
+ #include "macho_relocatable_file.h"
+ #include "macho_dylib_file.h"
+ #include "archive_file.h"
++#ifdef LTO
+ #include "lto_file.h"
++#endif
+ #include "opaque_section_file.h"
+
+
+@@ -175,9 +177,11 @@
+ if ( result != NULL )
+ return result;
+
++#ifdef LTO
+ result = lto::archName(p, len);
+ if ( result != NULL )
+ return result;
++#endif
+
+ if ( strncmp((const char*)p, "!<arch>\n", 8) == 0 )
+ return "archive";
+@@ -264,10 +268,12 @@
+ if ( objResult != NULL )
+ return this->addObject(objResult, info, len);
+
++#if LTO
+ // see if it is an llvm object file
+ objResult = lto::parse(p, len, info.path, info.modTime, _nextInputOrdinal, _options.architecture(), _options.subArchitecture(), _options.logAllFiles());
+ if ( objResult != NULL )
+ return this->addObject(objResult, info, len);
++#endif
+
+ // see if it is a dynamic library
+ ld::dylib::File* dylibResult = mach_o::dylib::parse(p, len, info.path, info.modTime, _options, _nextInputOrdinal, info.options.fBundleLoader, indirectDylib);
+@@ -291,6 +297,7 @@
+ return this->addArchive(archiveResult, info, len);
+ }
+
++#ifdef LTO
+ // does not seem to be any valid linker input file, check LTO misconfiguration problems
+ if ( lto::archName((uint8_t*)p, len) != NULL ) {
+ if ( lto::libLTOisLoaded() ) {
+@@ -315,6 +322,7 @@
+ throwf("could not process llvm bitcode object file, because %s could not be loaded", libLTO);
+ }
+ }
++#endif
+
+ // error handling
+ if ( ((fat_header*)p)->magic == OSSwapBigToHostInt32(FAT_MAGIC) ) {
+--- src/ld/Options.cpp
++++ src/ld/Options.cpp
+@@ -36,10 +36,12 @@
+ #include "Architectures.hpp"
+ #include "MachOFileAbstraction.hpp"
+
++#ifdef LTO
+ // upward dependency on lto::version()
+ namespace lto {
+ extern const char* version();
+ }
++#endif
+
+ // magic to place command line in crash reports
+ const int crashreporterBufferSize = 2000;
+@@ -2766,9 +2768,11 @@
+ fprintf(stderr, "%s", ldVersionString);
+ // if only -v specified, exit cleanly
+ if ( argc == 2 ) {
++#ifdef LTO
+ const char* ltoVers = lto::version();
+ if ( ltoVers != NULL )
+ fprintf(stderr, "%s\n", ltoVers);
++#endif
+ exit(0);
+ }
+ }
+--- src/ld/Resolver.cpp
++++ src/ld/Resolver.cpp
+@@ -58,7 +58,9 @@
+ #include "InputFiles.h"
+ #include "SymbolTable.h"
+ #include "Resolver.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+
+
+ namespace ld {
+@@ -1315,6 +1317,7 @@
+
+ void Resolver::linkTimeOptimize()
+ {
++#ifdef LTO
+ // only do work here if some llvm obj files where loaded
+ if ( ! _haveLLVMObjs )
+ return;
+@@ -1415,6 +1418,9 @@
+ // check new code does not override some dylib
+ this->checkDylibSymbolCollisions();
+ }
++#else
++ return;
++#endif
+ }
+
+
+--- src/ld/ld.cpp
++++ src/ld/ld.cpp
+@@ -83,7 +83,9 @@
+ #include "parsers/archive_file.h"
+ #include "parsers/macho_relocatable_file.h"
+ #include "parsers/macho_dylib_file.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+ #include "parsers/opaque_section_file.h"
+
+
+--- src/ld/parsers/archive_file.cpp
++++ src/ld/parsers/archive_file.cpp
+@@ -39,7 +39,9 @@
+ #include "Architectures.hpp"
+
+ #include "macho_relocatable_file.h"
++#ifdef LTO
+ #include "lto_file.h"
++#endif
+ #include "archive_file.h"
+
+
+@@ -91,8 +93,10 @@
+ private:
+ static bool validMachOFile(const uint8_t* fileContent, uint64_t fileLength,
+ const mach_o::relocatable::ParserOptions& opts);
++#ifdef LTO
+ static bool validLTOFile(const uint8_t* fileContent, uint64_t fileLength,
+ const mach_o::relocatable::ParserOptions& opts);
++#endif
+ static cpu_type_t architecture();
+
+ class Entry : ar_hdr
+@@ -239,12 +243,13 @@
+ return mach_o::relocatable::isObjectFile(fileContent, fileLength, opts);
+ }
+
++#ifdef LTO
+ template <typename A>
+ bool File<A>::validLTOFile(const uint8_t* fileContent, uint64_t fileLength, const mach_o::relocatable::ParserOptions& opts)
+ {
+ return lto::isObjectFile(fileContent, fileLength, opts.architecture, opts.subType);
+ }
+-
++#endif
+
+
+ template <typename A>
+@@ -263,7 +268,11 @@
+ if ( (p==start) && ((strcmp(memberName, SYMDEF_SORTED) == 0) || (strcmp(memberName, SYMDEF) == 0)) )
+ continue;
+ // archive is valid if first .o file is valid
+- return (validMachOFile(p->content(), p->contentSize(), opts) || validLTOFile(p->content(), p->contentSize(), opts));
++ return (validMachOFile(p->content(), p->contentSize(), opts)
++#ifdef LTO
++ || validLTOFile(p->content(), p->contentSize(), opts)
++#endif
++ );
+ }
+ // empty archive
+ return true;
+@@ -363,6 +372,7 @@
+ _instantiatedEntries[member] = state;
+ return _instantiatedEntries[member];
+ }
++#ifdef LTO
+ // see if member is llvm bitcode file
+ result = lto::parse(member->content(), member->contentSize(),
+ mPath, member->modificationTime(), this->ordinal() + memberIndex,
+@@ -372,6 +382,7 @@
+ _instantiatedEntries[member] = state;
+ return _instantiatedEntries[member];
+ }
++#endif
+
+ throwf("archive member '%s' with length %d is not mach-o or llvm bitcode", memberName, member->contentSize());
+ }
+--- src/other/ObjectDump.cpp
++++ src/other/ObjectDump.cpp
+@@ -33,7 +33,9 @@
+
+ #include "MachOFileAbstraction.hpp"
+ #include "parsers/macho_relocatable_file.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+
+ static bool sDumpContent= true;
+ static bool sDumpStabs = false;
+@@ -1150,10 +1152,12 @@
+ if ( objResult != NULL )
+ return objResult;
+
++#ifdef LTO
+ // see if it is an llvm object file
+ objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, 0, sPreferredArch, sPreferredSubArch, false);
+ if ( objResult != NULL )
+ return objResult;
++#endif
+
+ throwf("not a mach-o object file: %s", path);
+ #else
diff --git a/sys-devel/binutils-apple/files/ld64-127.2-ppc-range-warning.patch b/sys-devel/binutils-apple/files/ld64-127.2-ppc-range-warning.patch
new file mode 100644
index 000000000000..c9f850823939
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-127.2-ppc-range-warning.patch
@@ -0,0 +1,16 @@
+Insipred by the comment here:
+http://bugs.freepascal.org/view.php?id=20879
+It looks like the PPC case is missing, hence add this. Without, we get
+linker errors for compiling packages like Python and TexLive.
+
+--- src/ld/OutputFile.cpp
++++ src/ld/OutputFile.cpp
+@@ -807,7 +807,7 @@
+ // is encoded in mach-o the same as:
+ // .long _foo + 0x40000000
+ // so if _foo lays out to 0xC0000100, the first is ok, but the second is not.
+- if ( (_options.architecture() == CPU_TYPE_ARM) || (_options.architecture() == CPU_TYPE_I386) ) {
++ if ( (_options.architecture() == CPU_TYPE_ARM) || (_options.architecture() == CPU_TYPE_I386) || (_options.architecture() == CPU_TYPE_POWERPC) ) {
+ // Unlikely userland code does funky stuff like this, so warn for them, but not warn for -preload
+ if ( _options.outputKind() != Options::kPreload ) {
+ warning("32-bit absolute address out of range (0x%08llX max is 4GB): from %s + 0x%08X (0x%08llX) to 0x%08llX",
diff --git a/sys-devel/binutils-apple/files/ld64-127.2-thread_state.patch b/sys-devel/binutils-apple/files/ld64-127.2-thread_state.patch
new file mode 100644
index 000000000000..e894bee0c8d0
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-127.2-thread_state.patch
@@ -0,0 +1,13 @@
+Include thread_status.h so that __darwin_i386_thread_state_t is known and will
+not generate warnings that it's declared inside parameter list.
+
+--- ld64-127.2/src/ld/HeaderAndLoadCommands.hpp.orig 2015-01-28 00:32:55.000000000 +0100
++++ ld64-127.2/src/ld/HeaderAndLoadCommands.hpp 2015-01-28 00:27:51.000000000 +0100
+@@ -29,6 +29,7 @@
+ #include <limits.h>
+ #include <unistd.h>
+ #include <mach-o/loader.h>
++#include <mach/i386/thread_status.h>
+
+ #include <vector>
+
diff --git a/sys-devel/binutils-apple/files/ld64-128.2-1010.patch b/sys-devel/binutils-apple/files/ld64-128.2-1010.patch
new file mode 100644
index 000000000000..dee69e7c858b
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-128.2-1010.patch
@@ -0,0 +1,20 @@
+Backport (just a diff really) of OS X 10.10 handling from 241.9.
+
+--- ld64-128.2/src/ld/Options.cpp 2015-01-30 17:16:48.000000000 +0100
++++ ld64-241.9/src/ld/Options.cpp 2015-01-30 17:11:57.000000000 +0100
+@@ -1241,7 +1348,14 @@
+ throw "-macosx_version_min argument missing";
+
+ if ( (strncmp(version, "10.", 3) == 0) && isdigit(version[3]) ) {
+- unsigned int minorVersion = version[3] - '0';
++ unsigned int minorVersion = 0;
++ for (int i=3; isdigit(version[i]); ++i) {
++ minorVersion = minorVersion*10 + (version[i] - '0');
++ }
++ if ( minorVersion > 255 ) {
++ warning("Mac OS X minor version > 255 in '%s'", version);
++ minorVersion = 255;
++ }
+ fMacVersionMin = (ld::MacVersionMin)(0x000A0000 | (minorVersion << 8));
+ }
+ else {
diff --git a/sys-devel/binutils-apple/files/ld64-128.2-Makefile b/sys-devel/binutils-apple/files/ld64-128.2-Makefile
new file mode 100644
index 000000000000..b02c82459449
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-128.2-Makefile
@@ -0,0 +1,47 @@
+CPPFLAGS += "-DCPU_SUBTYPE_X86_ALL=((cpu_subtype_t)3)" -Iinclude -Iabstraction -Ild -Ild/parsers -Iother -I.
+
+# dropped machocheck due to compilation failures
+all: rebase unwinddump dyldinfo ld64 ObjectDump
+
+libprunetrie.a: other/PruneTrie.o other/prune_trie.h
+ $(AR) -s -r -c libprunetrie.a other/PruneTrie.o
+
+LD64LIBS=ld/parsers/archive_file.o ld/parsers/macho_relocatable_file.o \
+ ld/parsers/opaque_section_file.o \
+ ld/parsers/macho_dylib_file.o \
+ ld/passes/branch_island.o ld/passes/dylibs.o ld/passes/order.o \
+ ld/passes/branch_shim.o ld/passes/got.o ld/passes/tlvp.o \
+ ld/passes/compact_unwind.o ld/passes/huge.o \
+ ld/passes/dtrace_dof.o ld/passes/objc.o \
+ ld/passes/stubs/stubs.o \
+ ld/InputFiles.o ld/OutputFile.o ld/SymbolTable.o \
+ ld/Options.o ld/Resolver.o ld/debugline.o ld/ld.o
+
+ifeq ($(LTO),1)
+CPPFLAGS += "-DLTO"
+LTO_OBJ = ld/parsers/lto_file.o
+LIBLTO = -lLTO
+else
+CPPFLAGS += "-ULTO"
+LTO_OBJ =
+LIBLTO =
+endif
+
+ld64: libprunetrie.a version.o $(LD64LIBS) $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+rebase: other/rebase.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+dyldinfo: other/dyldinfo.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+unwinddump: other/unwinddump.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+ObjectDump: other/ObjectDump.o ld/debugline.o ld/parsers/macho_relocatable_file.o $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+machocheck: other/machochecker.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
diff --git a/sys-devel/binutils-apple/files/ld64-128.2-Makefile-2 b/sys-devel/binutils-apple/files/ld64-128.2-Makefile-2
new file mode 100644
index 000000000000..1d48ae9eaaf4
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-128.2-Makefile-2
@@ -0,0 +1,50 @@
+CPPFLAGS += -Iinclude -Iabstraction -Ild -Ild/parsers -Iother -I.
+
+# some files generate warnings about applying offsetof to a non-POD type.
+# Upstream seems aware of that and ignores by setting
+# GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO in the xcode project.
+CXXFLAGS += -Wno-invalid-offsetof
+
+all: rebase unwinddump dyldinfo ld64 ObjectDump machocheck
+
+libprunetrie.a: other/PruneTrie.o other/prune_trie.h
+ $(AR) -s -r -c libprunetrie.a other/PruneTrie.o
+
+LD64LIBS=ld/parsers/archive_file.o ld/parsers/macho_relocatable_file.o \
+ ld/parsers/opaque_section_file.o \
+ ld/parsers/macho_dylib_file.o \
+ ld/passes/branch_island.o ld/passes/dylibs.o ld/passes/order.o \
+ ld/passes/branch_shim.o ld/passes/got.o ld/passes/tlvp.o \
+ ld/passes/compact_unwind.o ld/passes/huge.o \
+ ld/passes/dtrace_dof.o ld/passes/objc.o \
+ ld/passes/stubs/stubs.o \
+ ld/InputFiles.o ld/OutputFile.o ld/SymbolTable.o \
+ ld/Options.o ld/Resolver.o ld/debugline.o ld/ld.o
+
+ifeq ($(LTO),1)
+CPPFLAGS += -DLTO
+LTO_OBJ = ld/parsers/lto_file.o
+LIBLTO = -lLTO
+else
+LTO_OBJ =
+LIBLTO =
+endif
+
+ld64: libprunetrie.a version.o $(LD64LIBS) $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+rebase: other/rebase.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+dyldinfo: other/dyldinfo.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+unwinddump: other/unwinddump.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+ObjectDump: other/ObjectDump.o ld/debugline.o ld/parsers/macho_relocatable_file.o $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+machocheck: other/machochecker.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
diff --git a/sys-devel/binutils-apple/files/ld64-128.2-stdlib.patch b/sys-devel/binutils-apple/files/ld64-128.2-stdlib.patch
new file mode 100644
index 000000000000..8bbcb46cf9c5
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-128.2-stdlib.patch
@@ -0,0 +1,14 @@
+Patch by Linlin Yan <yanlinlin82@gmail.com>
+
+https://bugs.gentoo.org/show_bug.cgi?id=490932
+
+--- ld64-128.2/src/other/rebase.cpp
++++ ld64-128.2/src/other/rebase.cpp
+@@ -29,6 +29,7 @@
+ #include <limits.h>
+ #include <stdarg.h>
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <unistd.h>
diff --git a/sys-devel/binutils-apple/files/ld64-136-Makefile b/sys-devel/binutils-apple/files/ld64-136-Makefile
new file mode 100644
index 000000000000..948c705503ae
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-136-Makefile
@@ -0,0 +1,48 @@
+CPPFLAGS += "-DCPU_SUBTYPE_X86_ALL=((cpu_subtype_t)3)" -Iinclude -Iabstraction -Ild -Ild/parsers -Iother -I.
+
+# dropped machocheck due to compilation failures
+all: rebase unwinddump dyldinfo ld64 ObjectDump
+
+libprunetrie.a: other/PruneTrie.o other/prune_trie.h
+ $(AR) -s -r -c libprunetrie.a other/PruneTrie.o
+
+LD64LIBS=ld/parsers/archive_file.o ld/parsers/macho_relocatable_file.o \
+ ld/parsers/opaque_section_file.o \
+ ld/parsers/macho_dylib_file.o \
+ ld/passes/branch_island.o ld/passes/dylibs.o ld/passes/order.o \
+ ld/passes/branch_shim.o ld/passes/got.o ld/passes/tlvp.o \
+ ld/passes/compact_unwind.o ld/passes/huge.o \
+ ld/passes/dtrace_dof.o ld/passes/objc.o \
+ ld/passes/stubs/stubs.o \
+ ld/InputFiles.o ld/OutputFile.o ld/SymbolTable.o \
+ ld/Snapshot.o \
+ ld/Options.o ld/Resolver.o ld/debugline.o ld/ld.o
+
+ifeq ($(LTO),1)
+CPPFLAGS += "-DLTO"
+LTO_OBJ = ld/parsers/lto_file.o
+LIBLTO = -lLTO
+else
+CPPFLAGS += "-ULTO"
+LTO_OBJ =
+LIBLTO =
+endif
+
+ld64: libprunetrie.a version.o $(LD64LIBS) $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+rebase: other/rebase.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+dyldinfo: other/dyldinfo.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+unwinddump: other/unwinddump.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+ObjectDump: other/ObjectDump.o ld/debugline.o ld/parsers/macho_relocatable_file.o $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+machocheck: other/machochecker.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
diff --git a/sys-devel/binutils-apple/files/ld64-136-compile_stubs.h b/sys-devel/binutils-apple/files/ld64-136-compile_stubs.h
new file mode 100644
index 000000000000..8cd430adb9eb
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-136-compile_stubs.h
@@ -0,0 +1,53 @@
+static const char *compile_stubs =
+"#!/bin/csh\n"
+"\n"
+"# Attempt to find the architecture.\n"
+"# First look through the command line args.\n"
+"set arch=unknown\n"
+"set link_cmd=(`cat link_command`)\n"
+"while ( $#link_cmd > 0 )\n"
+" if ( \"$link_cmd[1]\" == \"-arch\" ) then\n"
+" set arch=$link_cmd[2]\n"
+" endif\n"
+" shift link_cmd\n"
+"end\n"
+"\n"
+"# look for an explicit arch file\n"
+"if ( \"$arch\" == \"unknown\" ) then\n"
+" if ( -e arch ) then\n"
+" set arch=`cat arch`\n"
+" endif\n"
+"endif\n"
+"\n"
+"if ( \"$arch\" == \"unknown\" ) then\n"
+"echo \"***** Unable to determine architecture.\"\n"
+"exit 1\n"
+"endif \n"
+"\n"
+"# Create .dylibs for each file in the dylib_stubs directory.\n"
+"if ( -e dylib_stubs ) then\n"
+" set files=`cd dylib_stubs ; echo *`\n"
+" mkdir -p dylibs\n"
+" foreach file ($files)\n"
+" if ( ! -e dylibs/$file ) then\n"
+" clang -arch $arch -c -fno-builtin -o tmp_object.o -x c dylib_stubs/$file\n"
+" ld -arch $arch -dylib -macosx_version_min 10.1 -no_version_load_command -o dylibs/$file tmp_object.o\n"
+" endif\n"
+" end\n"
+"endif\n"
+"\n"
+"# Create .frameworks for each file in the framework_stubs directory.\n"
+"if ( -e framework_stubs ) then\n"
+" set files=`cd framework_stubs ; echo *`\n"
+" foreach file ($files)\n"
+" if ( ! -e frameworks/$file.framework ) then\n"
+" clang -arch $arch -c -fno-builtin -o tmp_object.o -x c framework_stubs/$file\n"
+" mkdir -p frameworks/$file.framework\n"
+" ld -arch $arch -dylib -macosx_version_min 10.1 -no_version_load_command -o frameworks/$file.framework/$file tmp_object.o\n"
+" endif\n"
+" end\n"
+"endif\n"
+"\n"
+"# Clean up.\n"
+"rm -f tmp_object.o\n"
+;
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-Makefile b/sys-devel/binutils-apple/files/ld64-236.3-Makefile
new file mode 100644
index 000000000000..1f35c8ff9f39
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-Makefile
@@ -0,0 +1,51 @@
+CPPFLAGS += -Iinclude -Iabstraction -Ild -Ild/parsers -Iother -I.
+
+# some files generate warnings about applying offsetof to a non-POD type.
+# Upstream seems aware of that and ignores by setting
+# GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO in the xcode project.
+CXXFLAGS += -Wno-invalid-offsetof
+
+all: rebase unwinddump dyldinfo ld64 ObjectDump machocheck
+
+libprunetrie.a: other/PruneTrie.o other/prune_trie.h
+ $(AR) -s -r -c libprunetrie.a other/PruneTrie.o
+
+LD64LIBS=ld/parsers/archive_file.o ld/parsers/macho_relocatable_file.o \
+ ld/parsers/opaque_section_file.o \
+ ld/parsers/macho_dylib_file.o \
+ ld/passes/branch_island.o ld/passes/dylibs.o ld/passes/order.o \
+ ld/passes/branch_shim.o ld/passes/got.o ld/passes/tlvp.o \
+ ld/passes/compact_unwind.o ld/passes/huge.o \
+ ld/passes/dtrace_dof.o ld/passes/objc.o \
+ ld/passes/stubs/stubs.o \
+ ld/InputFiles.o ld/OutputFile.o ld/SymbolTable.o \
+ ld/Snapshot.o \
+ ld/Options.o ld/Resolver.o ld/debugline.o ld/ld.o
+
+ifeq ($(LTO),1)
+CPPFLAGS += -DLTO
+LTO_OBJ = ld/parsers/lto_file.o
+LIBLTO = -lLTO
+else
+LTO_OBJ =
+LIBLTO =
+endif
+
+ld64: libprunetrie.a version.o $(LD64LIBS) $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+rebase: other/rebase.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+dyldinfo: other/dyldinfo.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+unwinddump: other/unwinddump.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+ObjectDump: other/ObjectDump.o ld/debugline.o ld/parsers/macho_relocatable_file.o $(LTO_OBJ)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBLTO) -o $@ $^
+
+machocheck: other/machochecker.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-arm64-fixup.patch b/sys-devel/binutils-apple/files/ld64-236.3-arm64-fixup.patch
new file mode 100644
index 000000000000..b64e52906f4f
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-arm64-fixup.patch
@@ -0,0 +1,17 @@
+Use correct enum values (backport from 241.9).
+
+--- ld64-236.3/src/other/ObjectDump.cpp.orig 2014-11-12 21:17:01.000000000 +0100
++++ ld64-236.3/src/other/ObjectDump.cpp 2014-11-12 21:17:44.000000000 +0100
+@@ -995,10 +995,10 @@
+ case ld::Fixup::kindStoreTargetAddressARM64PageOff12:
+ printf("ARM64 store 12-bit page offset of %s", referenceTargetAtomName(ref));
+ break;
+- case ld::Fixup::kindStoreTargetAddressARM64TLVPage21:
++ case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPage21:
+ printf("ARM64 store 21-bit pcrel ADRP to TLV for %s", referenceTargetAtomName(ref));
+ break;
+- case ld::Fixup::kindStoreTargetAddressARM64TLVPageOff12:
++ case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPageOff12:
+ printf("ARM64 store 12-bit page offset of TLV of %s", referenceTargetAtomName(ref));
+ break;
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPage21:
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-constant-types.patch b/sys-devel/binutils-apple/files/ld64-236.3-constant-types.patch
new file mode 100644
index 000000000000..c4c5e0d113c8
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-constant-types.patch
@@ -0,0 +1,61 @@
+Avoid error with gcc on 32bit platforms:
+ld/LinkEdit.hpp:1329: error: integer constant is too large for 'long' type
+
+--- ./ld64-236.3/src/ld/LinkEdit.hpp.orig 2015-01-14 18:00:49.000000000 +0100
++++ ./ld64-236.3/src/ld/LinkEdit.hpp 2015-01-14 18:02:23.000000000 +0100
+@@ -1326,7 +1326,7 @@
+ void FunctionStartsAtom<A>::encode() const
+ {
+ this->_encodedData.reserve(8192);
+- const uint64_t badAddress = 0xFFFFFFFFFFFFFFFF;
++ const uint64_t badAddress = 0xFFFFFFFFFFFFFFFFULL;
+ uint64_t addr = badAddress;
+ // delta compress all function addresses
+ for (std::vector<ld::Internal::FinalSection*>::iterator it = this->_state.sections.begin(); it != this->_state.sections.end(); ++it) {
+--- ./ld64-236.3/src/ld/Options.cpp.orig 2015-01-14 18:01:12.000000000 +0100
++++ ./ld64-236.3/src/ld/Options.cpp 2015-01-14 18:02:09.000000000 +0100
+@@ -4173,7 +4173,7 @@
+ switch (fArchitecture) {
+ case CPU_TYPE_I386:
+ case CPU_TYPE_ARM:
+- if ( fStackAddr > 0xFFFFFFFF )
++ if ( fStackAddr > 0xFFFFFFFFULL )
+ throw "-stack_addr must be < 4G for 32-bit processes";
+ break;
+ case CPU_TYPE_X86_64:
+@@ -4193,29 +4193,29 @@
+ if ( fStackSize > 0xFFFFFFFF )
+ throw "-stack_size must be < 4G for 32-bit processes";
+ if ( fStackAddr == 0 ) {
+- fStackAddr = 0xC0000000;
++ fStackAddr = 0xC0000000ULL;
+ }
+- if ( (fStackAddr > 0xB0000000) && ((fStackAddr-fStackSize) < 0xB0000000) )
++ if ( (fStackAddr > 0xB0000000ULL) && ((fStackAddr-fStackSize) < 0xB0000000ULL) )
+ warning("custom stack placement overlaps and will disable shared region");
+ break;
+ case CPU_TYPE_ARM:
+ if ( fStackSize > 0x2F000000 )
+ throw "-stack_size must be < 752MB";
+ if ( fStackAddr == 0 )
+- fStackAddr = 0x2F000000;
+- if ( fStackAddr > 0x30000000)
++ fStackAddr = 0x2F000000ULL;
++ if ( fStackAddr > 0x30000000ULL)
+ throw "-stack_addr must be < 0x30000000 for arm";
+ break;
+ case CPU_TYPE_X86_64:
+ if ( fStackAddr == 0 ) {
+- fStackAddr = 0x00007FFF5C000000LL;
++ fStackAddr = 0x00007FFF5C000000ULL;
+ }
+ break;
+ case CPU_TYPE_ARM64:
+ if ( fStackSize > 0x20000000 )
+ throw "-stack_size must be < 512MB";
+ if ( fStackAddr == 0 ) {
+- fStackAddr = 0x120000000;
++ fStackAddr = 0x120000000ULL;
+ }
+ break;
+ }
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-crashreporter.patch b/sys-devel/binutils-apple/files/ld64-236.3-crashreporter.patch
new file mode 100644
index 000000000000..f8b42b459b6f
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-crashreporter.patch
@@ -0,0 +1,23 @@
+Allow to disable crash reporter
+
+diff -ur ld64-236.3/src/ld/Options.cpp ld64-236.3/src/ld/Options.cpp
+--- ld64-236.3/src/ld/Options.cpp 2014-08-29 16:40:18.000000000 +0200
++++ ld64-236.3/src/ld/Options.cpp 2014-08-29 16:35:36.000000000 +0200
+@@ -54,7 +54,7 @@
+ // magic to place command line in crash reports
+ const int crashreporterBufferSize = 2000;
+ static char crashreporterBuffer[crashreporterBufferSize];
+-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
++#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && defined(SUPPORT_CRASHREPORTER)
+ #include <CrashReporterClient.h>
+ // hack until ld does not need to build on 10.6 anymore
+ struct crashreporter_annotations_t gCRAnnotations
+@@ -4564,7 +4564,7 @@
+ bool newLinker = false;
+
+ // build command line buffer in case ld crashes
+-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
++#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && defined(SUPPORT_CRASHREPORTER)
+ CRSetCrashLogMessage(crashreporterBuffer);
+ #endif
+ const char* srcRoot = getenv("SRCROOT");
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-gcc.patch b/sys-devel/binutils-apple/files/ld64-236.3-gcc.patch
new file mode 100644
index 000000000000..1e1f578ca354
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-gcc.patch
@@ -0,0 +1,1038 @@
+Provide c++11 headers from tr1 include directory and namespace.
+
+Work around weird namespacing bug in gcc-4.2.1 where class ld::Section
+conflicts with template mach_o::relocatable::Section by renaming the latter to
+MRFSection (could possibly be done using sed from ebuild or avoided by figuring
+out, what's actually going on with those namespaces).
+
+diff -ur ld64-236.3.orig/src/ld/InputFiles.h ld64-236.3/src/ld/InputFiles.h
+--- ld64-236.3.orig/src/ld/InputFiles.h 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/InputFiles.h 2015-01-11 22:43:08.000000000 +0100
+@@ -46,6 +46,14 @@
+ #include <pthread.h>
+ #endif
+
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
++#include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
++
+ #include <vector>
+
+ #include "Options.h"
+@@ -107,7 +115,7 @@
+ static void parseWorkerThread(InputFiles *inputFiles);
+ void startThread(void (*threadFunc)(InputFiles *)) const;
+
+- typedef std::unordered_map<const char*, ld::dylib::File*, CStringHash, CStringEquals> InstallNameToDylib;
++ typedef std::UNORDERED_MAP<const char*, ld::dylib::File*, CStringHash, CStringEquals> InstallNameToDylib;
+
+ const Options& _options;
+ std::vector<ld::File*> _inputFiles;
+diff -ur ld64-236.3.orig/src/ld/LinkEditClassic.hpp ld64-236.3/src/ld/LinkEditClassic.hpp
+--- ld64-236.3.orig/src/ld/LinkEditClassic.hpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/LinkEditClassic.hpp 2015-01-11 22:44:04.000000000 +0100
+@@ -31,8 +31,13 @@
+ #include <limits.h>
+ #include <unistd.h>
+
+-#include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+
+ #include "Options.h"
+ #include "ld.hpp"
+@@ -92,7 +97,7 @@
+
+ private:
+ enum { kBufferSize = 0x01000000 };
+- typedef std::unordered_map<const char*, int32_t, CStringHash, CStringEquals> StringToOffset;
++ typedef std::UNORDERED_MAP<const char*, int32_t, CStringHash, CStringEquals> StringToOffset;
+
+ const uint32_t _pointerSize;
+ std::vector<char*> _fullBuffers;
+diff -ur ld64-236.3.orig/src/ld/Options.cpp ld64-236.3/src/ld/Options.cpp
+--- ld64-236.3.orig/src/ld/Options.cpp 2015-01-11 17:35:08.000000000 +0100
++++ ld64-236.3/src/ld/Options.cpp 2015-01-11 22:47:34.000000000 +0100
+@@ -4335,7 +4335,7 @@
+
+ // make sure all required exported symbols exist
+ std::vector<const char*> impliedExports;
+- for (NameSet::iterator it=fExportSymbols.regularBegin(); it != fExportSymbols.regularEnd(); ++it) {
++ for (NameSet::const_iterator it=fExportSymbols.regularBegin(); it != fExportSymbols.regularEnd(); ++it) {
+ const char* name = *it;
+ const int len = strlen(name);
+ if ( (strcmp(&name[len-3], ".eh") == 0) || (strncmp(name, ".objc_category_name_", 20) == 0) ) {
+@@ -4367,7 +4367,7 @@
+ }
+
+ // make sure all required re-exported symbols exist
+- for (NameSet::iterator it=fReExportSymbols.regularBegin(); it != fReExportSymbols.regularEnd(); ++it) {
++ for (NameSet::const_iterator it=fReExportSymbols.regularBegin(); it != fReExportSymbols.regularEnd(); ++it) {
+ fInitialUndefines.push_back(*it);
+ }
+
+diff -ur ld64-236.3.orig/src/ld/Options.h ld64-236.3/src/ld/Options.h
+--- ld64-236.3.orig/src/ld/Options.h 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/Options.h 2015-01-11 22:44:00.000000000 +0100
+@@ -30,8 +30,17 @@
+ #include <mach/machine.h>
+
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "ld.hpp"
+ #include "Snapshot.h"
+@@ -376,8 +385,8 @@
+ const std::vector<SectionRename>& sectionRenames() const { return fSectionRenames; }
+
+ private:
+- typedef std::unordered_map<const char*, unsigned int, ld::CStringHash, ld::CStringEquals> NameToOrder;
+- typedef std::unordered_set<const char*, ld::CStringHash, ld::CStringEquals> NameSet;
++ typedef std::UNORDERED_MAP<const char*, unsigned int, ld::CStringHash, ld::CStringEquals> NameToOrder;
++ typedef std::UNORDERED_SET<const char*, ld::CStringHash, ld::CStringEquals> NameSet;
+ enum ExportMode { kExportDefault, kExportSome, kDontExportSome };
+ enum LibrarySearchMode { kSearchDylibAndArchiveInEachDir, kSearchAllDirsForDylibsThenAllDirsForArchives };
+ enum InterposeMode { kInterposeNone, kInterposeAllExternal, kInterposeSome };
+@@ -389,8 +398,8 @@
+ bool containsNonWildcard(const char*) const;
+ bool empty() const { return fRegular.empty() && fWildCard.empty(); }
+ bool hasWildCards() const { return !fWildCard.empty(); }
+- NameSet::iterator regularBegin() const { return fRegular.begin(); }
+- NameSet::iterator regularEnd() const { return fRegular.end(); }
++ NameSet::const_iterator regularBegin() const { return fRegular.begin(); }
++ NameSet::const_iterator regularEnd() const { return fRegular.end(); }
+ void remove(const NameSet&);
+ private:
+ static bool hasWildCards(const char*);
+diff -ur ld64-236.3.orig/src/ld/OutputFile.cpp ld64-236.3/src/ld/OutputFile.cpp
+--- ld64-236.3.orig/src/ld/OutputFile.cpp 2015-01-11 17:35:08.000000000 +0100
++++ ld64-236.3/src/ld/OutputFile.cpp 2015-01-12 00:24:43.000000000 +0100
+@@ -50,7 +50,13 @@
+ #include <vector>
+ #include <list>
+ #include <algorithm>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include <CommonCrypto/CommonDigest.h>
+ #include <AvailabilityMacros.h>
+@@ -4699,7 +4705,7 @@
+ const char* filename = NULL;
+ bool wroteStartSO = false;
+ state.stabs.reserve(atomsNeedingDebugNotes.size()*4);
+- std::unordered_set<const char*, CStringHash, CStringEquals> seenFiles;
++ std::UNORDERED_SET<const char*, CStringHash, CStringEquals> seenFiles;
+ for (std::vector<const ld::Atom*>::iterator it=atomsNeedingDebugNotes.begin(); it != atomsNeedingDebugNotes.end(); it++) {
+ const ld::Atom* atom = *it;
+ const ld::File* atomFile = atom->file();
+diff -ur ld64-236.3.orig/src/ld/Resolver.h ld64-236.3/src/ld/Resolver.h
+--- ld64-236.3.orig/src/ld/Resolver.h 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/Resolver.h 2015-01-11 22:49:14.000000000 +0100
+@@ -42,7 +42,13 @@
+ #include <mach-o/dyld.h>
+
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "Options.h"
+ #include "ld.hpp"
+@@ -103,7 +109,7 @@
+ void doLinkerOption(const std::vector<const char*>& linkerOption, const char* fileName);
+ void dumpAtoms();
+
+- typedef std::unordered_set<const char*, CStringHash, CStringEquals> StringSet;
++ typedef std::UNORDERED_SET<const char*, CStringHash, CStringEquals> StringSet;
+
+ class NotLive {
+ public:
+diff -ur ld64-236.3.orig/src/ld/SymbolTable.h ld64-236.3/src/ld/SymbolTable.h
+--- ld64-236.3.orig/src/ld/SymbolTable.h 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/SymbolTable.h 2015-01-11 22:46:19.000000000 +0100
+@@ -42,7 +42,13 @@
+ #include <mach-o/dyld.h>
+
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+
+ #include "Options.h"
+ #include "ld.hpp"
+@@ -57,38 +63,38 @@
+ typedef uint32_t IndirectBindingSlot;
+
+ private:
+- typedef std::unordered_map<const char*, IndirectBindingSlot, CStringHash, CStringEquals> NameToSlot;
++ typedef std::UNORDERED_MAP<const char*, IndirectBindingSlot, CStringHash, CStringEquals> NameToSlot;
+
+ class ContentFuncs {
+ public:
+ size_t operator()(const ld::Atom*) const;
+ bool operator()(const ld::Atom* left, const ld::Atom* right) const;
+ };
+- typedef std::unordered_map<const ld::Atom*, IndirectBindingSlot, ContentFuncs, ContentFuncs> ContentToSlot;
++ typedef std::UNORDERED_MAP<const ld::Atom*, IndirectBindingSlot, ContentFuncs, ContentFuncs> ContentToSlot;
+
+ class ReferencesHashFuncs {
+ public:
+ size_t operator()(const ld::Atom*) const;
+ bool operator()(const ld::Atom* left, const ld::Atom* right) const;
+ };
+- typedef std::unordered_map<const ld::Atom*, IndirectBindingSlot, ReferencesHashFuncs, ReferencesHashFuncs> ReferencesToSlot;
++ typedef std::UNORDERED_MAP<const ld::Atom*, IndirectBindingSlot, ReferencesHashFuncs, ReferencesHashFuncs> ReferencesToSlot;
+
+ class CStringHashFuncs {
+ public:
+ size_t operator()(const ld::Atom*) const;
+ bool operator()(const ld::Atom* left, const ld::Atom* right) const;
+ };
+- typedef std::unordered_map<const ld::Atom*, IndirectBindingSlot, CStringHashFuncs, CStringHashFuncs> CStringToSlot;
++ typedef std::UNORDERED_MAP<const ld::Atom*, IndirectBindingSlot, CStringHashFuncs, CStringHashFuncs> CStringToSlot;
+
+ class UTF16StringHashFuncs {
+ public:
+ size_t operator()(const ld::Atom*) const;
+ bool operator()(const ld::Atom* left, const ld::Atom* right) const;
+ };
+- typedef std::unordered_map<const ld::Atom*, IndirectBindingSlot, UTF16StringHashFuncs, UTF16StringHashFuncs> UTF16StringToSlot;
++ typedef std::UNORDERED_MAP<const ld::Atom*, IndirectBindingSlot, UTF16StringHashFuncs, UTF16StringHashFuncs> UTF16StringToSlot;
+
+ typedef std::map<IndirectBindingSlot, const char*> SlotToName;
+- typedef std::unordered_map<const char*, CStringToSlot*, CStringHash, CStringEquals> NameToMap;
++ typedef std::UNORDERED_MAP<const char*, CStringToSlot*, CStringHash, CStringEquals> NameToMap;
+
+ typedef std::vector<const ld::Atom *> DuplicatedSymbolAtomList;
+ typedef std::map<const char *, DuplicatedSymbolAtomList * > DuplicateSymbols;
+diff -ur ld64-236.3.orig/src/ld/ld.cpp ld64-236.3/src/ld/ld.cpp
+--- ld64-236.3.orig/src/ld/ld.cpp 2015-01-11 17:35:08.000000000 +0100
++++ ld64-236.3/src/ld/ld.cpp 2015-01-11 22:42:58.000000000 +0100
+@@ -54,7 +54,13 @@
+ #include <vector>
+ #include <list>
+ #include <algorithm>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+ #include <cxxabi.h>
+
+ #include "Options.h"
+@@ -150,7 +156,7 @@
+ struct SectionEquals {
+ bool operator()(const ld::Section* left, const ld::Section* right) const;
+ };
+- typedef std::unordered_map<const ld::Section*, FinalSection*, SectionHash, SectionEquals> SectionInToOut;
++ typedef std::UNORDERED_MAP<const ld::Section*, FinalSection*, SectionHash, SectionEquals> SectionInToOut;
+
+
+ SectionInToOut _sectionInToFinalMap;
+diff -ur ld64-236.3.orig/src/ld/ld.hpp ld64-236.3/src/ld/ld.hpp
+--- ld64-236.3.orig/src/ld/ld.hpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/ld.hpp 2015-01-11 22:42:46.000000000 +0100
+@@ -32,7 +32,13 @@
+ #include <assert.h>
+
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "configure.h"
+
+@@ -821,7 +827,7 @@
+ bool operator()(const char* left, const char* right) const { return (strcmp(left, right) == 0); }
+ };
+
+-typedef std::unordered_set<const char*, ld::CStringHash, ld::CStringEquals> CStringSet;
++typedef std::UNORDERED_SET<const char*, ld::CStringHash, ld::CStringEquals> CStringSet;
+
+ class Internal
+ {
+diff -ur ld64-236.3.orig/src/ld/parsers/archive_file.cpp ld64-236.3/src/ld/parsers/archive_file.cpp
+--- ld64-236.3.orig/src/ld/parsers/archive_file.cpp 2015-01-11 17:35:08.000000000 +0100
++++ ld64-236.3/src/ld/parsers/archive_file.cpp 2015-01-11 22:41:37.000000000 +0100
+@@ -33,7 +33,13 @@
+ #include <set>
+ #include <map>
+ #include <algorithm>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+
+ #include "MachOFileAbstraction.hpp"
+ #include "Architectures.hpp"
+@@ -116,7 +122,7 @@
+ struct MemberState { ld::relocatable::File* file; const Entry *entry; bool logged; bool loaded; uint32_t index;};
+ bool loadMember(MemberState& state, ld::File::AtomHandler& handler, const char *format, ...) const;
+
+- typedef std::unordered_map<const char*, const struct ranlib*, ld::CStringHash, ld::CStringEquals> NameToEntryMap;
++ typedef std::UNORDERED_MAP<const char*, const struct ranlib*, ld::CStringHash, ld::CStringEquals> NameToEntryMap;
+
+ typedef typename A::P P;
+ typedef typename A::P::E E;
+diff -ur ld64-236.3.orig/src/ld/parsers/lto_file.cpp ld64-236.3/src/ld/parsers/lto_file.cpp
+--- ld64-236.3.orig/src/ld/parsers/lto_file.cpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/parsers/lto_file.cpp 2015-01-11 22:44:48.000000000 +0100
+@@ -33,8 +33,17 @@
+ #include <pthread.h>
+ #include <mach-o/dyld.h>
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "MachOFileAbstraction.hpp"
+ #include "Architectures.hpp"
+@@ -217,8 +226,8 @@
+ static void ltoDiagnosticHandler(lto_codegen_diagnostic_severity_t, const char*, void*);
+ #endif
+
+- typedef std::unordered_set<const char*, ld::CStringHash, ld::CStringEquals> CStringSet;
+- typedef std::unordered_map<const char*, Atom*, ld::CStringHash, ld::CStringEquals> CStringToAtom;
++ typedef std::UNORDERED_SET<const char*, ld::CStringHash, ld::CStringEquals> CStringSet;
++ typedef std::UNORDERED_MAP<const char*, Atom*, ld::CStringHash, ld::CStringEquals> CStringToAtom;
+
+ class AtomSyncer : public ld::File::AtomHandler {
+ public:
+diff -ur ld64-236.3.orig/src/ld/parsers/macho_dylib_file.cpp ld64-236.3/src/ld/parsers/macho_dylib_file.cpp
+--- ld64-236.3.orig/src/ld/parsers/macho_dylib_file.cpp 2015-01-11 17:35:08.000000000 +0100
++++ ld64-236.3/src/ld/parsers/macho_dylib_file.cpp 2015-01-11 22:45:17.000000000 +0100
+@@ -34,8 +34,17 @@
+ #include <vector>
+ #include <set>
+ #include <algorithm>
+-#include <unordered_map>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "Architectures.hpp"
+ #include "MachOFileAbstraction.hpp"
+@@ -189,8 +198,8 @@
+ };
+ };
+ struct AtomAndWeak { ld::Atom* atom; bool weakDef; bool tlv; pint_t address; };
+- typedef std::unordered_map<const char*, AtomAndWeak, ld::CStringHash, ld::CStringEquals> NameToAtomMap;
+- typedef std::unordered_set<const char*, CStringHash, ld::CStringEquals> NameSet;
++ typedef std::UNORDERED_MAP<const char*, AtomAndWeak, ld::CStringHash, ld::CStringEquals> NameToAtomMap;
++ typedef std::UNORDERED_SET<const char*, CStringHash, ld::CStringEquals> NameSet;
+
+ struct Dependent { const char* path; File<A>* dylib; bool reExport; };
+
+@@ -548,14 +557,18 @@
+ if ( _s_logHashtable ) fprintf(stderr, "ld: building hashtable of %u toc entries for %s\n", dynamicInfo->nextdefsym(), this->path());
+ const macho_nlist<P>* start = &symbolTable[dynamicInfo->iextdefsym()];
+ const macho_nlist<P>* end = &start[dynamicInfo->nextdefsym()];
++#ifndef __GLIBCXX__
+ _atoms.reserve(dynamicInfo->nextdefsym()); // set initial bucket count
++#endif
+ for (const macho_nlist<P>* sym=start; sym < end; ++sym) {
+ this->addSymbol(&strings[sym->n_strx()], (sym->n_desc() & N_WEAK_DEF) != 0, false, sym->n_value());
+ }
+ }
+ else {
+ int32_t count = dynamicInfo->ntoc();
++#ifndef __GLIBCXX__
+ _atoms.reserve(count); // set initial bucket count
++#endif
+ if ( _s_logHashtable ) fprintf(stderr, "ld: building hashtable of %u entries for %s\n", count, this->path());
+ const struct dylib_table_of_contents* toc = (dylib_table_of_contents*)(fileContent + dynamicInfo->tocoff());
+ for (int32_t i = 0; i < count; ++i) {
+diff -ur ld64-236.3.orig/src/ld/parsers/macho_relocatable_file.cpp ld64-236.3/src/ld/parsers/macho_relocatable_file.cpp
+--- ld64-236.3.orig/src/ld/parsers/macho_relocatable_file.cpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/parsers/macho_relocatable_file.cpp 2015-01-11 23:08:13.000000000 +0100
+@@ -62,7 +62,7 @@
+ // forward reference
+ template <typename A> class Parser;
+ template <typename A> class Atom;
+-template <typename A> class Section;
++template <typename A> class MRFSection;
+ template <typename A> class CFISection;
+ template <typename A> class CUSection;
+
+@@ -100,14 +100,14 @@
+ const uint8_t* fileContent() { return _fileContent; }
+ private:
+ friend class Atom<A>;
+- friend class Section<A>;
++ friend class MRFSection<A>;
+ friend class Parser<A>;
+ friend class CFISection<A>::OAS;
+
+ typedef typename A::P P;
+
+ const uint8_t* _fileContent;
+- Section<A>** _sectionsArray;
++ MRFSection<A>** _sectionsArray;
+ uint8_t* _atomsArray;
+ uint32_t _sectionsArrayCount;
+ uint32_t _atomsArrayCount;
+@@ -129,14 +129,14 @@
+
+
+ template <typename A>
+-class Section : public ld::Section
++class MRFSection : public ld::Section
+ {
+ public:
+ typedef typename A::P::uint_t pint_t;
+ typedef typename A::P P;
+ typedef typename A::P::E E;
+
+- virtual ~Section() { }
++ virtual ~MRFSection() { }
+ class File<A>& file() const { return _file; }
+ const macho_section<P>* machoSection() const { return _machOSection; }
+ uint32_t sectionNum(class Parser<A>&) const;
+@@ -160,10 +160,10 @@
+ static const char* makeSectionName(const macho_section<typename A::P>* s);
+
+ protected:
+- Section(File<A>& f, const macho_section<typename A::P>* s)
++ MRFSection(File<A>& f, const macho_section<typename A::P>* s)
+ : ld::Section(makeSegmentName(s), makeSectionName(s), sectionType(s)),
+ _file(f), _machOSection(s), _beginAtoms(NULL), _endAtoms(NULL), _hasAliases(false) { }
+- Section(File<A>& f, const char* segName, const char* sectName, ld::Section::Type t, bool hidden=false)
++ MRFSection(File<A>& f, const char* segName, const char* sectName, ld::Section::Type t, bool hidden=false)
+ : ld::Section(segName, sectName, t, hidden), _file(f), _machOSection(NULL),
+ _beginAtoms(NULL), _endAtoms(NULL), _hasAliases(false) { }
+
+@@ -186,11 +186,11 @@
+
+
+ template <typename A>
+-class CFISection : public Section<A>
++class CFISection : public MRFSection<A>
+ {
+ public:
+ CFISection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s)
+- : Section<A>(f, s) { }
++ : MRFSection<A>(f, s) { }
+ uint32_t cfiCount();
+
+ virtual ld::Atom::ContentType contentType() { return ld::Atom::typeCFI; }
+@@ -250,11 +250,11 @@
+
+
+ template <typename A>
+-class CUSection : public Section<A>
++class CUSection : public MRFSection<A>
+ {
+ public:
+ CUSection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s)
+- : Section<A>(f, s) { }
++ : MRFSection<A>(f, s) { }
+
+ typedef typename A::P::uint_t pint_t;
+ typedef typename A::P P;
+@@ -291,11 +291,11 @@
+
+
+ template <typename A>
+-class TentativeDefinitionSection : public Section<A>
++class TentativeDefinitionSection : public MRFSection<A>
+ {
+ public:
+ TentativeDefinitionSection(Parser<A>& parser, File<A>& f)
+- : Section<A>(f, "__DATA", "__comm/tent", ld::Section::typeTentativeDefs) {}
++ : MRFSection<A>(f, "__DATA", "__comm/tent", ld::Section::typeTentativeDefs) {}
+
+ virtual ld::Atom::ContentType contentType() { return ld::Atom::typeZeroFill; }
+ virtual bool addFollowOnFixups() const { return false; }
+@@ -313,11 +313,11 @@
+
+
+ template <typename A>
+-class AbsoluteSymbolSection : public Section<A>
++class AbsoluteSymbolSection : public MRFSection<A>
+ {
+ public:
+ AbsoluteSymbolSection(Parser<A>& parser, File<A>& f)
+- : Section<A>(f, "__DATA", "__abs", ld::Section::typeAbsoluteSymbols, true) {}
++ : MRFSection<A>(f, "__DATA", "__abs", ld::Section::typeAbsoluteSymbols, true) {}
+
+ virtual ld::Atom::ContentType contentType() { return ld::Atom::typeUnclassified; }
+ virtual bool dontDeadStrip() { return false; }
+@@ -339,7 +339,7 @@
+
+
+ template <typename A>
+-class SymboledSection : public Section<A>
++class SymboledSection : public MRFSection<A>
+ {
+ public:
+ SymboledSection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s);
+@@ -371,11 +371,11 @@
+
+
+ template <typename A>
+-class ImplicitSizeSection : public Section<A>
++class ImplicitSizeSection : public MRFSection<A>
+ {
+ public:
+ ImplicitSizeSection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s)
+- : Section<A>(f, s) { }
++ : MRFSection<A>(f, s) { }
+ virtual uint32_t computeAtomCount(class Parser<A>& parser, struct Parser<A>::LabelAndCFIBreakIterator& it, const struct Parser<A>::CFI_CU_InfoArrays&);
+ virtual uint32_t appendAtoms(class Parser<A>& parser, uint8_t* buffer, struct Parser<A>::LabelAndCFIBreakIterator& it, const struct Parser<A>::CFI_CU_InfoArrays&);
+ protected:
+@@ -709,8 +709,8 @@
+
+ public:
+ // methods for all atoms from mach-o object file
+- Section<A>& sect() const { return (Section<A>&)section(); }
+- File<A>& machofile() const { return ((Section<A>*)(this->_section))->file(); }
++ MRFSection<A>& sect() const { return (MRFSection<A>&)section(); }
++ File<A>& machofile() const { return ((MRFSection<A>*)(this->_section))->file(); }
+ void setFixupsRange(uint32_t s, uint32_t c);
+ void setUnwindInfoRange(uint32_t s, uint32_t c);
+ void extendUnwindInfoRange();
+@@ -727,7 +727,7 @@
+ typedef typename A::P::E E;
+ typedef typename A::P::uint_t pint_t;
+ // constuct via all attributes
+- Atom(Section<A>& sct, const char* nm, pint_t addr, uint64_t sz,
++ Atom(MRFSection<A>& sct, const char* nm, pint_t addr, uint64_t sz,
+ ld::Atom::Definition d, ld::Atom::Combine c, ld::Atom::Scope s,
+ ld::Atom::ContentType ct, ld::Atom::SymbolTableInclusion i,
+ bool dds, bool thumb, bool al, ld::Atom::Alignment a)
+@@ -737,7 +737,7 @@
+ _unwindInfoStartIndex(0), _fixupsCount(0),
+ _lineInfoCount(0), _unwindInfoCount(0) { }
+ // construct via symbol table entry
+- Atom(Section<A>& sct, Parser<A>& parser, const macho_nlist<P>& sym,
++ Atom(MRFSection<A>& sct, Parser<A>& parser, const macho_nlist<P>& sym,
+ uint64_t sz, bool alias=false)
+ : ld::Atom((ld::Section&)sct, parser.definitionFromSymbol(sym),
+ parser.combineFromSymbol(sym), parser.scopeFromSymbol(sym),
+@@ -760,7 +760,7 @@
+
+ private:
+ friend class Parser<A>;
+- friend class Section<A>;
++ friend class MRFSection<A>;
+ friend class CStringSection<A>;
+ friend class AbsoluteSymbolSection<A>;
+
+@@ -991,8 +991,8 @@
+ uint32_t undefinedStartIndex() { return _undefinedStartIndex; }
+ uint32_t undefinedEndIndex() { return _undefinedEndIndex; }
+ void addFixup(FixupInAtom f) { _allFixups.push_back(f); }
+- Section<A>* sectionForNum(unsigned int sectNum);
+- Section<A>* sectionForAddress(pint_t addr);
++ MRFSection<A>* sectionForNum(unsigned int sectNum);
++ MRFSection<A>* sectionForAddress(pint_t addr);
+ Atom<A>* findAtomByAddress(pint_t addr);
+ Atom<A>* findAtomByAddressOrNullIfStub(pint_t addr);
+ Atom<A>* findAtomByAddressOrLocalTargetOfStub(pint_t addr, uint32_t* offsetInAtom);
+@@ -1034,7 +1034,7 @@
+ : sortedSymbolIndexes(ssa), sortedSymbolCount(ssc), cfiStartsArray(cfisa),
+ cfiStartsCount(cfisc), fileHasOverlappingSymbols(ols),
+ newSection(false), cfiIndex(0), symIndex(0) {}
+- bool next(Parser<A>& parser, const Section<A>& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr,
++ bool next(Parser<A>& parser, const MRFSection<A>& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr,
+ pint_t* addr, pint_t* size, const macho_nlist<P>** sym);
+ pint_t peek(Parser<A>& parser, pint_t startAddr, pint_t endAddr);
+ void beginSection() { newSection = true; symIndex = 0; }
+@@ -1063,7 +1063,7 @@
+
+
+ private:
+- friend class Section<A>;
++ friend class MRFSection<A>;
+
+ enum SectionType { sectionTypeIgnore, sectionTypeLiteral4, sectionTypeLiteral8, sectionTypeLiteral16,
+ sectionTypeNonLazy, sectionTypeCFI, sectionTypeCString, sectionTypeCStringPointer,
+@@ -1404,7 +1404,7 @@
+ // was becuase of a label, the symbol). Returns false when no more chunks.
+ //
+ template <typename A>
+-bool Parser<A>::LabelAndCFIBreakIterator::next(Parser<A>& parser, const Section<A>& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr,
++bool Parser<A>::LabelAndCFIBreakIterator::next(Parser<A>& parser, const MRFSection<A>& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr,
+ pint_t* addr, pint_t* size, const macho_nlist<P>** symbol)
+ {
+ // may not be a label on start of section, but need atom demarcation there
+@@ -1590,7 +1590,7 @@
+ uint32_t sortedSymbolIndexes[_symbolsInSections];
+ this->makeSortedSymbolsArray(sortedSymbolIndexes, sortedSectionIndexes);
+
+- // allocate Section<A> object for each mach-o section
++ // allocate MRFSection<A> object for each mach-o section
+ makeSections();
+
+ // if it exists, do special early parsing of __compact_unwind section
+@@ -1687,7 +1687,7 @@
+ #endif
+ }
+
+- Section<A>** sections = _file->_sectionsArray;
++ MRFSection<A>** sections = _file->_sectionsArray;
+ uint32_t sectionsCount = _file->_sectionsArrayCount;
+
+ // figure out how many atoms will be allocated and allocate
+@@ -2208,11 +2208,11 @@
+ _file->_objConstraint = ld::File::objcConstraintRetainRelease;
+ if ( sect->size() > 8 ) {
+ warning("section %s/%s has unexpectedly large size %llu in %s",
+- sect->segname(), Section<A>::makeSectionName(sect), sect->size(), _file->path());
++ sect->segname(), MRFSection<A>::makeSectionName(sect), sect->size(), _file->path());
+ }
+ }
+ else {
+- warning("can't parse %s/%s section in %s", sect->segname(), Section<A>::makeSectionName(sect), _file->path());
++ warning("can't parse %s/%s section in %s", sect->segname(), MRFSection<A>::makeSectionName(sect), _file->path());
+ }
+ continue;
+ }
+@@ -2308,24 +2308,24 @@
+ // sort by address (mach-o object files don't aways have sections sorted)
+ ::qsort(machOSects, count, sizeof(MachOSectionAndSectionClass<P>), MachOSectionAndSectionClass<P>::sorter);
+
+- // we will synthesize a dummy Section<A> object for tentative definitions
++ // we will synthesize a dummy MRFSection<A> object for tentative definitions
+ if ( _tentativeDefinitionCount > 0 ) {
+ totalSectionsSize += sizeof(TentativeDefinitionSection<A>);
+ machOSects[count++].type = sectionTypeTentativeDefinitions;
+ }
+
+- // we will synthesize a dummy Section<A> object for Absolute symbols
++ // we will synthesize a dummy MRFSection<A> object for Absolute symbols
+ if ( _absoluteSymbolCount > 0 ) {
+ totalSectionsSize += sizeof(AbsoluteSymbolSection<A>);
+ machOSects[count++].type = sectionTypeAbsoluteSymbols;
+ }
+
+ // allocate one block for all Section objects as well as pointers to each
+- uint8_t* space = new uint8_t[totalSectionsSize+count*sizeof(Section<A>*)];
+- _file->_sectionsArray = (Section<A>**)space;
++ uint8_t* space = new uint8_t[totalSectionsSize+count*sizeof(MRFSection<A>*)];
++ _file->_sectionsArray = (MRFSection<A>**)space;
+ _file->_sectionsArrayCount = count;
+- Section<A>** objects = _file->_sectionsArray;
+- space += count*sizeof(Section<A>*);
++ MRFSection<A>** objects = _file->_sectionsArray;
++ space += count*sizeof(MRFSection<A>*);
+ for (uint32_t i=0; i < count; ++i) {
+ switch ( machOSects[i].type ) {
+ case sectionTypeIgnore:
+@@ -2413,7 +2413,7 @@
+
+
+ template <typename A>
+-Section<A>* Parser<A>::sectionForAddress(typename A::P::uint_t addr)
++MRFSection<A>* Parser<A>::sectionForAddress(typename A::P::uint_t addr)
+ {
+ for (uint32_t i=0; i < _file->_sectionsArrayCount; ++i ) {
+ const macho_section<typename A::P>* sect = _file->_sectionsArray[i]->machoSection();
+@@ -2440,7 +2440,7 @@
+ }
+
+ template <typename A>
+-Section<A>* Parser<A>::sectionForNum(unsigned int num)
++MRFSection<A>* Parser<A>::sectionForNum(unsigned int num)
+ {
+ for (uint32_t i=0; i < _file->_sectionsArrayCount; ++i ) {
+ const macho_section<typename A::P>* sect = _file->_sectionsArray[i]->machoSection();
+@@ -2456,7 +2456,7 @@
+ template <typename A>
+ Atom<A>* Parser<A>::findAtomByAddress(pint_t addr)
+ {
+- Section<A>* section = this->sectionForAddress(addr);
++ MRFSection<A>* section = this->sectionForAddress(addr);
+ return section->findAtomByAddress(addr);
+ }
+
+@@ -2513,7 +2513,7 @@
+ target.addend = 0;
+ return;
+ }
+- Section<A>* section = this->sectionForAddress(addr);
++ MRFSection<A>* section = this->sectionForAddress(addr);
+ target.atom = section->findAtomByAddress(addr);
+ target.addend = addr - target.atom->_objAddress;
+ target.weakImport = false;
+@@ -2561,7 +2561,7 @@
+ }
+ return;
+ }
+- Section<A>* section = this->sectionForNum(sectNum);
++ MRFSection<A>* section = this->sectionForNum(sectNum);
+ target.atom = section->findAtomByAddress(addr);
+ if ( target.atom == NULL ) {
+ typedef typename A::P::sint_t sint_t;
+@@ -3723,7 +3723,7 @@
+ }
+
+ template <typename A>
+-const char* Section<A>::makeSegmentName(const macho_section<typename A::P>* sect)
++const char* MRFSection<A>::makeSegmentName(const macho_section<typename A::P>* sect)
+ {
+ // mach-o section record only has room for 16-byte seg/sect names
+ // so a 16-byte name has no trailing zero
+@@ -3736,7 +3736,7 @@
+ }
+
+ template <typename A>
+-const char* Section<A>::makeSectionName(const macho_section<typename A::P>* sect)
++const char* MRFSection<A>::makeSectionName(const macho_section<typename A::P>* sect)
+ {
+ const char* name = sect->sectname();
+ if ( strlen(name) < 16 )
+@@ -3770,13 +3770,13 @@
+ }
+
+ template <typename A>
+-bool Section<A>::readable(const macho_section<typename A::P>* sect)
++bool MRFSection<A>::readable(const macho_section<typename A::P>* sect)
+ {
+ return true;
+ }
+
+ template <typename A>
+-bool Section<A>::writable(const macho_section<typename A::P>* sect)
++bool MRFSection<A>::writable(const macho_section<typename A::P>* sect)
+ {
+ // mach-o .o files do not contain segment permissions
+ // we just know TEXT is special
+@@ -3784,7 +3784,7 @@
+ }
+
+ template <typename A>
+-bool Section<A>::exectuable(const macho_section<typename A::P>* sect)
++bool MRFSection<A>::exectuable(const macho_section<typename A::P>* sect)
+ {
+ // mach-o .o files do not contain segment permissions
+ // we just know TEXT is special
+@@ -3793,7 +3793,7 @@
+
+
+ template <typename A>
+-ld::Section::Type Section<A>::sectionType(const macho_section<typename A::P>* sect)
++ld::Section::Type MRFSection<A>::sectionType(const macho_section<typename A::P>* sect)
+ {
+ switch ( sect->flags() & SECTION_TYPE ) {
+ case S_ZEROFILL:
+@@ -3871,7 +3871,7 @@
+
+
+ template <typename A>
+-Atom<A>* Section<A>::findContentAtomByAddress(pint_t addr, class Atom<A>* start, class Atom<A>* end)
++Atom<A>* MRFSection<A>::findContentAtomByAddress(pint_t addr, class Atom<A>* start, class Atom<A>* end)
+ {
+ // do a binary search of atom array
+ uint32_t atomCount = end - start;
+@@ -3903,7 +3903,7 @@
+ }
+
+ template <typename A>
+-ld::Atom::Alignment Section<A>::alignmentForAddress(pint_t addr)
++ld::Atom::Alignment MRFSection<A>::alignmentForAddress(pint_t addr)
+ {
+ const uint32_t sectionAlignment = this->_machOSection->align();
+ uint32_t modulus = (addr % (1 << sectionAlignment));
+@@ -3913,7 +3913,7 @@
+ }
+
+ template <typename A>
+-uint32_t Section<A>::sectionNum(class Parser<A>& parser) const
++uint32_t MRFSection<A>::sectionNum(class Parser<A>& parser) const
+ {
+ if ( _machOSection == NULL )
+ return 0;
+@@ -4481,7 +4481,7 @@
+ else {
+ const pint_t* content = (pint_t*)(this->file().fileContent() + this->_machOSection->offset() + reloc->r_address());
+ pint_t personalityAddr = *content;
+- Section<x86_64>* personalitySection = parser.sectionForAddress(personalityAddr);
++ MRFSection<x86_64>* personalitySection = parser.sectionForAddress(personalityAddr);
+ assert((personalitySection->type() == ld::Section::typeCode) && "personality column in __compact_unwind section is not pointer to function");
+ // atoms may not be constructed yet, so scan symbol table for labels
+ const char* name = parser.scanSymbolTableForAddress(personalityAddr);
+@@ -4501,7 +4501,7 @@
+ // support __LD, __compact_unwind personality entries which are pointer to personality non-lazy pointer
+ const pint_t* content = (pint_t*)(this->file().fileContent() + this->_machOSection->offset() + reloc->r_address());
+ pint_t nlPointerAddr = *content;
+- Section<x86>* nlSection = parser.sectionForAddress(nlPointerAddr);
++ MRFSection<x86>* nlSection = parser.sectionForAddress(nlPointerAddr);
+ if ( nlSection->type() == ld::Section::typeCode ) {
+ // personality function is defined in this .o file, so this is a direct reference to it
+ // atoms may not be constructed yet, so scan symbol table for labels
+@@ -4528,7 +4528,7 @@
+ else {
+ const pint_t* content = (pint_t*)(this->file().fileContent() + this->_machOSection->offset() + reloc->r_address());
+ pint_t personalityAddr = *content;
+- Section<arm64>* personalitySection = parser.sectionForAddress(personalityAddr);
++ MRFSection<arm64>* personalitySection = parser.sectionForAddress(personalityAddr);
+ assert((personalitySection->type() == ld::Section::typeCode) && "personality column in __compact_unwind section is not pointer to function");
+ // atoms may not be constructed yet, so scan symbol table for labels
+ const char* name = parser.scanSymbolTableForAddress(personalityAddr);
+@@ -4681,7 +4681,7 @@
+
+ template <typename A>
+ SymboledSection<A>::SymboledSection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s)
+- : Section<A>(f, s), _type(ld::Atom::typeUnclassified)
++ : MRFSection<A>(f, s), _type(ld::Atom::typeUnclassified)
+ {
+ switch ( s->flags() & SECTION_TYPE ) {
+ case S_ZEROFILL:
+@@ -4727,7 +4727,7 @@
+ if ( ! this->_file.canScatterAtoms() )
+ return true;
+ // call inherited
+- return Section<A>::dontDeadStrip();
++ return MRFSection<A>::dontDeadStrip();
+ }
+ return false;
+ }
+@@ -5572,7 +5572,7 @@
+
+
+ template <>
+-uint32_t Section<x86_64>::x86_64PcRelOffset(uint8_t r_type)
++uint32_t MRFSection<x86_64>::x86_64PcRelOffset(uint8_t r_type)
+ {
+ switch ( r_type ) {
+ case X86_64_RELOC_SIGNED:
+@@ -5589,7 +5589,7 @@
+
+
+ template <>
+-bool Section<x86_64>::addRelocFixup(class Parser<x86_64>& parser, const macho_relocation_info<P>* reloc)
++bool MRFSection<x86_64>::addRelocFixup(class Parser<x86_64>& parser, const macho_relocation_info<P>* reloc)
+ {
+ const macho_section<P>* sect = this->machoSection();
+ uint64_t srcAddr = sect->addr() + reloc->r_address();
+@@ -5796,7 +5796,7 @@
+
+
+ template <>
+-bool Section<x86>::addRelocFixup(class Parser<x86>& parser, const macho_relocation_info<P>* reloc)
++bool MRFSection<x86>::addRelocFixup(class Parser<x86>& parser, const macho_relocation_info<P>* reloc)
+ {
+ const macho_section<P>* sect = this->machoSection();
+ uint32_t srcAddr;
+@@ -6037,7 +6037,7 @@
+
+ #if SUPPORT_ARCH_arm_any
+ template <>
+-bool Section<arm>::addRelocFixup(class Parser<arm>& parser, const macho_relocation_info<P>* reloc)
++bool MRFSection<arm>::addRelocFixup(class Parser<arm>& parser, const macho_relocation_info<P>* reloc)
+ {
+ const macho_section<P>* sect = this->machoSection();
+ bool result = false;
+@@ -6495,7 +6495,7 @@
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+-bool Section<arm64>::addRelocFixup(class Parser<arm64>& parser, const macho_relocation_info<P>* reloc)
++bool MRFSection<arm64>::addRelocFixup(class Parser<arm64>& parser, const macho_relocation_info<P>* reloc)
+ {
+ bool result = false;
+ Parser<arm64>::SourceLocation src;
+@@ -6893,7 +6893,7 @@
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+-void Section<arm64>::addLOH(class Parser<arm64>& parser, int kind, int count, const uint64_t addrs[]) {
++void MRFSection<arm64>::addLOH(class Parser<arm64>& parser, int kind, int count, const uint64_t addrs[]) {
+ switch (kind) {
+ case LOH_ARM64_ADRP_ADRP:
+ case LOH_ARM64_ADRP_LDR:
+@@ -6948,18 +6948,18 @@
+ extra.info.delta2 = (count > 1) ? ((addrs[1] - lowestAddress) >> 2) : 0;
+ extra.info.delta3 = (count > 2) ? ((addrs[2] - lowestAddress) >> 2) : 0;
+ extra.info.delta4 = (count > 3) ? ((addrs[3] - lowestAddress) >> 2) : 0;
+- typename Parser<arm64>::SourceLocation src(inAtom, lowestAddress- inAtom->objectAddress());
++ Parser<arm64>::SourceLocation src(inAtom, lowestAddress- inAtom->objectAddress());
+ parser.addFixup(src, ld::Fixup::k1of1, ld::Fixup::kindLinkerOptimizationHint, extra.addend);
+ }
+ #endif
+
+ template <typename A>
+-void Section<A>::addLOH(class Parser<A>& parser, int kind, int count, const uint64_t addrs[]) {
++void MRFSection<A>::addLOH(class Parser<A>& parser, int kind, int count, const uint64_t addrs[]) {
+
+ }
+
+ template <typename A>
+-void Section<A>::makeFixups(class Parser<A>& parser, const struct Parser<A>::CFI_CU_InfoArrays&)
++void MRFSection<A>::makeFixups(class Parser<A>& parser, const struct Parser<A>::CFI_CU_InfoArrays&)
+ {
+ const macho_section<P>* sect = this->machoSection();
+ const macho_relocation_info<P>* relocs = (macho_relocation_info<P>*)(file().fileContent() + sect->reloff());
+@@ -6970,7 +6970,7 @@
+ ++r; // skip next
+ }
+ catch (const char* msg) {
+- throwf("in section %s,%s reloc %u: %s", sect->segname(), Section<A>::makeSectionName(sect), r, msg);
++ throwf("in section %s,%s reloc %u: %s", sect->segname(), MRFSection<A>::makeSectionName(sect), r, msg);
+ }
+ }
+
+diff -ur ld64-236.3.orig/src/ld/passes/dtrace_dof.cpp ld64-236.3/src/ld/passes/dtrace_dof.cpp
+--- ld64-236.3.orig/src/ld/passes/dtrace_dof.cpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/passes/dtrace_dof.cpp 2015-01-12 00:27:58.000000000 +0100
+@@ -30,8 +30,17 @@
+
+ #include <vector>
+ #include <map>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#include <tr1/unordered_set>
++#define UNORDERED_MAP tr1::unordered_map
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_map>
+ #include <unordered_set>
++#define UNORDERED_MAP unordered_map
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "ld.hpp"
+ #include "MachOFileAbstraction.hpp"
+@@ -111,8 +120,8 @@
+ uint32_t offset;
+ const char* probeName;
+ };
+-typedef std::unordered_map<const char*, std::vector<DTraceProbeInfo>, CStringHash, CStringEquals> ProviderToProbes;
+-typedef std::unordered_set<const char*, CStringHash, CStringEquals> CStringSet;
++typedef std::UNORDERED_MAP<const char*, std::vector<DTraceProbeInfo>, CStringHash, CStringEquals> ProviderToProbes;
++typedef std::UNORDERED_SET<const char*, CStringHash, CStringEquals> CStringSet;
+
+
+
+diff -ur ld64-236.3.orig/src/ld/passes/order.cpp ld64-236.3/src/ld/passes/order.cpp
+--- ld64-236.3.orig/src/ld/passes/order.cpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/ld/passes/order.cpp 2015-01-11 22:45:57.000000000 +0100
+@@ -32,7 +32,13 @@
+ #include <vector>
+ #include <map>
+ #include <set>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+
+ #include "ld.hpp"
+ #include "order.h"
+@@ -84,7 +90,7 @@
+ const Layout& _layout;
+ };
+
+- typedef std::unordered_map<const char*, const ld::Atom*, CStringHash, CStringEquals> NameToAtom;
++ typedef std::UNORDERED_MAP<const char*, const ld::Atom*, CStringHash, CStringEquals> NameToAtom;
+
+ typedef std::map<const ld::Atom*, const ld::Atom*> AtomToAtom;
+
+diff -ur ld64-236.3.orig/src/other/dyldinfo.cpp ld64-236.3/src/other/dyldinfo.cpp
+--- ld64-236.3.orig/src/other/dyldinfo.cpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/other/dyldinfo.cpp 2015-01-12 00:27:33.000000000 +0100
+@@ -33,7 +33,6 @@
+
+ #include <vector>
+ #include <set>
+-#include <unordered_set>
+
+ #include "configure.h"
+ #include "MachOFileAbstraction.hpp"
+diff -ur ld64-236.3.orig/src/other/machochecker.cpp ld64-236.3/src/other/machochecker.cpp
+--- ld64-236.3.orig/src/other/machochecker.cpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/other/machochecker.cpp 2015-01-11 22:46:37.000000000 +0100
+@@ -33,7 +33,13 @@
+
+ #include <vector>
+ #include <set>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "configure.h"
+
+@@ -124,7 +130,7 @@
+ bool operator()(const char* left, const char* right) const { return (strcmp(left, right) == 0); }
+ };
+
+- typedef std::unordered_set<const char*, CStringHash, CStringEquals> StringSet;
++ typedef std::UNORDERED_SET<const char*, CStringHash, CStringEquals> StringSet;
+
+ MachOChecker(const uint8_t* fileContent, uint32_t fileLength, const char* path);
+ void checkMachHeader();
+diff -ur ld64-236.3.orig/src/other/unwinddump.cpp ld64-236.3/src/other/unwinddump.cpp
+--- ld64-236.3.orig/src/other/unwinddump.cpp 2014-04-05 00:42:29.000000000 +0200
++++ ld64-236.3/src/other/unwinddump.cpp 2015-01-11 23:58:00.000000000 +0100
+@@ -33,7 +33,6 @@
+
+ #include <vector>
+ #include <set>
+-#include <unordered_set>
+
+ #include "configure.h"
+ #include "MachOFileAbstraction.hpp"
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-missing-cputypes.patch b/sys-devel/binutils-apple/files/ld64-236.3-missing-cputypes.patch
new file mode 100644
index 000000000000..29b50f628122
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-missing-cputypes.patch
@@ -0,0 +1,10 @@
+--- ld64-236.3/src/include/mach/machine.h.orig 2015-01-24 13:22:36.000000000 +0100
++++ ld64-236.3/src/include/mach/machine.h 2015-01-24 13:22:51.000000000 +0100
+@@ -233,6 +233,7 @@
+ */
+
+ #define CPU_SUBTYPE_I386_ALL ((cpu_subtype_t) 3)
++#define CPU_SUBTYPE_X86_ALL CPU_SUBTYPE_I386_ALL
+ #define CPU_SUBTYPE_X86_64_ALL CPU_SUBTYPE_I386_ALL
+ #define CPU_SUBTYPE_386 ((cpu_subtype_t) 3)
+ #define CPU_SUBTYPE_486 ((cpu_subtype_t) 4)
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-noarm.patch b/sys-devel/binutils-apple/files/ld64-236.3-noarm.patch
new file mode 100644
index 000000000000..5a235ec85e32
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-noarm.patch
@@ -0,0 +1,1236 @@
+Fully conditionalise arm support so it can be disabled on 10.4.
+
+--- ld64-236.3/src/ld/HeaderAndLoadCommands.hpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/HeaderAndLoadCommands.hpp 2015-01-23 06:56:04.000000000 +0100
+@@ -605,8 +605,12 @@
+
+ template <> uint32_t HeaderAndLoadCommandsAtom<x86>::cpuType() const { return CPU_TYPE_I386; }
+ template <> uint32_t HeaderAndLoadCommandsAtom<x86_64>::cpuType() const { return CPU_TYPE_X86_64; }
++#if SUPPORT_ARCH_arm_any
+ template <> uint32_t HeaderAndLoadCommandsAtom<arm>::cpuType() const { return CPU_TYPE_ARM; }
++#endif
++#if SUPPORT_ARCH_arm64
+ template <> uint32_t HeaderAndLoadCommandsAtom<arm64>::cpuType() const { return CPU_TYPE_ARM64; }
++#endif
+
+
+
+@@ -625,17 +629,21 @@
+ return _state.cpuSubType;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ uint32_t HeaderAndLoadCommandsAtom<arm>::cpuSubType() const
+ {
+ return _state.cpuSubType;
+ }
++#endif
+
++#if SUPPORT_ARCH_arm64
+ template <>
+ uint32_t HeaderAndLoadCommandsAtom<arm64>::cpuSubType() const
+ {
+ return CPU_SUBTYPE_ARM64_ALL;
+ }
++#endif
+
+
+
+--- ld64-236.3/src/ld/LinkEdit.hpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/LinkEdit.hpp 2015-01-23 06:56:04.000000000 +0100
+@@ -1595,6 +1595,7 @@
+ for (ld::Fixup::iterator fit = atom->fixupsBegin(); fit != atom->fixupsEnd(); ++fit) {
+ if ( fit->kind != ld::Fixup::kindLinkerOptimizationHint)
+ continue;
++#if SUPPORT_ARCH_arm64
+ ld::Fixup::LOH_arm64 extra;
+ extra.addend = fit->u.addend;
+ _encodedData.append_uleb128(extra.info.kind);
+@@ -1606,6 +1607,7 @@
+ _encodedData.append_uleb128((extra.info.delta3 << 2) + fit->offsetInAtom + address);
+ if ( extra.info.count > 2 )
+ _encodedData.append_uleb128((extra.info.delta4 << 2) + fit->offsetInAtom + address);
++#endif
+ }
+ }
+ }
+--- ld64-236.3/src/ld/Options.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/Options.cpp 2015-01-23 07:05:43.000000000 +0100
+@@ -567,8 +567,13 @@
+ #endif
+ }
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
++#if SUPPORT_ARCH_arm_any || SUPPORT_ARCH_arm64
+ if ( (fMacVersionMin == ld::macVersionUnset) && (fIOSVersionMin == ld::iOSVersionUnset) && (fOutputKind != Options::kObjectFile) ) {
+ #if defined(DEFAULT_IPHONEOS_MIN_VERSION)
+ warning("-ios_version_min not specified, assuming " DEFAULT_IPHONEOS_MIN_VERSION);
+@@ -579,6 +584,7 @@
+ #endif
+ }
+ break;
++#endif
+ }
+ #ifdef SUPPORT_SNAPSHOTS
+ fLinkSnapshot.recordArch(fArchitectureName);
+@@ -1649,9 +1655,11 @@
+ symbolStart = NULL;
+ }
+ else if ( strncmp(symbolStart, "arm:", 4) == 0 ) {
++#if SUPPORT_ARCH_arm_any
+ if ( fArchitecture == CPU_TYPE_ARM )
+ symbolStart = &symbolStart[4];
+ else
++#endif
+ symbolStart = NULL;
+ }
+ if ( symbolStart != NULL ) {
+@@ -3483,6 +3491,7 @@
+ #endif
+ }
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( (fOutputKind != Options::kObjectFile) && (fOutputKind != Options::kPreload) ) {
+ #if defined(DEFAULT_IPHONEOS_MIN_VERSION)
+@@ -3494,6 +3503,7 @@
+ #endif
+ }
+ break;
++#endif
+ default:
+ // architecture will be infered later by examining .o files
+ break;
+@@ -3516,12 +3526,14 @@
+ fMacVersionMin = ld::mac10_4;
+ }
+ break;
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
+ if ( fIOSVersionMin < ld::iOS_7_0 ) {
+ //warning("-mios_version_min should be 7.0 or later for arm64");
+ fIOSVersionMin = ld::iOS_7_0;
+ }
+ break;
++#endif
+ }
+
+ // default to adding functions start for dynamic code, static code must opt-in
+@@ -3561,6 +3573,7 @@
+ fAllowTextRelocs = true;
+ fUndefinedTreatment = kUndefinedDynamicLookup;
+ break;
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
+ // arm64 uses new MH_KEXT_BUNDLE type
+ fMakeCompressedDyldInfo = false;
+@@ -3569,6 +3582,8 @@
+ fKextsUseStubs = true;
+ fUndefinedTreatment = kUndefinedDynamicLookup;
+ break;
++#endif
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( fIOSVersionMin >= ld::iOS_5_0 ) {
+ // iOS 5.0 and later use new MH_KEXT_BUNDLE type
+@@ -3580,6 +3595,7 @@
+ fUndefinedTreatment = kUndefinedDynamicLookup;
+ break;
+ }
++#endif
+ // else use object file
+ case CPU_TYPE_I386:
+ // use .o files
+@@ -3632,6 +3648,7 @@
+ if ( fSplitSegs && (fBaseWritableAddress-fBaseAddress != 0x10000000) )
+ fBaseWritableAddress = fBaseAddress + 0x10000000;
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( fOutputKind != Options::kDynamicLibrary ) {
+ fSplitSegs = false;
+@@ -3642,6 +3659,7 @@
+ fBaseWritableAddress = fBaseAddress + 0x08000000;
+ }
+ break;
++#endif
+ default:
+ fSplitSegs = false;
+ fBaseAddress = 0;
+@@ -3656,6 +3674,7 @@
+ break;
+ case CPU_TYPE_X86_64:
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ switch ( fOutputKind ) {
+ case Options::kDynamicExecutable:
+@@ -3678,6 +3697,7 @@
+ fBaseAddress = 0;
+ }
+ break;
++#endif
+ }
+
+ // <rdar://problem/6138961> -r implies no prebinding for all architectures
+@@ -3723,6 +3743,7 @@
+ case CPU_TYPE_X86_64:
+ fPrebind = false;
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ switch ( fOutputKind ) {
+ case Options::kDynamicExecutable:
+@@ -3740,6 +3761,7 @@
+ break;
+ }
+ break;
++#endif
+ }
+ }
+
+@@ -3766,10 +3788,12 @@
+ case CPU_TYPE_I386:
+ if ( fIOSVersionMin != ld::iOSVersionUnset ) // simulator never needs modules
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( fPrebind )
+ fNeedsModuleTable = true; // redo_prebinding requires a module table
+ break;
++#endif
+ }
+ }
+
+@@ -3993,7 +3993,9 @@
+ switch ( fArchitecture ) {
+ case CPU_TYPE_I386:
+ case CPU_TYPE_X86_64:
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ switch ( fOutputKind ) {
+ case Options::kObjectFile:
+ case Options::kStaticExecutable:
+@@ -4010,10 +4012,12 @@
+ break;
+ }
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ fAddCompactUnwindEncoding = false;
+ fRemoveDwarfUnwindIfCompactExists = false;
+ break;
++#endif
+ case 0:
+ // if -arch is missing, assume we don't want compact unwind info
+ fAddCompactUnwindEncoding = false;
+@@ -3815,7 +3843,15 @@
+ // only iOS main executables should be encrypted
+ if ( fOutputKind != Options::kDynamicExecutable )
+ fEncryptable = false;
+- if ( (fArchitecture != CPU_TYPE_ARM) && (fArchitecture != CPU_TYPE_ARM64) )
++ if (
++#if SUPPORT_ARCH_arm_any
++ (fArchitecture != CPU_TYPE_ARM) &&
++#endif
++#if SUPPORT_ARCH_arm64
++ (fArchitecture != CPU_TYPE_ARM64) &&
++#endif
++ 1
++ )
+ fEncryptable = false;
+
+ // don't move inits in dyld because dyld wants certain
+@@ -3867,11 +3903,15 @@
+
+ // only ARM and x86_64 enforces that cpu-sub-types must match
+ switch ( fArchitecture ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
+ case CPU_TYPE_X86_64:
+ break;
+ case CPU_TYPE_I386:
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ fAllowCpuSubtypeMismatches = true;
+ break;
+ }
+@@ -3917,6 +3957,7 @@
+ fPositionIndependentExecutable = true;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ // armv7 for iOS4.3 defaults to PIE
+ if ( (fArchitecture == CPU_TYPE_ARM)
+ && fArchSupportsThumb2
+@@ -3924,15 +3965,18 @@
+ && (fIOSVersionMin >= ld::iOS_4_3) ) {
+ fPositionIndependentExecutable = true;
+ }
++#endif
+
+ // -no_pie anywhere on command line disable PIE
+ if ( fDisablePositionIndependentExecutable )
+ fPositionIndependentExecutable = false;
+
++#if SUPPORT_ARCH_arm64
+ // arm64 is always PIE
+ if ( (fArchitecture == CPU_TYPE_ARM64) && (fOutputKind == kDynamicExecutable) ) {
+ fPositionIndependentExecutable = true;
+ }
++#endif
+
+ // set fOutputSlidable
+ switch ( fOutputKind ) {
+@@ -3958,9 +4002,11 @@
+ if ( fMacVersionMin >= ld::mac10_7 ) {
+ fTLVSupport = true;
+ }
++#if SUPPORT_ARCH_arm64
+ else if ( (fArchitecture == CPU_TYPE_ARM64) && (fIOSVersionMin >= 0x00080000) ) {
+ fTLVSupport = true;
+ }
++#endif
+
+ // default to adding version load command for dynamic code, static code must opt-in
+ switch ( fOutputKind ) {
+@@ -4149,6 +4195,7 @@
+ }
+
+ // <rdar://problem/12258065> ARM64 needs 16KB page size for user land code
++#if SUPPORT_ARCH_arm64
+ if ( fArchitecture == CPU_TYPE_ARM64 ) {
+ if ( fSegmentAlignment == 4096 ) {
+ switch ( fOutputKind ) {
+@@ -4166,6 +4213,7 @@
+ }
+ }
+ }
++#endif
+
+ // <rdar://problem/13624134> linker should not convert dwarf unwind if .o file has compact unwind section
+ switch ( fOutputKind ) {
+@@ -4267,12 +4315,16 @@
+ if ( fStackAddr != 0 ) {
+ switch (fArchitecture) {
+ case CPU_TYPE_I386:
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
+ if ( fStackAddr > 0xFFFFFFFFULL )
+ throw "-stack_addr must be < 4G for 32-bit processes";
+ break;
+ case CPU_TYPE_X86_64:
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ break;
+ }
+ if ( (fStackAddr & -4096) != fStackAddr )
+@@ -4293,6 +4345,7 @@
+ if ( (fStackAddr > 0xB0000000ULL) && ((fStackAddr-fStackSize) < 0xB0000000ULL) )
+ warning("custom stack placement overlaps and will disable shared region");
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( fStackSize > 0x2F000000 )
+ throw "-stack_size must be < 752MB";
+@@ -4301,11 +4354,13 @@
+ if ( fStackAddr > 0x30000000ULL)
+ throw "-stack_addr must be < 0x30000000 for arm";
+ break;
++#endif
+ case CPU_TYPE_X86_64:
+ if ( fStackAddr == 0 ) {
+ fStackAddr = 0x00007FFF5C000000ULL;
+ }
+ break;
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
+ if ( fStackSize > 0x20000000 )
+ throw "-stack_size must be < 512MB";
+@@ -4313,6 +4368,7 @@
+ fStackAddr = 0x120000000ULL;
+ }
+ break;
++#endif
+ }
+ if ( (fStackSize & -4096) != fStackSize )
+ throw "-stack_size must be multiples of 4K";
+@@ -4422,8 +4478,12 @@
+ alterObjC1ClassNamesToObjC2 = true;
+ break;
+ case CPU_TYPE_X86_64:
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ alterObjC1ClassNamesToObjC2 = true;
+ break;
+ }
+@@ -4799,11 +4799,15 @@
+ // zero page size not specified on command line, set default
+ switch (fArchitecture) {
+ case CPU_TYPE_I386:
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
+ // first 4KB for 32-bit architectures
+ fZeroPageSize = 0x1000;
+ break;
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ case CPU_TYPE_X86_64:
+ // first 4GB for x86_64 on all OS's
+ fZeroPageSize = 0x100000000ULL;
+@@ -4621,9 +4685,11 @@
+
+ // -force_cpusubtype_ALL is not supported for ARM
+ if ( fForceSubtypeAll ) {
++#if SUPPORT_ARCH_arm_any
+ if ( fArchitecture == CPU_TYPE_ARM ) {
+ warning("-force_cpusubtype_ALL will become unsupported for ARM architectures");
+ }
++#endif
+ }
+
+ // -reexported_symbols_list can only be used with -dynamiclib
+--- ld64-236.3/src/ld/OutputFile.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/OutputFile.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -629,7 +629,12 @@
+ // is encoded in mach-o the same as:
+ // .long _foo + 0x40000000
+ // so if _foo lays out to 0xC0000100, the first is ok, but the second is not.
+- if ( (_options.architecture() == CPU_TYPE_ARM) || (_options.architecture() == CPU_TYPE_I386) ) {
++ if (
++#if SUPPORT_ARCH_arm_any
++ (_options.architecture() == CPU_TYPE_ARM) ||
++#endif
++ (_options.architecture() == CPU_TYPE_I386) ||
++ 0) {
+ // Unlikely userland code does funky stuff like this, so warn for them, but not warn for -preload or -static
+ if ( (_options.outputKind() != Options::kPreload) && (_options.outputKind() != Options::kStaticExecutable) ) {
+ warning("32-bit absolute address out of range (0x%08llX max is 4GB): from %s + 0x%08X (0x%08llX) to 0x%08llX",
+@@ -1229,22 +1234,26 @@
+ return false;
+ const ld::Fixup* f;
+ switch ( fixup->kind ) {
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreTargetAddressARM64Page21:
+ return !mustBeGOT;
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPage21:
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPage21:
+ return true;
++#endif
+ case ld::Fixup::kindSetTargetAddress:
+ f = fixup;
+ do {
+ ++f;
+ } while ( ! f->lastInCluster() );
+ switch (f->kind ) {
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreARM64Page21:
+ return !mustBeGOT;
+ case ld::Fixup::kindStoreARM64GOTLoadPage21:
+ case ld::Fixup::kindStoreARM64GOTLeaPage21:
+ return true;
++#endif
+ default:
+ break;
+ }
+@@ -1261,22 +1270,26 @@
+ return false;
+ const ld::Fixup* f;
+ switch ( fixup->kind ) {
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreTargetAddressARM64PageOff12:
+ return !mustBeGOT;
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPageOff12:
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPageOff12:
+ return true;
++#endif
+ case ld::Fixup::kindSetTargetAddress:
+ f = fixup;
+ do {
+ ++f;
+ } while ( ! f->lastInCluster() );
+ switch (f->kind ) {
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreARM64PageOff12:
+ return !mustBeGOT;
+ case ld::Fixup::kindStoreARM64GOTLoadPageOff12:
+ case ld::Fixup::kindStoreARM64GOTLeaPageOff12:
+ return true;
++#endif
+ default:
+ break;
+ }
+@@ -1311,7 +1324,9 @@
+ std::map<uint32_t, const Fixup*> usedByHints;
+ for (ld::Fixup::iterator fit = atom->fixupsBegin(), end=atom->fixupsEnd(); fit != end; ++fit) {
+ uint8_t* fixUpLocation = &buffer[fit->offsetInAtom];
++#if SUPPORT_ARCH_arm64
+ ld::Fixup::LOH_arm64 lohExtra;
++#endif
+ switch ( (ld::Fixup::Kind)(fit->kind) ) {
+ case ld::Fixup::kindNone:
+ case ld::Fixup::kindNoneFollowOn:
+@@ -1570,6 +1585,7 @@
+ break;
+ case ld::Fixup::kindLinkerOptimizationHint:
+ // expand table of address/offsets used by hints
++#if SUPPORT_ARCH_arm64
+ lohExtra.addend = fit->u.addend;
+ usedByHints[fit->offsetInAtom + (lohExtra.info.delta1 << 2)] = NULL;
+ if ( lohExtra.info.count > 0 )
+@@ -1578,6 +1594,7 @@
+ usedByHints[fit->offsetInAtom + (lohExtra.info.delta3 << 2)] = NULL;
+ if ( lohExtra.info.count > 2 )
+ usedByHints[fit->offsetInAtom + (lohExtra.info.delta4 << 2)] = NULL;
++#endif
+ break;
+ case ld::Fixup::kindStoreTargetAddressLittleEndian32:
+ accumulator = addressOf(state, fit, &toTarget);
+@@ -2057,6 +2074,7 @@
+ //uint8_t loadSize, destReg;
+ //uint32_t scaledOffset;
+ //uint32_t imm12;
++#if SUPPORT_ARCH_arm64
+ ld::Fixup::LOH_arm64 alt;
+ alt.addend = fit->u.addend;
+ setInfo(state, atom, buffer, usedByHints, fit->offsetInAtom, (alt.info.delta1 << 2), &infoA);
+@@ -2415,6 +2433,7 @@
+ fprintf(stderr, "unknown hint kind %d alt.info.kind at 0x%08llX\n", alt.info.kind, infoA.instructionAddress);
+ break;
+ }
++#endif
+ }
+ // apply hints pass 2
+ for (ld::Fixup::iterator fit = atom->fixupsBegin(), end=atom->fixupsEnd(); fit != end; ++fit) {
+@@ -2422,6 +2441,7 @@
+ continue;
+ InstructionInfo infoA;
+ InstructionInfo infoB;
++#if SUPPORT_ARCH_arm64
+ ld::Fixup::LOH_arm64 alt;
+ alt.addend = fit->u.addend;
+ setInfo(state, atom, buffer, usedByHints, fit->offsetInAtom, (alt.info.delta1 << 2), &infoA);
+@@ -2453,6 +2473,7 @@
+ }
+ break;
+ }
++#endif
+ }
+ }
+
+@@ -2469,6 +2490,7 @@
+ for (uint8_t* p=from; p < to; ++p)
+ *p = 0x90;
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( thumb ) {
+ for (uint8_t* p=from; p < to; p += 2)
+@@ -2479,6 +2501,7 @@
+ OSWriteLittleInt32((uint32_t*)p, 0, 0xe1a00000);
+ }
+ break;
++#endif
+ default:
+ for (uint8_t* p=from; p < to; ++p)
+ *p = 0x00;
+@@ -2807,7 +2830,11 @@
+
+ // in -r mode, clarify symbolTableNotInFinalLinkedImages
+ if ( _options.outputKind() == Options::kObjectFile ) {
+- if ( (_options.architecture() == CPU_TYPE_X86_64) || (_options.architecture() == CPU_TYPE_ARM64) ) {
++ if ( (_options.architecture() == CPU_TYPE_X86_64) ||
++#if SUPPORT_ARCH_arm64
++ (_options.architecture() == CPU_TYPE_ARM64) ||
++#endif
++ 0 ) {
+ // x86_64 .o files need labels on anonymous literal strings
+ if ( (sect->type() == ld::Section::typeCString) && (atom->combine() == ld::Atom::combineByNameAndContent) ) {
+ (const_cast<ld::Atom*>(atom))->setSymbolTableInclusion(ld::Atom::symbolTableIn);
+@@ -4030,8 +4057,10 @@
+ if ( _options.sharedRegionEligible() ) {
+ // <rdar://problem/13287063> when range checking, ignore high byte of arm64 addends
+ uint64_t checkAddend = addend;
++#if SUPPORT_ARCH_arm64
+ if ( _options.architecture() == CPU_TYPE_ARM64 )
+ checkAddend &= 0x0FFFFFFFFFFFFFFFULL;
++#endif
+ if ( checkAddend != 0 ) {
+ // make sure the addend does not cause the pointer to point outside the target's segment
+ // if it does, update_dyld_shared_cache will not be able to put this dylib into the shared cache
+@@ -4238,12 +4267,17 @@
+
+ bool OutputFile::useExternalSectionReloc(const ld::Atom* atom, const ld::Atom* target, ld::Fixup* fixupWithTarget)
+ {
+- if ( (_options.architecture() == CPU_TYPE_X86_64) || (_options.architecture() == CPU_TYPE_ARM64) ) {
++ if ( (_options.architecture() == CPU_TYPE_X86_64) ||
++#if SUPPORT_ARCH_arm64
++ (_options.architecture() == CPU_TYPE_ARM64) ||
++#endif
++ 0) {
+ // x86_64 and ARM64 use external relocations for everthing that has a symbol
+ return ( target->symbolTableInclusion() != ld::Atom::symbolTableNotIn );
+ }
+
+ // <rdar://problem/9513487> support arm branch interworking in -r mode
++#if SUPPORT_ARCH_arm_any
+ if ( (_options.architecture() == CPU_TYPE_ARM) && (_options.outputKind() == Options::kObjectFile) ) {
+ if ( atom->isThumb() != target->isThumb() ) {
+ switch ( fixupWithTarget->kind ) {
+@@ -4257,6 +4291,7 @@
+ }
+ }
+ }
++#endif
+
+ if ( (_options.architecture() == CPU_TYPE_I386) && (_options.outputKind() == Options::kObjectFile) ) {
+ if ( target->contentType() == ld::Atom::typeTLV )
+@@ -4324,7 +4359,11 @@
+ bool minusTargetUsesExternalReloc = (minusTarget != NULL) && this->useExternalSectionReloc(atom, minusTarget, fixupWithMinusTarget);
+
+ // in x86_64 and arm64 .o files an external reloc means the content contains just the addend
+- if ( (_options.architecture() == CPU_TYPE_X86_64) ||(_options.architecture() == CPU_TYPE_ARM64) ) {
++ if ( (_options.architecture() == CPU_TYPE_X86_64) ||
++#if SUPPORT_ARCH_arm64
++ (_options.architecture() == CPU_TYPE_ARM64) ||
++#endif
++ 0 ) {
+ if ( targetUsesExternalReloc ) {
+ fixupWithTarget->contentAddendOnly = true;
+ fixupWithStore->contentAddendOnly = true;
+--- ld64-236.3/src/ld/parsers/archive_file.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/parsers/archive_file.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -232,8 +232,12 @@
+
+ template <> cpu_type_t File<x86>::architecture() { return CPU_TYPE_I386; }
+ template <> cpu_type_t File<x86_64>::architecture() { return CPU_TYPE_X86_64; }
++#if SUPPORT_ARCH_arm_any
+ template <> cpu_type_t File<arm>::architecture() { return CPU_TYPE_ARM; }
++#endif
++#if SUPPORT_ARCH_arm64
+ template <> cpu_type_t File<arm64>::architecture() { return CPU_TYPE_ARM64; }
++#endif
+
+
+ template <typename A>
+--- ld64-236.3/src/ld/parsers/macho_dylib_file.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/parsers/macho_dylib_file.cpp 2015-01-23 07:01:27.000000000 +0100
+@@ -250,11 +250,15 @@
+ bool File<A>::_s_logHashtable = false;
+
+ template <> const char* File<x86_64>::objCInfoSegmentName() { return "__DATA"; }
++#if SUPPORT_ARCH_arm_any
+ template <> const char* File<arm>::objCInfoSegmentName() { return "__DATA"; }
++#endif
+ template <typename A> const char* File<A>::objCInfoSegmentName() { return "__OBJC"; }
+
+ template <> const char* File<x86_64>::objCInfoSectionName() { return "__objc_imageinfo"; }
++#if SUPPORT_ARCH_arm_any
+ template <> const char* File<arm>::objCInfoSectionName() { return "__objc_imageinfo"; }
++#endif
+ template <typename A> const char* File<A>::objCInfoSectionName() { return "__image_info"; }
+
+ template <typename A>
+@@ -1006,6 +1010,7 @@
+ }
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ bool Parser<arm>::validFile(const uint8_t* fileContent, bool executableOrDyliborBundle)
+ {
+@@ -1032,9 +1037,11 @@
+ return false;
+ }
+ }
++#endif
+
+
+
++#if SUPPORT_ARCH_arm64
+ template <>
+ bool Parser<arm64>::validFile(const uint8_t* fileContent, bool executableOrDyliborBundle)
+ {
+@@ -1061,6 +1068,7 @@
+ return false;
+ }
+ }
++#endif
+
+
+ bool isDylibFile(const uint8_t* fileContent, cpu_type_t* result, cpu_subtype_t* subResult)
+@@ -1084,17 +1084,21 @@
+ *subResult = CPU_SUBTYPE_X86_ALL;
+ return true;
+ }
++#if SUPPORT_ARCH_arm_any
+ if ( Parser<arm>::validFile(fileContent, false) ) {
+ *result = CPU_TYPE_ARM;
+ const macho_header<Pointer32<LittleEndian> >* header = (const macho_header<Pointer32<LittleEndian> >*)fileContent;
+ *subResult = header->cpusubtype();
+ return true;
+ }
++#endif
++#if SUPPORT_ARCH_arm64
+ if ( Parser<arm64>::validFile(fileContent, false) ) {
+ *result = CPU_TYPE_ARM64;
+ *subResult = CPU_SUBTYPE_ARM64_ALL;
+ return true;
+ }
++#endif
+ #ifdef SUPPORT_ARCH_ppc
+ if ( Parser<ppc>::validFile(fileContent, false) ) {
+ *result = CPU_TYPE_POWERPC;
+@@ -1123,6 +1135,7 @@
+ return "x86_64";
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ const char* Parser<arm>::fileKind(const uint8_t* fileContent)
+ {
+@@ -1138,6 +1151,7 @@
+ }
+ return "arm???";
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -1163,9 +1177,11 @@
+ if ( Parser<x86>::validFile(fileContent, true) ) {
+ return Parser<x86>::fileKind(fileContent);
+ }
++#if SUPPORT_ARCH_arm_any
+ if ( Parser<arm>::validFile(fileContent, true) ) {
+ return Parser<arm>::fileKind(fileContent);
+ }
++#endif
+ #if SUPPORT_ARCH_arm64
+ if ( Parser<arm64>::validFile(fileContent, false) ) {
+ return Parser<arm64>::fileKind(fileContent);
+--- ld64-236.3/src/ld/parsers/macho_relocatable_file.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/parsers/macho_relocatable_file.cpp 2015-01-23 07:02:23.000000000 +0100
+@@ -861,6 +861,7 @@
+ }
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ void Atom<arm>::verifyAlignment(const macho_section<P>&) const
+ {
+@@ -869,6 +870,7 @@
+ warning("ARM function not 4-byte aligned: %s from %s", this->name(), this->file()->path());
+ }
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -1218,6 +1220,7 @@
+ return true;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ bool Parser<arm>::validFile(const uint8_t* fileContent, bool subtypeMustMatch, cpu_subtype_t subtype)
+ {
+@@ -1238,8 +1241,10 @@
+ }
+ return true;
+ }
++#endif
+
+
++#if SUPPORT_ARCH_arm64
+ template <>
+ bool Parser<arm64>::validFile(const uint8_t* fileContent, bool subtypeMustMatch, cpu_subtype_t subtype)
+ {
+@@ -1252,6 +1257,7 @@
+ return false;
+ return true;
+ }
++#endif
+
+
+ template <>
+@@ -1276,6 +1282,7 @@
+ return "x86_64";
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ const char* Parser<arm>::fileKind(const uint8_t* fileContent)
+ {
+@@ -1291,6 +1298,7 @@
+ }
+ return "arm???";
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -1802,8 +1810,12 @@
+
+ template <> uint8_t Parser<x86>::loadCommandSizeMask() { return 0x03; }
+ template <> uint8_t Parser<x86_64>::loadCommandSizeMask() { return 0x07; }
++#if SUPPORT_ARCH_arm_any
+ template <> uint8_t Parser<arm>::loadCommandSizeMask() { return 0x03; }
++#endif
++#if SUPPORT_ARCH_arm64
+ template <> uint8_t Parser<arm64>::loadCommandSizeMask() { return 0x07; }
++#endif
+
+ template <typename A>
+ bool Parser<A>::parseLoadCommands()
+@@ -3921,8 +3933,10 @@
+ return 1 + (this->_machOSection - parser.firstMachOSection());
+ }
+
++#if SUPPORT_ARCH_arm_any
+ // arm does not have zero cost exceptions
+ template <> uint32_t CFISection<arm>::cfiCount() { return 0; }
++#endif
+
+ template <typename A>
+ uint32_t CFISection<A>::cfiCount()
+@@ -4050,6 +4064,7 @@
+
+
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ void CFISection<arm>::cfiParse(class Parser<arm>& parser, uint8_t* buffer,
+ libunwind::CFI_Atom_Info<CFISection<arm>::OAS>::CFI_Atom_Info cfiArray[],
+@@ -4058,6 +4073,7 @@
+ // arm does not use zero cost exceptions
+ assert(count == 0);
+ }
++#endif
+
+ template <>
+ void CFISection<arm64>::cfiParse(class Parser<arm64>& parser, uint8_t* buffer,
+@@ -4159,8 +4175,12 @@
+
+ template <> bool CFISection<x86_64>::bigEndian() { return false; }
+ template <> bool CFISection<x86>::bigEndian() { return false; }
++#if SUPPORT_ARCH_arm_any
+ template <> bool CFISection<arm>::bigEndian() { return false; }
++#endif
++#if SUPPORT_ARCH_arm64
+ template <> bool CFISection<arm64>::bigEndian() { return false; }
++#endif
+
+
+ template <>
+@@ -5077,11 +5097,13 @@
+ return ld::Fixup::kindStoreLittleEndian32;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ ld::Fixup::Kind NonLazyPointerSection<arm>::fixupKind()
+ {
+ return ld::Fixup::kindStoreLittleEndian32;
+ }
++#endif
+
+ template <>
+ ld::Fixup::Kind NonLazyPointerSection<arm64>::fixupKind()
+@@ -7170,10 +7192,14 @@
+ return ( mach_o::relocatable::Parser<x86_64>::validFile(fileContent) );
+ case CPU_TYPE_I386:
+ return ( mach_o::relocatable::Parser<x86>::validFile(fileContent) );
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ return ( mach_o::relocatable::Parser<arm>::validFile(fileContent, opts.objSubtypeMustMatch, opts.subType) );
++#endif
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
+ return ( mach_o::relocatable::Parser<arm64>::validFile(fileContent, opts.objSubtypeMustMatch, opts.subType) );
++#endif
+ }
+ return false;
+ }
+@@ -7194,17 +7220,21 @@
+ *subResult = CPU_SUBTYPE_X86_ALL;
+ return true;
+ }
++#if SUPPORT_ARCH_arm_any
+ if ( mach_o::relocatable::Parser<arm>::validFile(fileContent, false, 0) ) {
+ *result = CPU_TYPE_ARM;
+ const macho_header<Pointer32<LittleEndian> >* header = (const macho_header<Pointer32<LittleEndian> >*)fileContent;
+ *subResult = header->cpusubtype();
+ return true;
+ }
++#endif
++#if SUPPORT_ARCH_arm_any
+ if ( mach_o::relocatable::Parser<arm64>::validFile(fileContent, false, 0) ) {
+ *result = CPU_TYPE_ARM64;
+ *subResult = CPU_SUBTYPE_ARM64_ALL;
+ return true;
+ }
++#endif
+ return false;
+ }
+
+@@ -7219,9 +7249,11 @@
+ if ( mach_o::relocatable::Parser<x86>::validFile(fileContent) ) {
+ return mach_o::relocatable::Parser<x86>::fileKind(fileContent);
+ }
++#if SUPPORT_ARCH_arm_any
+ if ( mach_o::relocatable::Parser<arm>::validFile(fileContent, false, 0) ) {
+ return mach_o::relocatable::Parser<arm>::fileKind(fileContent);
+ }
++#endif
+ return NULL;
+ }
+
+@@ -7233,9 +7265,11 @@
+ if ( mach_o::relocatable::Parser<x86_64>::validFile(fileContent) ) {
+ return mach_o::relocatable::Parser<x86_64>::hasObjC2Categories(fileContent);
+ }
++#if SUPPORT_ARCH_arm_any
+ else if ( mach_o::relocatable::Parser<arm>::validFile(fileContent, false, 0) ) {
+ return mach_o::relocatable::Parser<arm>::hasObjC2Categories(fileContent);
+ }
++#endif
+ else if ( mach_o::relocatable::Parser<x86>::validFile(fileContent, false, 0) ) {
+ return mach_o::relocatable::Parser<x86>::hasObjC2Categories(fileContent);
+ }
+--- ld64-236.3/src/ld/passes/branch_island.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/passes/branch_island.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -284,6 +284,7 @@
+ static uint64_t textSizeWhenMightNeedBranchIslands(const Options& opts, bool seenThumbBranch)
+ {
+ switch ( opts.architecture() ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( ! seenThumbBranch )
+ return 32000000; // ARM can branch +/- 32MB
+@@ -292,6 +293,7 @@
+ else
+ return 4000000; // thumb1 can branch +/- 4MB
+ break;
++#endif
+ }
+ assert(0 && "unexpected architecture");
+ return 0x100000000LL;
+@@ -301,6 +303,7 @@
+ static uint64_t maxDistanceBetweenIslands(const Options& opts, bool seenThumbBranch)
+ {
+ switch ( opts.architecture() ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( ! seenThumbBranch )
+ return 30*1024*1024; // 2MB of branch islands per 32MB
+@@ -309,6 +312,7 @@
+ else
+ return 3500000; // 0.5MB of branch islands per 4MB
+ break;
++#endif
+ }
+ assert(0 && "unexpected architecture");
+ return 0x100000000LL;
+@@ -653,8 +657,10 @@
+
+ // only ARM needs branch islands
+ switch ( opts.architecture() ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ break;
++#endif
+ default:
+ return;
+ }
+--- ld64-236.3/src/ld/passes/branch_shim.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/passes/branch_shim.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -276,6 +276,9 @@
+ //
+ void doPass(const Options& opts, ld::Internal& state)
+ {
++#if !SUPPORT_ARCH_arm_any
++ return;
++#else
+ // only make branch shims in final linked images
+ if ( opts.outputKind() == Options::kObjectFile )
+ return;
+@@ -386,6 +389,7 @@
+ // append all new shims to end of __text
+ sect->atoms.insert(sect->atoms.end(), shims.begin(), shims.end());
+ }
++#endif
+ }
+
+
+--- ld64-236.3/src/ld/passes/dtrace_dof.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/passes/dtrace_dof.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -179,8 +179,12 @@
+ switch ( opts.architecture() ) {
+ case CPU_TYPE_I386:
+ case CPU_TYPE_X86_64:
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ storeKind = ld::Fixup::kindStoreLittleEndian32;
+ break;
+ default:
+--- ld64-236.3/src/ld/passes/stubs/stubs.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/passes/stubs/stubs.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -324,9 +324,11 @@
+ if ( _options.outputKind() != Options::kDynamicLibrary )
+ throwf("resolver functions (%s) can only be used in dylibs", atom->name());
+ if ( !_options.makeCompressedDyldInfo() ) {
++#if SUPPORT_ARCH_arm_any
+ if ( _options.architecture() == CPU_TYPE_ARM )
+ throwf("resolver functions (%s) can only be used when targeting iOS 4.2 or later", atom->name());
+ else
++#endif
+ throwf("resolver functions (%s) can only be used when targeting Mac OS X 10.6 or later", atom->name());
+ }
+ stubFor[atom] = NULL;
+@@ -354,6 +356,7 @@
+ throw "symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o";
+
+ // disable arm close stubs in some cases
++#if SUPPORT_ARCH_arm_any
+ if ( _architecture == CPU_TYPE_ARM ) {
+ if ( codeSize > 4*1024*1024 )
+ _largeText = true;
+@@ -377,6 +380,7 @@
+ }
+ }
+ }
++#endif
+
+ // make stub atoms
+ for (std::map<const ld::Atom*,ld::Atom*>::iterator it = stubFor.begin(); it != stubFor.end(); ++it) {
+--- ld64-236.3/src/ld/Resolver.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/ld/Resolver.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -396,6 +396,7 @@
+ // update cpu-sub-type
+ cpu_subtype_t nextObjectSubType = file.cpuSubType();
+ switch ( _options.architecture() ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( _options.subArchitecture() != nextObjectSubType ) {
+ if ( (_options.subArchitecture() == CPU_SUBTYPE_ARM_ALL) && _options.forceCpuSubtypeAll() ) {
+@@ -414,6 +415,7 @@
+ }
+ }
+ break;
++#endif
+
+ case CPU_TYPE_I386:
+ _internal.cpuSubType = CPU_SUBTYPE_I386_ALL;
+--- ld64-236.3/src/other/machochecker.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/other/machochecker.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -252,6 +252,7 @@
+ return false;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ bool MachOChecker<arm>::validFile(const uint8_t* fileContent)
+ {
+@@ -269,6 +270,7 @@
+ }
+ return false;
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -294,7 +296,9 @@
+ template <> uint8_t MachOChecker<ppc64>::loadCommandSizeMask() { return 0x07; }
+ template <> uint8_t MachOChecker<x86>::loadCommandSizeMask() { return 0x03; }
+ template <> uint8_t MachOChecker<x86_64>::loadCommandSizeMask() { return 0x07; }
++#if SUPPORT_ARCH_arm_any
+ template <> uint8_t MachOChecker<arm>::loadCommandSizeMask() { return 0x03; }
++#endif
+ #if SUPPORT_ARCH_arm64
+ template <> uint8_t MachOChecker<arm64>::loadCommandSizeMask() { return 0x07; }
+ #endif
+@@ -324,11 +328,13 @@
+ return threadInfo->thread_register(7);
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ arm::P::uint_t MachOChecker<arm>::getInitialStackPointer(const macho_thread_command<arm::P>* threadInfo)
+ {
+ return threadInfo->thread_register(13);
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -362,11 +368,13 @@
+ return threadInfo->thread_register(16);
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ arm::P::uint_t MachOChecker<arm>::getEntryPoint(const macho_thread_command<arm::P>* threadInfo)
+ {
+ return threadInfo->thread_register(15);
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -1025,6 +1033,7 @@
+ return fFirstWritableSegment->vmaddr();
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ arm::P::uint_t MachOChecker<arm>::relocBase()
+ {
+@@ -1033,6 +1042,7 @@
+ else
+ return fFirstSegment->vmaddr();
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+--- ld64-236.3/src/other/ObjectDump.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/other/ObjectDump.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -806,6 +806,7 @@
+ case ld::Fixup::kindStoreThumbHigh16:
+ printf(", then store high-16 in Thumb movt");
+ break;
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreARM64Branch26:
+ printf(", then store as ARM64 26-bit pcrel branch");
+ break;
+@@ -839,6 +840,7 @@
+ case ld::Fixup::kindStoreARM64PCRelToGOT:
+ printf(", then store as 32-bit delta to GOT entry");
+ break;
++#endif
+ case ld::Fixup::kindDtraceExtra:
+ printf("dtrace static probe extra info");
+ break;
+@@ -983,6 +985,7 @@
+ case ld::Fixup::kindSetTargetTLVTemplateOffsetLittleEndian64:
+ printf("tlv template offset of %s", referenceTargetAtomName(ref));
+ break;
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreTargetAddressARM64Branch26:
+ printf("ARM64 store 26-bit pcrel branch to %s", referenceTargetAtomName(ref));
+ break;
+@@ -1010,6 +1013,7 @@
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPageOff12:
+ printf("ARM64 store 12-bit page offset of lea of %s", referenceTargetAtomName(ref));
+ break;
++#endif
+ //default:
+ // printf("unknown fixup");
+ // break;
+--- ld64-236.3/src/other/rebase.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/other/rebase.cpp 2015-01-23 06:56:04.000000000 +0100
+@@ -160,9 +160,11 @@
+ case CPU_TYPE_X86_64:
+ fRebasers.push_back(new Rebaser<x86_64>(&p[fileOffset]));
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ fRebasers.push_back(new Rebaser<arm>(&p[fileOffset]));
+ break;
++#endif
+ default:
+ throw "unknown file format";
+ }
+@@ -186,9 +188,11 @@
+ else if ( (OSSwapLittleToHostInt32(mh->magic) == MH_MAGIC_64) && (OSSwapLittleToHostInt32(mh->cputype) == CPU_TYPE_X86_64)) {
+ fRebasers.push_back(new Rebaser<x86_64>(mh));
+ }
++#if SUPPORT_ARCH_arm_any
+ else if ( (OSSwapLittleToHostInt32(mh->magic) == MH_MAGIC) && (OSSwapLittleToHostInt32(mh->cputype) == CPU_TYPE_ARM)) {
+ fRebasers.push_back(new Rebaser<arm>(mh));
+ }
++#endif
+ else {
+ throw "unknown file format";
+ }
+@@ -236,7 +240,9 @@
+ template <> cpu_type_t Rebaser<ppc64>::getArchitecture() const { return CPU_TYPE_POWERPC64; }
+ template <> cpu_type_t Rebaser<x86>::getArchitecture() const { return CPU_TYPE_I386; }
+ template <> cpu_type_t Rebaser<x86_64>::getArchitecture() const { return CPU_TYPE_X86_64; }
++#if SUPPORT_ARCH_arm_any
+ template <> cpu_type_t Rebaser<arm>::getArchitecture() const { return CPU_TYPE_ARM; }
++#endif
+
+ template <typename A>
+ uint64_t Rebaser<A>::getBaseAddress() const
+@@ -875,8 +881,10 @@
+ return "i386";
+ case CPU_TYPE_X86_64:
+ return "x86_64";
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ return "arm";
++#endif
+ }
+ return "unknown";
+ }
+@@ -969,6 +977,7 @@
+ else if ( arch == CPU_TYPE_X86_64 ) {
+ return 0x200000000ULL;
+ }
++#if SUPPORT_ARCH_arm_any
+ else if ( arch == CPU_TYPE_ARM ) {
+ // place dylibs below dyld
+ uint64_t topAddr = 0x2FE00000;
+@@ -977,6 +986,7 @@
+ throwf("total size of images (0x%X) does not fit below 0x2FE00000", totalSize);
+ return topAddr - totalSize;
+ }
++#endif
+ else
+ throw "unknown architecture";
+ }
+@@ -1043,7 +1053,9 @@
+ onlyArchs.insert(CPU_TYPE_POWERPC64);
+ onlyArchs.insert(CPU_TYPE_I386);
+ onlyArchs.insert(CPU_TYPE_X86_64);
++#if SUPPORT_ARCH_arm_any
+ onlyArchs.insert(CPU_TYPE_ARM);
++#endif
+ }
+
+ // scan files and collect sizes
+--- ld64-236.3/src/other/unwinddump.cpp.orig 2015-01-23 06:55:36.000000000 +0100
++++ ld64-236.3/src/other/unwinddump.cpp 2015-01-23 07:03:16.000000000 +0100
+@@ -97,7 +97,9 @@
+
+ template <> const char* UnwindPrinter<x86>::archName() { return "i386"; }
+ template <> const char* UnwindPrinter<x86_64>::archName() { return "x86_64"; }
++#if SUPPORT_ARCH_arm_any
+ template <> const char* UnwindPrinter<arm>::archName() { return "arm"; }
++#endif
+ #if SUPPORT_ARCH_arm64
+ template <> const char* UnwindPrinter<arm64>::archName() { return "arm64"; }
+ #endif
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-nolto.patch b/sys-devel/binutils-apple/files/ld64-236.3-nolto.patch
new file mode 100644
index 000000000000..5d68c377ea0e
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-nolto.patch
@@ -0,0 +1,219 @@
+Allow to fully disable LTO
+
+--- ld64-236.3/src/ld/InputFiles.cpp
++++ ld64-236.3/src/ld/InputFiles.cpp
+@@ -59,7 +59,9 @@
+ #include "macho_relocatable_file.h"
+ #include "macho_dylib_file.h"
+ #include "archive_file.h"
++#ifdef LTO
+ #include "lto_file.h"
++#endif
+ #include "opaque_section_file.h"
+ #include "MachOFileAbstraction.hpp"
+ #include "Snapshot.h"
+@@ -187,9 +189,11 @@
+ if ( result != NULL )
+ return result;
+
++#ifdef LTO
+ result = lto::archName(p, len);
+ if ( result != NULL )
+ return result;
++#endif
+
+ if ( strncmp((const char*)p, "!<arch>\n", 8) == 0 )
+ return "archive";
+@@ -292,6 +296,7 @@
+ return objResult;
+ }
+
++#ifdef LTO
+ // see if it is an llvm object file
+ objResult = lto::parse(p, len, info.path, info.modTime, info.ordinal, _options.architecture(), _options.subArchitecture(), _options.logAllFiles(), _options.verboseOptimizationHints());
+ if ( objResult != NULL ) {
+@@ -299,6 +304,7 @@
+ OSAtomicIncrement32(&_totalObjectLoaded);
+ return objResult;
+ }
++#endif
+
+ // see if it is a dynamic library
+ ld::dylib::File* dylibResult = mach_o::dylib::parse(p, len, info.path, info.modTime, _options, info.ordinal, info.options.fBundleLoader, indirectDylib);
+@@ -322,6 +328,7 @@
+ return archiveResult;
+ }
+
++#ifdef LTO
+ // does not seem to be any valid linker input file, check LTO misconfiguration problems
+ if ( lto::archName((uint8_t*)p, len) != NULL ) {
+ if ( lto::libLTOisLoaded() ) {
+@@ -349,6 +356,7 @@
+ throwf("could not process llvm bitcode object file, because %s could not be loaded", libLTO);
+ }
+ }
++#endif
+
+ // error handling
+ if ( ((fat_header*)p)->magic == OSSwapBigToHostInt32(FAT_MAGIC) ) {
+--- ld64-236.3/src/ld/ld.cpp
++++ ld64-236.3/src/ld/ld.cpp
+@@ -91,7 +91,9 @@
+ #include "parsers/archive_file.h"
+ #include "parsers/macho_relocatable_file.h"
+ #include "parsers/macho_dylib_file.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+ #include "parsers/opaque_section_file.h"
+
+
+--- ld64-236.3/src/ld/Options.cpp
++++ ld64-236.3/src/ld/Options.cpp
+@@ -41,10 +41,13 @@
+ #include "MachOFileAbstraction.hpp"
+ #include "Snapshot.h"
+
++
++#ifdef LTO
+ // upward dependency on lto::version()
+ namespace lto {
+ extern const char* version();
+ }
++#endif
+
+ // magic to place command line in crash reports
+ const int crashreporterBufferSize = 2000;
+@@ -3179,9 +3182,11 @@
+ fprintf(stderr, "configured to support archs: %s\n", ALL_SUPPORTED_ARCHS);
+ // if only -v specified, exit cleanly
+ if ( argc == 2 ) {
++#ifdef LTO
+ const char* ltoVers = lto::version();
+ if ( ltoVers != NULL )
+ fprintf(stderr, "LTO support using: %s\n", ltoVers);
++#endif
+ exit(0);
+ }
+ }
+--- ld64-236.3/src/ld/parsers/archive_file.cpp
++++ ld64-236.3/src/ld/parsers/archive_file.cpp
+@@ -45,7 +45,9 @@
+ #include "Architectures.hpp"
+
+ #include "macho_relocatable_file.h"
++#ifdef LTO
+ #include "lto_file.h"
++#endif
+ #include "archive_file.h"
+
+
+@@ -97,8 +99,10 @@
+ private:
+ static bool validMachOFile(const uint8_t* fileContent, uint64_t fileLength,
+ const mach_o::relocatable::ParserOptions& opts);
++#ifdef LTO
+ static bool validLTOFile(const uint8_t* fileContent, uint64_t fileLength,
+ const mach_o::relocatable::ParserOptions& opts);
++#endif
+ static cpu_type_t architecture();
+
+ class Entry : ar_hdr
+@@ -242,11 +246,13 @@
+ return mach_o::relocatable::isObjectFile(fileContent, fileLength, opts);
+ }
+
++#ifdef LTO
+ template <typename A>
+ bool File<A>::validLTOFile(const uint8_t* fileContent, uint64_t fileLength, const mach_o::relocatable::ParserOptions& opts)
+ {
+ return lto::isObjectFile(fileContent, fileLength, opts.architecture, opts.subType);
+ }
++#endif
+
+
+
+@@ -267,7 +273,11 @@
+ if ( (p==start) && ((strcmp(memberName, SYMDEF_SORTED) == 0) || (strcmp(memberName, SYMDEF) == 0)) )
+ continue;
+ // archive is valid if first .o file is valid
+- return (validMachOFile(p->content(), p->contentSize(), opts) || validLTOFile(p->content(), p->contentSize(), opts));
++ return (validMachOFile(p->content(), p->contentSize(), opts)
++#ifdef LTO
++ || validLTOFile(p->content(), p->contentSize(), opts)
++#endif
++ );
+ }
+ // empty archive
+ return true;
+@@ -388,6 +398,7 @@
+ _instantiatedEntries[member] = state;
+ return _instantiatedEntries[member];
+ }
++#ifdef LTO
+ // see if member is llvm bitcode file
+ result = lto::parse(member->content(), member->contentSize(),
+ mPath, member->modificationTime(), ordinal,
+@@ -397,6 +408,7 @@
+ _instantiatedEntries[member] = state;
+ return _instantiatedEntries[member];
+ }
++#endif
+
+ throwf("archive member '%s' with length %d is not mach-o or llvm bitcode", memberName, member->contentSize());
+ }
+--- ld64-236.3/src/ld/Resolver.cpp
++++ ld64-236.3/src/ld/Resolver.cpp
+@@ -56,7 +56,9 @@
+ #include "InputFiles.h"
+ #include "SymbolTable.h"
+ #include "Resolver.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+
+
+ namespace ld {
+@@ -1438,6 +1440,7 @@
+
+ void Resolver::linkTimeOptimize()
+ {
++#ifdef LTO
+ // only do work here if some llvm obj files where loaded
+ if ( ! _haveLLVMObjs )
+ return;
+@@ -1535,6 +1538,9 @@
+ // check new code does not override some dylib
+ this->checkDylibSymbolCollisions();
+ }
++#else
++ return;
++#endif
+ }
+
+
+--- ld64-236.3/src/other/ObjectDump.cpp
++++ ld64-236.3/src/other/ObjectDump.cpp
+@@ -33,7 +33,9 @@
+
+ #include "MachOFileAbstraction.hpp"
+ #include "parsers/macho_relocatable_file.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+
+ static bool sDumpContent= true;
+ static bool sDumpStabs = false;
+@@ -1249,10 +1251,12 @@
+ if ( objResult != NULL )
+ return objResult;
+
++#ifdef LTO
+ // see if it is an llvm object file
+ objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, ld::File::Ordinal::NullOrdinal(), sPreferredArch, sPreferredSubArch, false, true);
+ if ( objResult != NULL )
+ return objResult;
++#endif
+
+ throwf("not a mach-o object file: %s", path);
+ #else
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-noppc.patch b/sys-devel/binutils-apple/files/ld64-236.3-noppc.patch
new file mode 100644
index 000000000000..85e9d94b35e1
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-noppc.patch
@@ -0,0 +1,26 @@
+Allow to fully disable powerpc.
+
+--- ld64-236.3/src/ld/parsers/macho_dylib_file.cpp.orig 2015-01-23 17:59:55.000000000 +0100
++++ ld64-236.3/src/ld/parsers/macho_dylib_file.cpp 2015-01-23 18:00:04.000000000 +0100
+@@ -1095,17 +1095,21 @@
+ *subResult = CPU_SUBTYPE_ARM64_ALL;
+ return true;
+ }
++#ifdef SUPPORT_ARCH_ppc
+ if ( Parser<ppc>::validFile(fileContent, false) ) {
+ *result = CPU_TYPE_POWERPC;
+ const macho_header<Pointer32<BigEndian> >* header = (const macho_header<Pointer32<BigEndian> >*)fileContent;
+ *subResult = header->cpusubtype();
+ return true;
+ }
++#endif
++#ifdef SUPPORT_ARCH_ppc64
+ if ( Parser<ppc64>::validFile(fileContent, false) ) {
+ *result = CPU_TYPE_POWERPC64;
+ *subResult = CPU_SUBTYPE_POWERPC_ALL;
+ return true;
+ }
++#endif
+ return false;
+ }
+
diff --git a/sys-devel/binutils-apple/files/ld64-236.3-nosnapshots.patch b/sys-devel/binutils-apple/files/ld64-236.3-nosnapshots.patch
new file mode 100644
index 000000000000..aa75a03cbf74
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-236.3-nosnapshots.patch
@@ -0,0 +1,644 @@
+Allow to disable snapshot support because of missing Block API on OS X < 10.6.
+
+--- ld64-236.3/src/ld/ld.cpp.orig 2015-01-16 14:49:49.000000000 -0800
++++ ld64-236.3/src/ld/ld.cpp 2015-01-16 14:50:42.000000000 -0800
+@@ -1072,11 +1072,13 @@
+ // implement assert() function to print out a backtrace before aborting
+ void __assert_rtn(const char* func, const char* file, int line, const char* failedexpr)
+ {
++#ifdef SUPPORT_SNAPSHOTS
+ Snapshot *snapshot = Snapshot::globalSnapshot;
+
+ snapshot->setSnapshotMode(Snapshot::SNAPSHOT_DEBUG);
+ snapshot->createSnapshot();
+ snapshot->recordAssertionMessage("Assertion failed: (%s), function %s, file %s, line %d.\n", failedexpr, func, file, line);
++#endif
+
+ void* callStack[128];
+ int depth = ::backtrace(callStack, 128);
+@@ -1094,9 +1096,13 @@
+ }
+ long offset = (uintptr_t)callStack[i] - (uintptr_t)info.dli_saddr;
+ fprintf(stderr, "%d %p %s + %ld\n", i, callStack[i], symboName, offset);
++#ifdef SUPPORT_SNAPSHOTS
+ snapshot->recordAssertionMessage("%d %p %s + %ld\n", i, callStack[i], symboName, offset);
++#endif
+ }
++#ifdef SUPPORT_SNAPSHOTS
+ fprintf(stderr, "A linker snapshot was created at:\n\t%s\n", snapshot->rootDir());
++#endif
+ fprintf(stderr, "ld: Assertion failed: (%s), function %s, file %s, line %d.\n", failedexpr, func, file, line);
+ exit(1);
+ }
+--- ld64-236.3/src/ld/Options.cpp.orig 2015-01-16 14:49:49.000000000 -0800
++++ ld64-236.3/src/ld/Options.cpp 2015-01-16 14:50:42.000000000 -0800
+@@ -182,7 +182,11 @@
+ fGenerateDtraceDOF(true), fAllowBranchIslands(true),
+ fDebugInfoStripping(kDebugInfoMinimal), fTraceOutputFile(NULL),
+ fMacVersionMin(ld::macVersionUnset), fIOSVersionMin(ld::iOSVersionUnset),
+- fSaveTempFiles(false), fSnapshotRequested(false), fPipelineFifo(NULL),
++ fSaveTempFiles(false),
++#ifdef SUPPORT_SNAPSHOTS
++ fSnapshotRequested(false),
++#endif
++ fPipelineFifo(NULL),
+ fDependencyInfoPath(NULL), fDependencyFileDescriptor(-1)
+ {
+ this->checkForClassic(argc, argv);
+@@ -577,7 +581,9 @@
+ }
+ break;
+ }
++#ifdef SUPPORT_SNAPSHOTS
+ fLinkSnapshot.recordArch(fArchitectureName);
++#endif
+ // only use compressed LINKEDIT for:
+ // Mac OS X 10.6 or later
+ // iOS 3.1 or later
+@@ -1822,8 +1828,10 @@
+ //
+ void Options::parse(int argc, const char* argv[])
+ {
++#ifdef SUPPORT_SNAPSHOTS
+ // Store the original args in the link snapshot.
+ fLinkSnapshot.recordRawArgs(argc, argv);
++#endif
+
+ // pass one builds search list from -L and -F options
+ this->buildSearchPaths(argc, argv);
+@@ -1836,17 +1844,21 @@
+ const char* arg = argv[i];
+
+ if ( arg[0] == '-' ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // by default, copy one arg to the snapshot link command, and do no file copying
+ int snapshotArgIndex = i;
+ int snapshotArgCount = -1; // -1 means compute count based on change in index
+ int snapshotFileArgIndex = -1; // -1 means no data file parameter to arg
++#endif
+
+ // Since we don't care about the files passed, just the option names, we do this here.
+ if (fPrintOptions)
+ fprintf (stderr, "[Logging ld64 options]\t%s\n", arg);
+
+ if ( (arg[1] == 'L') || (arg[1] == 'F') ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0; // stripped out of link snapshot
++#endif
+ if (arg[2] == '\0')
+ ++i;
+ // previously handled by buildSearchPaths()
+@@ -1893,12 +1905,16 @@
+ fOutputKind = kKextBundle;
+ }
+ else if ( strcmp(arg, "-o") == 0 ) {
+- snapshotArgCount = 0;
+ fOutputFile = argv[++i];
++#ifdef SUPPORT_SNAPSHOTS
++ snapshotArgCount = 0;
+ fLinkSnapshot.setSnapshotName(fOutputFile);
++#endif
+ }
+ else if ( strncmp(arg, "-lazy-l", 7) == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[7], true);
+ info.options.fLazyLoad = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -1906,13 +1922,17 @@
+ fUsingLazyDylibLinking = true;
+ }
+ else if ( strcmp(arg, "-lto_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ fOverridePathlibLTO = argv[++i];
+ if ( fOverridePathlibLTO == NULL )
+ throw "missing argument to -lto_library";
+ }
+ else if ( (arg[1] == 'l') && (strncmp(arg,"-lazy_",6) !=0) ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[2]);
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+@@ -1920,8 +1940,10 @@
+ // This causes a dylib to be weakly bound at
+ // link time. This corresponds to weak_import.
+ else if ( strncmp(arg, "-weak-l", 7) == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[7]);
+ info.options.fWeakImport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -1979,12 +2001,16 @@
+ else if ( strcmp(arg, "-sectorder") == 0 ) {
+ if ( (argv[i+1]==NULL) || (argv[i+2]==NULL) || (argv[i+3]==NULL) )
+ throw "-sectorder missing <segment> <section> <file-path>";
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 3;
++#endif
+ parseSectionOrderFile(argv[i+1], argv[i+2], argv[i+3]);
+ i += 3;
+ }
+ else if ( strcmp(arg, "-order_file") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ parseOrderFile(argv[++i], false);
+ }
+ else if ( strcmp(arg, "-order_file_statistics") == 0 ) {
+@@ -1995,7 +2021,9 @@
+ else if ( (strcmp(arg, "-sectcreate") == 0) || (strcmp(arg, "-segcreate") == 0) ) {
+ if ( (argv[i+1]==NULL) || (argv[i+2]==NULL) || (argv[i+3]==NULL) )
+ throw "-sectcreate missing <segment> <section> <file-path>";
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 3;
++#endif
+ addSection(argv[i+1], argv[i+2], argv[i+3]);
+ i += 3;
+ }
+@@ -2024,7 +2052,9 @@
+ }
+ // Same as -@ from the FSF linker.
+ else if ( strcmp(arg, "-filelist") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ const char* path = argv[++i];
+ if ( (path == NULL) || (path[0] == '-') )
+ throw "-filelist missing <path>";
+@@ -2051,7 +2081,9 @@
+ }
+ }
+ else if ( strcmp(arg, "-interposable_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ fInterposeMode = kInterposeSome;
+ loadExportFile(argv[++i], "-interposable_list", fInterposeList);
+ }
+@@ -2060,14 +2092,18 @@
+ fInterposeMode = kInterposeNone;
+ }
+ else if ( strcmp(arg, "-exported_symbols_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fExportMode == kDontExportSome )
+ throw "can't use -exported_symbols_list and -unexported_symbols_list";
+ fExportMode = kExportSome;
+ loadExportFile(argv[++i], "-exported_symbols_list", fExportSymbols);
+ }
+ else if ( strcmp(arg, "-unexported_symbols_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fExportMode == kExportSome )
+ throw "can't use -unexported_symbols_list and -exported_symbols_list";
+ fExportMode = kDontExportSome;
+@@ -2086,14 +2122,18 @@
+ fDontExportSymbols.insert(argv[++i]);
+ }
+ else if ( strcmp(arg, "-non_global_symbols_no_strip_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fLocalSymbolHandling == kLocalSymbolsSelectiveExclude )
+ throw "can't use -non_global_symbols_no_strip_list and -non_global_symbols_strip_list";
+ fLocalSymbolHandling = kLocalSymbolsSelectiveInclude;
+ loadExportFile(argv[++i], "-non_global_symbols_no_strip_list", fLocalSymbolsIncluded);
+ }
+ else if ( strcmp(arg, "-non_global_symbols_strip_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fLocalSymbolHandling == kLocalSymbolsSelectiveInclude )
+ throw "can't use -non_global_symbols_no_strip_list and -non_global_symbols_strip_list";
+ fLocalSymbolHandling = kLocalSymbolsSelectiveExclude;
+@@ -2109,16 +2149,20 @@
+ }
+ // Similar to -weak-l but uses the absolute path name to the library.
+ else if ( strcmp(arg, "-weak_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFile(argv[++i]);
+ info.options.fWeakImport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-lazy_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFile(argv[++i]);
+ info.options.fLazyLoad = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -2126,22 +2170,28 @@
+ fUsingLazyDylibLinking = true;
+ }
+ else if ( strcmp(arg, "-framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-weak_framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.options.fWeakImport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-lazy_framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.options.fLazyLoad = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -2219,8 +2269,10 @@
+ // This should probably be deprecated when we respect -L and -F
+ // when searching for libraries.
+ else if ( strcmp(arg, "-dylib_file") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // ignore for snapshot because a stub dylib will be created in the snapshot
+ snapshotArgCount = 0;
++#endif
+ addDylibOverride(argv[++i]);
+ }
+ // What to expand @executable_path to if found in dependent dylibs
+@@ -2277,7 +2329,9 @@
+ }
+ // ??? Deprecate when we get rid of basing at build time.
+ else if ( strcmp(arg, "-seg_addr_table") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ const char* name = argv[++i];
+ if ( name == NULL )
+ throw "-seg_addr_table missing argument";
+@@ -2341,7 +2395,9 @@
+ i += 2;
+ }
+ else if ( strcmp(arg, "-bundle_loader") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ fBundleLoader = argv[++i];
+ if ( (fBundleLoader == NULL) || (fBundleLoader[0] == '-') )
+ throw "-bundle_loader missing <path>";
+@@ -2573,7 +2629,9 @@
+ // previously handled by buildSearchPaths()
+ }
+ else if ( strcmp(arg, "-syslibroot") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ ++i;
+ // previously handled by buildSearchPaths()
+ }
+@@ -2584,7 +2642,9 @@
+ fUUIDMode = kUUIDRandom;
+ }
+ else if ( strcmp(arg, "-dtrace") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ const char* name = argv[++i];
+ if ( name == NULL )
+ throw "-dtrace missing argument";
+@@ -2607,7 +2667,9 @@
+ fAliases.push_back(pair);
+ }
+ else if ( strcmp(arg, "-alias_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ parseAliasFile(argv[++i]);
+ }
+ else if ( strcmp(arg, "-save-temps") == 0 ) {
+@@ -2638,48 +2700,60 @@
+ fDisablePositionIndependentExecutable = true;
+ }
+ else if ( strncmp(arg, "-reexport-l", 11) == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[11], true);
+ info.options.fReExport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-reexport_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFile(argv[++i]);
+ info.options.fReExport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-reexport_framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.options.fReExport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strncmp(arg, "-upward-l", 9) == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[9], true);
+ info.options.fUpward = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-upward_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFile(argv[++i]);
+ info.options.fUpward = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-upward_framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.options.fUpward = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -2733,7 +2807,9 @@
+ fMarkDeadStrippableDylib = true;
+ }
+ else if ( strcmp(arg, "-exported_symbols_order") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ loadSymbolOrderFile(argv[++i], fExportSymbolsOrder);
+ }
+ else if ( strcmp(arg, "-no_compact_linkedit") == 0 ) {
+@@ -2825,11 +2901,15 @@
+ fObjcCategoryMerging = false;
+ }
+ else if ( strcmp(arg, "-force_symbols_weak_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ loadExportFile(argv[++i], "-force_symbols_weak_list", fForceWeakSymbols);
+ }
+ else if ( strcmp(arg, "-force_symbols_not_weak_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ loadExportFile(argv[++i], "-force_symbols_not_weak_list", fForceNotWeakSymbols);
+ }
+ else if ( strcmp(arg, "-force_symbol_weak") == 0 ) {
+@@ -2845,7 +2925,9 @@
+ fForceNotWeakSymbols.insert(symbol);
+ }
+ else if ( strcmp(arg, "-reexported_symbols_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fExportMode == kExportSome )
+ throw "can't use -exported_symbols_list and -reexported_symbols_list";
+ loadExportFile(argv[++i], "-reexported_symbols_list", fReExportSymbols);
+@@ -2861,6 +2943,7 @@
+ else if ( strcmp(arg, "-page_align_data_atoms") == 0 ) {
+ fPageAlignDataAtoms = true;
+ }
++#ifdef SUPPORT_SNAPSHOTS
+ else if (strcmp(arg, "-debug_snapshot") == 0) {
+ fLinkSnapshot.setSnapshotMode(Snapshot::SNAPSHOT_DEBUG);
+ fSnapshotRequested = true;
+@@ -2873,6 +2956,7 @@
+ fLinkSnapshot.setSnapshotPath(path);
+ fSnapshotRequested = true;
+ }
++#endif
+ else if ( strcmp(arg, "-new_main") == 0 ) {
+ fEntryPointLoadCommandForceOn = true;
+ }
+@@ -2914,7 +2998,9 @@
+ fExportDynamic = true;
+ }
+ else if ( strcmp(arg, "-force_symbols_coalesce_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ loadExportFile(argv[++i], "-force_symbols_coalesce_list", fForceCoalesceSymbols);
+ }
+ else if ( strcmp(arg, "-add_linker_option") == 0 ) {
+@@ -2984,10 +3070,12 @@
+ throwf("unknown option: %s", arg);
+ }
+
++#ifdef SUPPORT_SNAPSHOTS
+ if (snapshotArgCount == -1)
+ snapshotArgCount = i-snapshotArgIndex+1;
+ if (snapshotArgCount > 0)
+ fLinkSnapshot.addSnapshotLinkArg(snapshotArgIndex, snapshotArgCount, snapshotFileArgIndex);
++#endif
+ }
+ else {
+ FileInfo info = findFile(arg);
+@@ -3006,8 +3096,10 @@
+ addLibrary(info);
+ }
+
++#ifdef SUPPORT_SNAPSHOTS
+ if (fSnapshotRequested)
+ fLinkSnapshot.createSnapshot();
++#endif
+ }
+
+
+@@ -3270,6 +3362,7 @@
+ if ( customDyldPath != NULL )
+ fDyldInstallPath = customDyldPath;
+
++#ifdef SUPPORT_SNAPSHOTS
+ const char* debugArchivePath = getenv("LD_DEBUG_SNAPSHOT");
+ if (debugArchivePath != NULL) {
+ fLinkSnapshot.setSnapshotMode(Snapshot::SNAPSHOT_DEBUG);
+@@ -3277,6 +3370,7 @@
+ fLinkSnapshot.setSnapshotPath(debugArchivePath);
+ fSnapshotRequested = true;
+ }
++#endif
+
+ const char* pipeFdString = getenv("LD_PIPELINE_FIFO");
+ if (pipeFdString != NULL) {
+@@ -4133,7 +4227,9 @@
+ if ( strcmp(&lastSlash[1], subUmbrella) == 0 ) {
+ info.options.fReExport = true;
+ found = true;
++#ifdef SUPPORT_SNAPSHOTS
+ fLinkSnapshot.recordSubUmbrella(info.path);
++#endif
+ break;
+ }
+ }
+@@ -4156,7 +4252,9 @@
+ if ( strncmp(&lastSlash[1], subLibrary, dot-lastSlash-1) == 0 ) {
+ info.options.fReExport = true;
+ found = true;
++#ifdef SUPPORT_SNAPSHOTS
+ fLinkSnapshot.recordSubLibrary(info.path);
++#endif
+ break;
+ }
+ }
+--- ld64-236.3/src/ld/Options.h.orig 2015-01-16 14:49:49.000000000 -0800
++++ ld64-236.3/src/ld/Options.h 2015-01-16 14:50:42.000000000 -0800
+@@ -48,7 +48,9 @@
+ extern void throwf (const char* format, ...) __attribute__ ((noreturn,format(printf, 1, 2)));
+ extern void warning(const char* format, ...) __attribute__((format(printf, 1, 2)));
+
++#ifdef SUPPORT_SNAPSHOTS
+ class Snapshot;
++#endif
+
+ class LibraryOptions
+ {
+@@ -362,7 +364,9 @@
+ bool forceWeakNonWildCard(const char* symbolName) const;
+ bool forceNotWeakNonWildcard(const char* symbolName) const;
+ bool forceCoalesce(const char* symbolName) const;
++#ifdef SUPPORT_SNAPSHOTS
+ Snapshot& snapshot() const { return fLinkSnapshot; }
++#endif
+ bool errorBecauseOfWarnings() const;
+ bool needsThreadLoadCommand() const { return fNeedsThreadLoadCommand; }
+ bool needsEntryPointLoadCommand() const { return fEntryPointLoadCommand; }
+@@ -640,8 +644,10 @@
+ std::vector< std::vector<const char*> > fLinkerOptions;
+ std::vector<SectionRename> fSectionRenames;
+ bool fSaveTempFiles;
++#ifdef SUPPORT_SNAPSHOTS
+ mutable Snapshot fLinkSnapshot;
+ bool fSnapshotRequested;
++#endif
+ const char* fPipelineFifo;
+ const char* fDependencyInfoPath;
+ mutable int fDependencyFileDescriptor;
+--- ld64-236.3/src/ld/Snapshot.cpp.orig 2015-01-16 14:51:58.000000000 -0800
++++ ld64-236.3/src/ld/Snapshot.cpp 2015-01-16 14:50:42.000000000 -0800
+@@ -6,6 +6,9 @@
+ // Copyright (c) 2011 Apple Inc. All rights reserved.
+ //
+
++#include "Snapshot.h"
++
++#ifdef SUPPORT_SNAPSHOTS
+ #include <string.h>
+ #include <unistd.h>
+ #include <stdio.h>
+@@ -17,7 +20,6 @@
+ #include <time.h>
+ #include <Block.h>
+
+-#include "Snapshot.h"
+ #include "Options.h"
+
+ #include "compile_stubs.h"
+@@ -538,3 +538,5 @@
+ }
+ }
+ }
++
++#endif /* SUPPORT_SNAPSHOT */
+--- ld64-236.3/src/ld/Snapshot.h.orig 2015-01-23 07:59:55.000000000 +0100
++++ ld64-236.3/src/ld/Snapshot.h 2015-01-23 07:58:14.000000000 +0100
+@@ -8,6 +8,8 @@
+
+ #ifndef ld64_Snapshot_h
+ #define ld64_Snapshot_h
++
++#ifdef SUPPORT_SNAPSHOTS
+ #include <stdint.h>
+ #include <string.h>
+ #include <map>
+@@ -151,3 +153,5 @@
+ };
+
+ #endif
++
++#endif
+--- ld64-236.3/src/ld/InputFiles.cpp.orig 2015-01-16 14:54:33.000000000 -0800
++++ ld64-236.3/src/ld/InputFiles.cpp 2015-01-16 14:55:37.000000000 -0800
+@@ -1101,7 +1101,9 @@
+ case ld::File::Reloc:
+ {
+ ld::relocatable::File* reloc = (ld::relocatable::File*)file;
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordObjectFile(reloc->path());
++#endif
+ if ( _options.dumpDependencyInfo() )
+ _options.dumpDependency(Options::depObjectFile, reloc->path());
+ }
+@@ -1201,7 +1203,9 @@
+ if ( dylibFile->justInTimeforEachAtom(name, handler) ) {
+ // we found a definition in this dylib
+ // done, unless it is a weak definition in which case we keep searching
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordDylibSymbol(dylibFile, name);
++#endif
+ if ( !dylibFile->hasWeakExternals() || !dylibFile->hasWeakDefinition(name)) {
+ return true;
+ }
+@@ -1215,7 +1219,9 @@
+ if ( archiveFile->justInTimeDataOnlyforEachAtom(name, handler) ) {
+ if ( _options.traceArchives() )
+ logArchive(archiveFile);
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordArchive(archiveFile->path());
++#endif
+ // found data definition in static library, done
+ return true;
+ }
+@@ -1224,7 +1230,9 @@
+ if ( archiveFile->justInTimeforEachAtom(name, handler) ) {
+ if ( _options.traceArchives() )
+ logArchive(archiveFile);
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordArchive(archiveFile->path());
++#endif
+ // found definition in static library, done
+ return true;
+ }
+@@ -1251,7 +1259,9 @@
+ if ( dylibFile->justInTimeforEachAtom(name, handler) ) {
+ // we found a definition in this dylib
+ // done, unless it is a weak definition in which case we keep searching
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordDylibSymbol(dylibFile, name);
++#endif
+ if ( !dylibFile->hasWeakExternals() || !dylibFile->hasWeakDefinition(name)) {
+ return true;
+ }
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-arm64-cputype.patch b/sys-devel/binutils-apple/files/ld64-241.9-arm64-cputype.patch
new file mode 100644
index 000000000000..dd0a6f22bc0b
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-arm64-cputype.patch
@@ -0,0 +1,17 @@
+Remove redefinitions of CPU types that cause warnings and mask that some
+platform isn't actually supported on a host version.
+
+diff -ur ld64-241.9/src/abstraction/MachOFileAbstraction.hpp work/ld64-241.9/src/abstraction/MachOFileAbstraction.hpp
+--- ld64-241.9/src/abstraction/MachOFileAbstraction.hpp 2014-11-04 00:30:51.000000000 +0100
++++ ld64-241.9/src/abstraction/MachOFileAbstraction.hpp 2015-01-22 21:31:58.000000000 +0100
+@@ -253,10 +253,6 @@
+
+
+
+-// hack until arm64 headers are worked out
+-#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
+-#define CPU_SUBTYPE_ARM64_ALL 0
+-#define CPU_SUBTYPE_ARM64_V8 1
+
+ #define ARM64_RELOC_UNSIGNED 0 // for pointers
+ #define ARM64_RELOC_SUBTRACTOR 1 // must be followed by a ARM64_RELOC_UNSIGNED
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-atomic-volatile.patch b/sys-devel/binutils-apple/files/ld64-241.9-atomic-volatile.patch
new file mode 100644
index 000000000000..294b05fb88b4
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-atomic-volatile.patch
@@ -0,0 +1,27 @@
+OSAtmicAdd and friends don't expect volatile parameters on OS X < 10.5.
+
+diff -ur ld64-241.9/src/ld/InputFiles.h ld64-241.9/src/ld/InputFiles.h
+--- ld64-241.9/src/ld/InputFiles.h 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/ld/InputFiles.h 2015-01-22 20:19:51.000000000 +0100
+@@ -86,11 +86,16 @@
+ void createIndirectDylibs();
+
+ // for -print_statistics
+- volatile int64_t _totalObjectSize;
+- volatile int64_t _totalArchiveSize;
+- volatile int32_t _totalObjectLoaded;
+- volatile int32_t _totalArchivesLoaded;
+- volatile int32_t _totalDylibsLoaded;
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
++#define LD_ATOMIC_VOLATILE volatile
++#else
++#define LD_ATOMIC_VOLATILE
++#endif
++ LD_ATOMIC_VOLATILE int64_t _totalObjectSize;
++ LD_ATOMIC_VOLATILE int64_t _totalArchiveSize;
++ LD_ATOMIC_VOLATILE int32_t _totalObjectLoaded;
++ LD_ATOMIC_VOLATILE int32_t _totalArchivesLoaded;
++ LD_ATOMIC_VOLATILE int32_t _totalDylibsLoaded;
+
+
+ private:
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-cc_md5.patch b/sys-devel/binutils-apple/files/ld64-241.9-cc_md5.patch
new file mode 100644
index 000000000000..833fec2b66e9
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-cc_md5.patch
@@ -0,0 +1,24 @@
+Provide CC_MD5 on OS X < 10.5.
+
+--- ld64-241.9/src/ld/OutputFile.cpp 2015-01-22 23:20:33.000000000 +0100
++++ ld64-241.9/src/ld/OutputFile.cpp 2015-01-22 23:26:02.000000000 +0100
+@@ -71,6 +71,19 @@
+ #include "LinkEdit.hpp"
+ #include "LinkEditClassic.hpp"
+
++#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
++/* CC_MD5 missing on < 10.5 - provide replacement */
++unsigned char *CC_MD5(const void *data, CC_LONG len, unsigned char *md) {
++ CC_MD5_CTX ctx;
++ if(md == NULL)
++ return NULL;
++
++ CC_MD5_Init(&ctx);
++ CC_MD5_Update(&ctx, data, len);
++ CC_MD5_Final(md, &ctx);
++ return md;
++}
++#endif
+
+ namespace ld {
+ namespace tool {
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-extraneous-includes.patch b/sys-devel/binutils-apple/files/ld64-241.9-extraneous-includes.patch
new file mode 100644
index 000000000000..f1fbbd82ec37
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-extraneous-includes.patch
@@ -0,0 +1,13 @@
+Remove unneeded and sometimes missing headers.
+
+diff -ur ld64-241.9/src/ld/Options.cpp work/ld64-241.9/src/ld/Options.cpp
+--- ld64-241.9/src/ld/Options.cpp 2015-01-22 21:42:04.000000000 +0100
++++ ld64-241.9/src/ld/Options.cpp 2015-01-22 21:45:15.000000000 +0100
+@@ -31,7 +31,6 @@
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <string.h>
+-#include <spawn.h>
+ #include <cxxabi.h>
+ #include <Availability.h>
+
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-gcc.patch b/sys-devel/binutils-apple/files/ld64-241.9-gcc.patch
new file mode 100644
index 000000000000..06b735b242a5
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-gcc.patch
@@ -0,0 +1,1029 @@
+Provide c++11 headers from tr1 include directory and namespace.
+
+Work around weird namespacing bug in gcc-4.2.1 where class ld::Section
+conflicts with template mach_o::relocatable::Section by renaming the latter to
+MRFSection (could possibly be done using sed from ebuild or avoided by figuring
+out, what's actually going on with those namespaces).
+
+--- ./ld64-241.9/src/ld/InputFiles.h.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/InputFiles.h 2015-01-12 22:12:18.000000000 +0100
+@@ -46,6 +46,14 @@
+ #include <pthread.h>
+ #endif
+
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
++#include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
++
+ #include <vector>
+
+ #include "Options.h"
+@@ -107,7 +115,7 @@
+ static void parseWorkerThread(InputFiles *inputFiles);
+ void startThread(void (*threadFunc)(InputFiles *)) const;
+
+- typedef std::unordered_map<const char*, ld::dylib::File*, CStringHash, CStringEquals> InstallNameToDylib;
++ typedef std::UNORDERED_MAP<const char*, ld::dylib::File*, CStringHash, CStringEquals> InstallNameToDylib;
+
+ const Options& _options;
+ std::vector<ld::File*> _inputFiles;
+--- ./ld64-241.9/src/ld/ld.cpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/ld.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -54,7 +54,13 @@
+ #include <vector>
+ #include <list>
+ #include <algorithm>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+ #include <cxxabi.h>
+
+ #include "Options.h"
+@@ -149,7 +155,7 @@
+ struct SectionEquals {
+ bool operator()(const ld::Section* left, const ld::Section* right) const;
+ };
+- typedef std::unordered_map<const ld::Section*, FinalSection*, SectionHash, SectionEquals> SectionInToOut;
++ typedef std::UNORDERED_MAP<const ld::Section*, FinalSection*, SectionHash, SectionEquals> SectionInToOut;
+
+
+ SectionInToOut _sectionInToFinalMap;
+--- ./ld64-241.9/src/ld/ld.hpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/ld.hpp 2015-01-12 22:12:18.000000000 +0100
+@@ -32,7 +32,13 @@
+ #include <assert.h>
+
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "configure.h"
+
+@@ -822,7 +828,7 @@
+ bool operator()(const char* left, const char* right) const { return (strcmp(left, right) == 0); }
+ };
+
+-typedef std::unordered_set<const char*, ld::CStringHash, ld::CStringEquals> CStringSet;
++typedef std::UNORDERED_SET<const char*, ld::CStringHash, ld::CStringEquals> CStringSet;
+
+ class Internal
+ {
+--- ./ld64-241.9/src/ld/LinkEditClassic.hpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/LinkEditClassic.hpp 2015-01-12 22:12:18.000000000 +0100
+@@ -31,8 +31,13 @@
+ #include <limits.h>
+ #include <unistd.h>
+
+-#include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+
+ #include "Options.h"
+ #include "ld.hpp"
+@@ -92,7 +97,7 @@
+
+ private:
+ enum { kBufferSize = 0x01000000 };
+- typedef std::unordered_map<const char*, int32_t, CStringHash, CStringEquals> StringToOffset;
++ typedef std::UNORDERED_MAP<const char*, int32_t, CStringHash, CStringEquals> StringToOffset;
+
+ const uint32_t _pointerSize;
+ std::vector<char*> _fullBuffers;
+--- ./ld64-241.9/src/ld/Options.cpp.gcc 2014-11-04 00:25:08.000000000 +0100
++++ ./ld64-241.9/src/ld/Options.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -4548,7 +4548,7 @@
+
+ // make sure all required exported symbols exist
+ std::vector<const char*> impliedExports;
+- for (NameSet::iterator it=fExportSymbols.regularBegin(); it != fExportSymbols.regularEnd(); ++it) {
++ for (NameSet::const_iterator it=fExportSymbols.regularBegin(); it != fExportSymbols.regularEnd(); ++it) {
+ const char* name = *it;
+ const int len = strlen(name);
+ if ( (strcmp(&name[len-3], ".eh") == 0) || (strncmp(name, ".objc_category_name_", 20) == 0) ) {
+@@ -4580,7 +4580,7 @@
+ }
+
+ // make sure all required re-exported symbols exist
+- for (NameSet::iterator it=fReExportSymbols.regularBegin(); it != fReExportSymbols.regularEnd(); ++it) {
++ for (NameSet::const_iterator it=fReExportSymbols.regularBegin(); it != fReExportSymbols.regularEnd(); ++it) {
+ fInitialUndefines.push_back(*it);
+ }
+
+--- ./ld64-241.9/src/ld/Options.h.gcc 2014-11-04 00:29:32.000000000 +0100
++++ ./ld64-241.9/src/ld/Options.h 2015-01-12 22:12:18.000000000 +0100
+@@ -30,8 +30,17 @@
+ #include <mach/machine.h>
+
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "ld.hpp"
+ #include "Snapshot.h"
+@@ -396,8 +405,8 @@
+ bool moveRwSymbol(const char* symName, const char* filePath, const char*& seg, bool& wildCardMatch) const;
+
+ private:
+- typedef std::unordered_map<const char*, unsigned int, ld::CStringHash, ld::CStringEquals> NameToOrder;
+- typedef std::unordered_set<const char*, ld::CStringHash, ld::CStringEquals> NameSet;
++ typedef std::UNORDERED_MAP<const char*, unsigned int, ld::CStringHash, ld::CStringEquals> NameToOrder;
++ typedef std::UNORDERED_SET<const char*, ld::CStringHash, ld::CStringEquals> NameSet;
+ enum ExportMode { kExportDefault, kExportSome, kDontExportSome };
+ enum LibrarySearchMode { kSearchDylibAndArchiveInEachDir, kSearchAllDirsForDylibsThenAllDirsForArchives };
+ enum InterposeMode { kInterposeNone, kInterposeAllExternal, kInterposeSome };
+@@ -410,8 +419,8 @@
+ bool containsNonWildcard(const char*) const;
+ bool empty() const { return fRegular.empty() && fWildCard.empty(); }
+ bool hasWildCards() const { return !fWildCard.empty(); }
+- NameSet::iterator regularBegin() const { return fRegular.begin(); }
+- NameSet::iterator regularEnd() const { return fRegular.end(); }
++ NameSet::const_iterator regularBegin() const { return fRegular.begin(); }
++ NameSet::const_iterator regularEnd() const { return fRegular.end(); }
+ void remove(const NameSet&);
+ private:
+ static bool hasWildCards(const char*);
+--- ./ld64-241.9/src/ld/OutputFile.cpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/OutputFile.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -50,7 +50,13 @@
+ #include <vector>
+ #include <list>
+ #include <algorithm>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include <CommonCrypto/CommonDigest.h>
+ #include <AvailabilityMacros.h>
+@@ -4748,7 +4754,7 @@
+ const char* filename = NULL;
+ bool wroteStartSO = false;
+ state.stabs.reserve(atomsNeedingDebugNotes.size()*4);
+- std::unordered_set<const char*, CStringHash, CStringEquals> seenFiles;
++ std::UNORDERED_SET<const char*, CStringHash, CStringEquals> seenFiles;
+ for (std::vector<const ld::Atom*>::iterator it=atomsNeedingDebugNotes.begin(); it != atomsNeedingDebugNotes.end(); it++) {
+ const ld::Atom* atom = *it;
+ const ld::File* atomFile = atom->file();
+--- ./ld64-241.9/src/ld/parsers/archive_file.cpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/parsers/archive_file.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -33,7 +33,13 @@
+ #include <set>
+ #include <map>
+ #include <algorithm>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+
+ #include "MachOFileAbstraction.hpp"
+ #include "Architectures.hpp"
+@@ -112,7 +118,7 @@
+ struct MemberState { ld::relocatable::File* file; const Entry *entry; bool logged; bool loaded; uint32_t index;};
+ bool loadMember(MemberState& state, ld::File::AtomHandler& handler, const char *format, ...) const;
+
+- typedef std::unordered_map<const char*, const struct ranlib*, ld::CStringHash, ld::CStringEquals> NameToEntryMap;
++ typedef std::UNORDERED_MAP<const char*, const struct ranlib*, ld::CStringHash, ld::CStringEquals> NameToEntryMap;
+
+ typedef typename A::P P;
+ typedef typename A::P::E E;
+--- ./ld64-241.9/src/ld/parsers/lto_file.cpp.gcc 2014-11-04 00:59:51.000000000 +0100
++++ ./ld64-241.9/src/ld/parsers/lto_file.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -33,8 +33,17 @@
+ #include <pthread.h>
+ #include <mach-o/dyld.h>
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "MachOFileAbstraction.hpp"
+ #include "Architectures.hpp"
+@@ -218,8 +227,8 @@
+ static void ltoDiagnosticHandler(lto_codegen_diagnostic_severity_t, const char*, void*);
+ #endif
+
+- typedef std::unordered_set<const char*, ld::CStringHash, ld::CStringEquals> CStringSet;
+- typedef std::unordered_map<const char*, Atom*, ld::CStringHash, ld::CStringEquals> CStringToAtom;
++ typedef std::UNORDERED_SET<const char*, ld::CStringHash, ld::CStringEquals> CStringSet;
++ typedef std::UNORDERED_MAP<const char*, Atom*, ld::CStringHash, ld::CStringEquals> CStringToAtom;
+
+ class AtomSyncer : public ld::File::AtomHandler {
+ public:
+--- ./ld64-241.9/src/ld/parsers/macho_dylib_file.cpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/parsers/macho_dylib_file.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -34,8 +34,17 @@
+ #include <vector>
+ #include <set>
+ #include <algorithm>
+-#include <unordered_map>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "Architectures.hpp"
+ #include "MachOFileAbstraction.hpp"
+@@ -193,8 +202,8 @@
+ };
+ };
+ struct AtomAndWeak { ld::Atom* atom; bool weakDef; bool tlv; pint_t address; };
+- typedef std::unordered_map<const char*, AtomAndWeak, ld::CStringHash, ld::CStringEquals> NameToAtomMap;
+- typedef std::unordered_set<const char*, CStringHash, ld::CStringEquals> NameSet;
++ typedef std::UNORDERED_MAP<const char*, AtomAndWeak, ld::CStringHash, ld::CStringEquals> NameToAtomMap;
++ typedef std::UNORDERED_SET<const char*, CStringHash, ld::CStringEquals> NameSet;
+
+ struct Dependent { const char* path; File<A>* dylib; bool reExport; };
+
+@@ -562,14 +571,18 @@
+ if ( _s_logHashtable ) fprintf(stderr, "ld: building hashtable of %u toc entries for %s\n", dynamicInfo->nextdefsym(), this->path());
+ const macho_nlist<P>* start = &symbolTable[dynamicInfo->iextdefsym()];
+ const macho_nlist<P>* end = &start[dynamicInfo->nextdefsym()];
++#ifndef __GLIBCXX__
+ _atoms.reserve(dynamicInfo->nextdefsym()); // set initial bucket count
++#endif
+ for (const macho_nlist<P>* sym=start; sym < end; ++sym) {
+ this->addSymbol(&strings[sym->n_strx()], (sym->n_desc() & N_WEAK_DEF) != 0, false, sym->n_value());
+ }
+ }
+ else {
+ int32_t count = dynamicInfo->ntoc();
++#ifndef __GLIBCXX__
+ _atoms.reserve(count); // set initial bucket count
++#endif
+ if ( _s_logHashtable ) fprintf(stderr, "ld: building hashtable of %u entries for %s\n", count, this->path());
+ const struct dylib_table_of_contents* toc = (dylib_table_of_contents*)(fileContent + dynamicInfo->tocoff());
+ for (int32_t i = 0; i < count; ++i) {
+--- ./ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp.gcc 2014-11-04 00:57:10.000000000 +0100
++++ ./ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp 2015-01-12 22:22:53.000000000 +0100
+@@ -62,7 +62,7 @@
+ // forward reference
+ template <typename A> class Parser;
+ template <typename A> class Atom;
+-template <typename A> class Section;
++template <typename A> class MRFSection;
+ template <typename A> class CFISection;
+ template <typename A> class CUSection;
+
+@@ -102,14 +102,14 @@
+ const uint8_t* fileContent() { return _fileContent; }
+ private:
+ friend class Atom<A>;
+- friend class Section<A>;
++ friend class MRFSection<A>;
+ friend class Parser<A>;
+ friend class CFISection<A>::OAS;
+
+ typedef typename A::P P;
+
+ const uint8_t* _fileContent;
+- Section<A>** _sectionsArray;
++ MRFSection<A>** _sectionsArray;
+ uint8_t* _atomsArray;
+ uint8_t* _aliasAtomsArray;
+ uint32_t _sectionsArrayCount;
+@@ -134,14 +134,14 @@
+
+
+ template <typename A>
+-class Section : public ld::Section
++class MRFSection : public ld::Section
+ {
+ public:
+ typedef typename A::P::uint_t pint_t;
+ typedef typename A::P P;
+ typedef typename A::P::E E;
+
+- virtual ~Section() { }
++ virtual ~MRFSection() { }
+ class File<A>& file() const { return _file; }
+ const macho_section<P>* machoSection() const { return _machOSection; }
+ uint32_t sectionNum(class Parser<A>&) const;
+@@ -165,10 +165,10 @@
+ static const char* makeSectionName(const macho_section<typename A::P>* s);
+
+ protected:
+- Section(File<A>& f, const macho_section<typename A::P>* s)
++ MRFSection(File<A>& f, const macho_section<typename A::P>* s)
+ : ld::Section(makeSegmentName(s), makeSectionName(s), sectionType(s)),
+ _file(f), _machOSection(s), _beginAtoms(NULL), _endAtoms(NULL), _hasAliases(false) { }
+- Section(File<A>& f, const char* segName, const char* sectName, ld::Section::Type t, bool hidden=false)
++ MRFSection(File<A>& f, const char* segName, const char* sectName, ld::Section::Type t, bool hidden=false)
+ : ld::Section(segName, sectName, t, hidden), _file(f), _machOSection(NULL),
+ _beginAtoms(NULL), _endAtoms(NULL), _hasAliases(false) { }
+
+@@ -192,11 +192,11 @@
+
+
+ template <typename A>
+-class CFISection : public Section<A>
++class CFISection : public MRFSection<A>
+ {
+ public:
+ CFISection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s)
+- : Section<A>(f, s) { }
++ : MRFSection<A>(f, s) { }
+ uint32_t cfiCount(Parser<A>& parser);
+
+ virtual ld::Atom::ContentType contentType() { return ld::Atom::typeCFI; }
+@@ -256,11 +256,11 @@
+
+
+ template <typename A>
+-class CUSection : public Section<A>
++class CUSection : public MRFSection<A>
+ {
+ public:
+ CUSection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s)
+- : Section<A>(f, s) { }
++ : MRFSection<A>(f, s) { }
+
+ typedef typename A::P::uint_t pint_t;
+ typedef typename A::P P;
+@@ -297,11 +297,11 @@
+
+
+ template <typename A>
+-class TentativeDefinitionSection : public Section<A>
++class TentativeDefinitionSection : public MRFSection<A>
+ {
+ public:
+ TentativeDefinitionSection(Parser<A>& parser, File<A>& f)
+- : Section<A>(f, "__DATA", "__comm/tent", ld::Section::typeTentativeDefs) {}
++ : MRFSection<A>(f, "__DATA", "__comm/tent", ld::Section::typeTentativeDefs) {}
+
+ virtual ld::Atom::ContentType contentType() { return ld::Atom::typeZeroFill; }
+ virtual bool addFollowOnFixups() const { return false; }
+@@ -319,11 +319,11 @@
+
+
+ template <typename A>
+-class AbsoluteSymbolSection : public Section<A>
++class AbsoluteSymbolSection : public MRFSection<A>
+ {
+ public:
+ AbsoluteSymbolSection(Parser<A>& parser, File<A>& f)
+- : Section<A>(f, "__DATA", "__abs", ld::Section::typeAbsoluteSymbols, true) {}
++ : MRFSection<A>(f, "__DATA", "__abs", ld::Section::typeAbsoluteSymbols, true) {}
+
+ virtual ld::Atom::ContentType contentType() { return ld::Atom::typeUnclassified; }
+ virtual bool dontDeadStrip() { return false; }
+@@ -345,7 +345,7 @@
+
+
+ template <typename A>
+-class SymboledSection : public Section<A>
++class SymboledSection : public MRFSection<A>
+ {
+ public:
+ SymboledSection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s);
+@@ -377,11 +377,11 @@
+
+
+ template <typename A>
+-class ImplicitSizeSection : public Section<A>
++class ImplicitSizeSection : public MRFSection<A>
+ {
+ public:
+ ImplicitSizeSection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s)
+- : Section<A>(f, s) { }
++ : MRFSection<A>(f, s) { }
+ virtual uint32_t computeAtomCount(class Parser<A>& parser, struct Parser<A>::LabelAndCFIBreakIterator& it, const struct Parser<A>::CFI_CU_InfoArrays&);
+ virtual uint32_t appendAtoms(class Parser<A>& parser, uint8_t* buffer, struct Parser<A>::LabelAndCFIBreakIterator& it, const struct Parser<A>::CFI_CU_InfoArrays&);
+ protected:
+@@ -715,8 +715,8 @@
+
+ public:
+ // methods for all atoms from mach-o object file
+- Section<A>& sect() const { return (Section<A>&)section(); }
+- File<A>& machofile() const { return ((Section<A>*)(this->_section))->file(); }
++ MRFSection<A>& sect() const { return (MRFSection<A>&)section(); }
++ File<A>& machofile() const { return ((MRFSection<A>*)(this->_section))->file(); }
+ void setFixupsRange(uint32_t s, uint32_t c);
+ void setUnwindInfoRange(uint32_t s, uint32_t c);
+ void extendUnwindInfoRange();
+@@ -733,7 +733,7 @@
+ typedef typename A::P::E E;
+ typedef typename A::P::uint_t pint_t;
+ // constuct via all attributes
+- Atom(Section<A>& sct, const char* nm, pint_t addr, uint64_t sz,
++ Atom(MRFSection<A>& sct, const char* nm, pint_t addr, uint64_t sz,
+ ld::Atom::Definition d, ld::Atom::Combine c, ld::Atom::Scope s,
+ ld::Atom::ContentType ct, ld::Atom::SymbolTableInclusion i,
+ bool dds, bool thumb, bool al, ld::Atom::Alignment a)
+@@ -743,7 +743,7 @@
+ _unwindInfoStartIndex(0), _fixupsCount(0),
+ _lineInfoCount(0), _unwindInfoCount(0) { }
+ // construct via symbol table entry
+- Atom(Section<A>& sct, Parser<A>& parser, const macho_nlist<P>& sym,
++ Atom(MRFSection<A>& sct, Parser<A>& parser, const macho_nlist<P>& sym,
+ uint64_t sz, bool alias=false)
+ : ld::Atom((ld::Section&)sct, parser.definitionFromSymbol(sym),
+ parser.combineFromSymbol(sym), parser.scopeFromSymbol(sym),
+@@ -766,7 +766,7 @@
+
+ private:
+ friend class Parser<A>;
+- friend class Section<A>;
++ friend class MRFSection<A>;
+ friend class CStringSection<A>;
+ friend class AbsoluteSymbolSection<A>;
+
+@@ -1031,8 +1031,8 @@
+ uint32_t undefinedStartIndex() { return _undefinedStartIndex; }
+ uint32_t undefinedEndIndex() { return _undefinedEndIndex; }
+ void addFixup(FixupInAtom f) { _allFixups.push_back(f); }
+- Section<A>* sectionForNum(unsigned int sectNum);
+- Section<A>* sectionForAddress(pint_t addr);
++ MRFSection<A>* sectionForNum(unsigned int sectNum);
++ MRFSection<A>* sectionForAddress(pint_t addr);
+ Atom<A>* findAtomByAddress(pint_t addr);
+ Atom<A>* findAtomByAddressOrNullIfStub(pint_t addr);
+ Atom<A>* findAtomByAddressOrLocalTargetOfStub(pint_t addr, uint32_t* offsetInAtom);
+@@ -1074,7 +1074,7 @@
+ : sortedSymbolIndexes(ssa), sortedSymbolCount(ssc), cfiStartsArray(cfisa),
+ cfiStartsCount(cfisc), fileHasOverlappingSymbols(ols),
+ newSection(false), cfiIndex(0), symIndex(0) {}
+- bool next(Parser<A>& parser, const Section<A>& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr,
++ bool next(Parser<A>& parser, const MRFSection<A>& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr,
+ pint_t* addr, pint_t* size, const macho_nlist<P>** sym);
+ pint_t peek(Parser<A>& parser, pint_t startAddr, pint_t endAddr);
+ void beginSection() { newSection = true; symIndex = 0; }
+@@ -1103,7 +1103,7 @@
+
+
+ private:
+- friend class Section<A>;
++ friend class MRFSection<A>;
+
+ enum SectionType { sectionTypeIgnore, sectionTypeLiteral4, sectionTypeLiteral8, sectionTypeLiteral16,
+ sectionTypeNonLazy, sectionTypeCFI, sectionTypeCString, sectionTypeCStringPointer,
+@@ -1448,7 +1448,7 @@
+ // was becuase of a label, the symbol). Returns false when no more chunks.
+ //
+ template <typename A>
+-bool Parser<A>::LabelAndCFIBreakIterator::next(Parser<A>& parser, const Section<A>& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr,
++bool Parser<A>::LabelAndCFIBreakIterator::next(Parser<A>& parser, const MRFSection<A>& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr,
+ pint_t* addr, pint_t* size, const macho_nlist<P>** symbol)
+ {
+ // may not be a label on start of section, but need atom demarcation there
+@@ -1600,7 +1600,7 @@
+ }
+
+ template <>
+-typename arm::P::uint_t Parser<arm>::realAddr(typename arm::P::uint_t addr)
++arm::P::uint_t Parser<arm>::realAddr(arm::P::uint_t addr)
+ {
+ return addr & (-2);
+ }
+@@ -1646,7 +1646,7 @@
+ uint32_t sortedSymbolIndexes[_symbolsInSections];
+ this->makeSortedSymbolsArray(sortedSymbolIndexes, sortedSectionIndexes);
+
+- // allocate Section<A> object for each mach-o section
++ // allocate MRFSection<A> object for each mach-o section
+ makeSections();
+
+ // if it exists, do special early parsing of __compact_unwind section
+@@ -1743,7 +1743,7 @@
+ #endif
+ }
+
+- Section<A>** sections = _file->_sectionsArray;
++ MRFSection<A>** sections = _file->_sectionsArray;
+ uint32_t sectionsCount = _file->_sectionsArrayCount;
+
+ // figure out how many atoms will be allocated and allocate
+@@ -2306,11 +2306,11 @@
+ _file->_swiftVersion = ((flags >> 8) & 0xFF);
+ if ( sect->size() > 8 ) {
+ warning("section %s/%s has unexpectedly large size %llu in %s",
+- sect->segname(), Section<A>::makeSectionName(sect), sect->size(), _file->path());
++ sect->segname(), MRFSection<A>::makeSectionName(sect), sect->size(), _file->path());
+ }
+ }
+ else {
+- warning("can't parse %s/%s section in %s", sect->segname(), Section<A>::makeSectionName(sect), _file->path());
++ warning("can't parse %s/%s section in %s", sect->segname(), MRFSection<A>::makeSectionName(sect), _file->path());
+ }
+ continue;
+ }
+@@ -2406,24 +2406,24 @@
+ // sort by address (mach-o object files don't aways have sections sorted)
+ ::qsort(machOSects, count, sizeof(MachOSectionAndSectionClass<P>), MachOSectionAndSectionClass<P>::sorter);
+
+- // we will synthesize a dummy Section<A> object for tentative definitions
++ // we will synthesize a dummy MRFSection<A> object for tentative definitions
+ if ( _tentativeDefinitionCount > 0 ) {
+ totalSectionsSize += sizeof(TentativeDefinitionSection<A>);
+ machOSects[count++].type = sectionTypeTentativeDefinitions;
+ }
+
+- // we will synthesize a dummy Section<A> object for Absolute symbols
++ // we will synthesize a dummy MRFSection<A> object for Absolute symbols
+ if ( _absoluteSymbolCount > 0 ) {
+ totalSectionsSize += sizeof(AbsoluteSymbolSection<A>);
+ machOSects[count++].type = sectionTypeAbsoluteSymbols;
+ }
+
+ // allocate one block for all Section objects as well as pointers to each
+- uint8_t* space = new uint8_t[totalSectionsSize+count*sizeof(Section<A>*)];
+- _file->_sectionsArray = (Section<A>**)space;
++ uint8_t* space = new uint8_t[totalSectionsSize+count*sizeof(MRFSection<A>*)];
++ _file->_sectionsArray = (MRFSection<A>**)space;
+ _file->_sectionsArrayCount = count;
+- Section<A>** objects = _file->_sectionsArray;
+- space += count*sizeof(Section<A>*);
++ MRFSection<A>** objects = _file->_sectionsArray;
++ space += count*sizeof(MRFSection<A>*);
+ for (uint32_t i=0; i < count; ++i) {
+ switch ( machOSects[i].type ) {
+ case sectionTypeIgnore:
+@@ -2511,7 +2511,7 @@
+
+
+ template <typename A>
+-Section<A>* Parser<A>::sectionForAddress(typename A::P::uint_t addr)
++MRFSection<A>* Parser<A>::sectionForAddress(typename A::P::uint_t addr)
+ {
+ for (uint32_t i=0; i < _file->_sectionsArrayCount; ++i ) {
+ const macho_section<typename A::P>* sect = _file->_sectionsArray[i]->machoSection();
+@@ -2538,7 +2538,7 @@
+ }
+
+ template <typename A>
+-Section<A>* Parser<A>::sectionForNum(unsigned int num)
++MRFSection<A>* Parser<A>::sectionForNum(unsigned int num)
+ {
+ for (uint32_t i=0; i < _file->_sectionsArrayCount; ++i ) {
+ const macho_section<typename A::P>* sect = _file->_sectionsArray[i]->machoSection();
+@@ -2554,7 +2554,7 @@
+ template <typename A>
+ Atom<A>* Parser<A>::findAtomByAddress(pint_t addr)
+ {
+- Section<A>* section = this->sectionForAddress(addr);
++ MRFSection<A>* section = this->sectionForAddress(addr);
+ return section->findAtomByAddress(addr);
+ }
+
+@@ -2611,7 +2611,7 @@
+ target.addend = 0;
+ return;
+ }
+- Section<A>* section = this->sectionForAddress(addr);
++ MRFSection<A>* section = this->sectionForAddress(addr);
+ target.atom = section->findAtomByAddress(addr);
+ target.addend = addr - target.atom->_objAddress;
+ target.weakImport = false;
+@@ -2659,7 +2659,7 @@
+ }
+ return;
+ }
+- Section<A>* section = this->sectionForNum(sectNum);
++ MRFSection<A>* section = this->sectionForNum(sectNum);
+ target.atom = section->findAtomByAddress(addr);
+ if ( target.atom == NULL ) {
+ typedef typename A::P::sint_t sint_t;
+@@ -3867,7 +3867,7 @@
+ }
+
+ template <typename A>
+-const char* Section<A>::makeSegmentName(const macho_section<typename A::P>* sect)
++const char* MRFSection<A>::makeSegmentName(const macho_section<typename A::P>* sect)
+ {
+ // mach-o section record only has room for 16-byte seg/sect names
+ // so a 16-byte name has no trailing zero
+@@ -3880,7 +3880,7 @@
+ }
+
+ template <typename A>
+-const char* Section<A>::makeSectionName(const macho_section<typename A::P>* sect)
++const char* MRFSection<A>::makeSectionName(const macho_section<typename A::P>* sect)
+ {
+ const char* name = sect->sectname();
+ if ( strlen(name) < 16 )
+@@ -3914,13 +3914,13 @@
+ }
+
+ template <typename A>
+-bool Section<A>::readable(const macho_section<typename A::P>* sect)
++bool MRFSection<A>::readable(const macho_section<typename A::P>* sect)
+ {
+ return true;
+ }
+
+ template <typename A>
+-bool Section<A>::writable(const macho_section<typename A::P>* sect)
++bool MRFSection<A>::writable(const macho_section<typename A::P>* sect)
+ {
+ // mach-o .o files do not contain segment permissions
+ // we just know TEXT is special
+@@ -3928,7 +3928,7 @@
+ }
+
+ template <typename A>
+-bool Section<A>::exectuable(const macho_section<typename A::P>* sect)
++bool MRFSection<A>::exectuable(const macho_section<typename A::P>* sect)
+ {
+ // mach-o .o files do not contain segment permissions
+ // we just know TEXT is special
+@@ -3937,7 +3937,7 @@
+
+
+ template <typename A>
+-ld::Section::Type Section<A>::sectionType(const macho_section<typename A::P>* sect)
++ld::Section::Type MRFSection<A>::sectionType(const macho_section<typename A::P>* sect)
+ {
+ switch ( sect->flags() & SECTION_TYPE ) {
+ case S_ZEROFILL:
+@@ -4015,7 +4015,7 @@
+
+
+ template <typename A>
+-Atom<A>* Section<A>::findContentAtomByAddress(pint_t addr, class Atom<A>* start, class Atom<A>* end)
++Atom<A>* MRFSection<A>::findContentAtomByAddress(pint_t addr, class Atom<A>* start, class Atom<A>* end)
+ {
+ // do a binary search of atom array
+ uint32_t atomCount = end - start;
+@@ -4047,7 +4047,7 @@
+ }
+
+ template <typename A>
+-ld::Atom::Alignment Section<A>::alignmentForAddress(pint_t addr)
++ld::Atom::Alignment MRFSection<A>::alignmentForAddress(pint_t addr)
+ {
+ const uint32_t sectionAlignment = this->_machOSection->align();
+ uint32_t modulus = (addr % (1 << sectionAlignment));
+@@ -4057,7 +4057,7 @@
+ }
+
+ template <typename A>
+-uint32_t Section<A>::sectionNum(class Parser<A>& parser) const
++uint32_t MRFSection<A>::sectionNum(class Parser<A>& parser) const
+ {
+ if ( _machOSection == NULL )
+ return 0;
+@@ -4650,7 +4650,7 @@
+ // support __LD, __compact_unwind personality entries which are pointer to personality non-lazy pointer
+ const pint_t* content = (pint_t*)(this->file().fileContent() + this->_machOSection->offset() + reloc->r_address());
+ pint_t nlPointerAddr = *content;
+- Section<x86>* nlSection = parser.sectionForAddress(nlPointerAddr);
++ MRFSection<x86>* nlSection = parser.sectionForAddress(nlPointerAddr);
+ if ( nlSection->type() == ld::Section::typeCode ) {
+ // personality function is defined in this .o file, so this is a direct reference to it
+ // atoms may not be constructed yet, so scan symbol table for labels
+@@ -4677,7 +4677,7 @@
+ else {
+ const pint_t* content = (pint_t*)(this->file().fileContent() + this->_machOSection->offset() + reloc->r_address());
+ pint_t personalityAddr = *content;
+- Section<arm64>* personalitySection = parser.sectionForAddress(personalityAddr);
++ MRFSection<arm64>* personalitySection = parser.sectionForAddress(personalityAddr);
+ assert((personalitySection->type() == ld::Section::typeCode) && "personality column in __compact_unwind section is not pointer to function");
+ // atoms may not be constructed yet, so scan symbol table for labels
+ const char* name = parser.scanSymbolTableForAddress(personalityAddr);
+@@ -4831,7 +4831,7 @@
+
+ template <typename A>
+ SymboledSection<A>::SymboledSection(Parser<A>& parser, File<A>& f, const macho_section<typename A::P>* s)
+- : Section<A>(f, s), _type(ld::Atom::typeUnclassified)
++ : MRFSection<A>(f, s), _type(ld::Atom::typeUnclassified)
+ {
+ switch ( s->flags() & SECTION_TYPE ) {
+ case S_ZEROFILL:
+@@ -4877,7 +4877,7 @@
+ if ( ! this->_file.canScatterAtoms() )
+ return true;
+ // call inherited
+- return Section<A>::dontDeadStrip();
++ return MRFSection<A>::dontDeadStrip();
+ }
+ return false;
+ }
+@@ -5724,7 +5724,7 @@
+
+
+ template <>
+-uint32_t Section<x86_64>::x86_64PcRelOffset(uint8_t r_type)
++uint32_t MRFSection<x86_64>::x86_64PcRelOffset(uint8_t r_type)
+ {
+ switch ( r_type ) {
+ case X86_64_RELOC_SIGNED:
+@@ -5741,7 +5741,7 @@
+
+
+ template <>
+-bool Section<x86_64>::addRelocFixup(class Parser<x86_64>& parser, const macho_relocation_info<P>* reloc)
++bool MRFSection<x86_64>::addRelocFixup(class Parser<x86_64>& parser, const macho_relocation_info<P>* reloc)
+ {
+ const macho_section<P>* sect = this->machoSection();
+ uint64_t srcAddr = sect->addr() + reloc->r_address();
+@@ -5948,7 +5948,7 @@
+
+
+ template <>
+-bool Section<x86>::addRelocFixup(class Parser<x86>& parser, const macho_relocation_info<P>* reloc)
++bool MRFSection<x86>::addRelocFixup(class Parser<x86>& parser, const macho_relocation_info<P>* reloc)
+ {
+ const macho_section<P>* sect = this->machoSection();
+ uint32_t srcAddr;
+@@ -6189,7 +6189,7 @@
+
+ #if SUPPORT_ARCH_arm_any
+ template <>
+-bool Section<arm>::addRelocFixup(class Parser<arm>& parser, const macho_relocation_info<P>* reloc)
++bool MRFSection<arm>::addRelocFixup(class Parser<arm>& parser, const macho_relocation_info<P>* reloc)
+ {
+ const macho_section<P>* sect = this->machoSection();
+ bool result = false;
+@@ -6656,7 +6656,7 @@
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+-bool Section<arm64>::addRelocFixup(class Parser<arm64>& parser, const macho_relocation_info<P>* reloc)
++bool MRFSection<arm64>::addRelocFixup(class Parser<arm64>& parser, const macho_relocation_info<P>* reloc)
+ {
+ bool result = false;
+ Parser<arm64>::SourceLocation src;
+@@ -7054,7 +7054,7 @@
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+-void Section<arm64>::addLOH(class Parser<arm64>& parser, int kind, int count, const uint64_t addrs[]) {
++void MRFSection<arm64>::addLOH(class Parser<arm64>& parser, int kind, int count, const uint64_t addrs[]) {
+ switch (kind) {
+ case LOH_ARM64_ADRP_ADRP:
+ case LOH_ARM64_ADRP_LDR:
+@@ -7109,18 +7109,18 @@
+ extra.info.delta2 = (count > 1) ? ((addrs[1] - lowestAddress) >> 2) : 0;
+ extra.info.delta3 = (count > 2) ? ((addrs[2] - lowestAddress) >> 2) : 0;
+ extra.info.delta4 = (count > 3) ? ((addrs[3] - lowestAddress) >> 2) : 0;
+- typename Parser<arm64>::SourceLocation src(inAtom, lowestAddress- inAtom->objectAddress());
++ Parser<arm64>::SourceLocation src(inAtom, lowestAddress- inAtom->objectAddress());
+ parser.addFixup(src, ld::Fixup::k1of1, ld::Fixup::kindLinkerOptimizationHint, extra.addend);
+ }
+ #endif
+
+ template <typename A>
+-void Section<A>::addLOH(class Parser<A>& parser, int kind, int count, const uint64_t addrs[]) {
++void MRFSection<A>::addLOH(class Parser<A>& parser, int kind, int count, const uint64_t addrs[]) {
+
+ }
+
+ template <typename A>
+-void Section<A>::makeFixups(class Parser<A>& parser, const struct Parser<A>::CFI_CU_InfoArrays&)
++void MRFSection<A>::makeFixups(class Parser<A>& parser, const struct Parser<A>::CFI_CU_InfoArrays&)
+ {
+ const macho_section<P>* sect = this->machoSection();
+ const macho_relocation_info<P>* relocs = (macho_relocation_info<P>*)(file().fileContent() + sect->reloff());
+@@ -7131,7 +7131,7 @@
+ ++r; // skip next
+ }
+ catch (const char* msg) {
+- throwf("in section %s,%s reloc %u: %s", sect->segname(), Section<A>::makeSectionName(sect), r, msg);
++ throwf("in section %s,%s reloc %u: %s", sect->segname(), MRFSection<A>::makeSectionName(sect), r, msg);
+ }
+ }
+
+@@ -7157,7 +7157,7 @@
+ }
+ if ( !this->_altEntries.empty() && !this->addFollowOnFixups() ) {
+ if ( _altEntries.count(_beginAtoms) != 0 )
+- warning("N_ALT_ENTRY bit set on first atom in section %s/%s", sect->segname(), Section<A>::makeSectionName(sect));
++ warning("N_ALT_ENTRY bit set on first atom in section %s/%s", sect->segname(), MRFSection<A>::makeSectionName(sect));
+
+ Atom<A>* end = &_endAtoms[-1];
+ for(Atom<A>* p = _beginAtoms; p < end; ++p) {
+--- ./ld64-241.9/src/ld/passes/dtrace_dof.cpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/passes/dtrace_dof.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -30,8 +30,17 @@
+
+ #include <vector>
+ #include <map>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#include <tr1/unordered_set>
++#define UNORDERED_MAP tr1::unordered_map
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_map>
+ #include <unordered_set>
++#define UNORDERED_MAP unordered_map
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "ld.hpp"
+ #include "MachOFileAbstraction.hpp"
+@@ -111,8 +120,8 @@
+ uint32_t offset;
+ const char* probeName;
+ };
+-typedef std::unordered_map<const char*, std::vector<DTraceProbeInfo>, CStringHash, CStringEquals> ProviderToProbes;
+-typedef std::unordered_set<const char*, CStringHash, CStringEquals> CStringSet;
++typedef std::UNORDERED_MAP<const char*, std::vector<DTraceProbeInfo>, CStringHash, CStringEquals> ProviderToProbes;
++typedef std::UNORDERED_SET<const char*, CStringHash, CStringEquals> CStringSet;
+
+
+
+--- ./ld64-241.9/src/ld/passes/order.cpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/passes/order.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -32,7 +32,13 @@
+ #include <vector>
+ #include <map>
+ #include <set>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+
+ #include "ld.hpp"
+ #include "order.h"
+@@ -85,7 +91,7 @@
+ ld::Internal& _state;
+ };
+
+- typedef std::unordered_map<const char*, const ld::Atom*, CStringHash, CStringEquals> NameToAtom;
++ typedef std::UNORDERED_MAP<const char*, const ld::Atom*, CStringHash, CStringEquals> NameToAtom;
+
+ typedef std::map<const ld::Atom*, const ld::Atom*> AtomToAtom;
+
+--- ./ld64-241.9/src/ld/Resolver.h.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/Resolver.h 2015-01-12 22:12:18.000000000 +0100
+@@ -42,7 +42,13 @@
+ #include <mach-o/dyld.h>
+
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "Options.h"
+ #include "ld.hpp"
+@@ -105,7 +111,7 @@
+ void doLinkerOption(const std::vector<const char*>& linkerOption, const char* fileName);
+ void dumpAtoms();
+
+- typedef std::unordered_set<const char*, CStringHash, CStringEquals> StringSet;
++ typedef std::UNORDERED_SET<const char*, CStringHash, CStringEquals> StringSet;
+
+ class NotLive {
+ public:
+--- ./ld64-241.9/src/ld/SymbolTable.h.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/ld/SymbolTable.h 2015-01-12 22:12:18.000000000 +0100
+@@ -42,7 +42,13 @@
+ #include <mach-o/dyld.h>
+
+ #include <vector>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_map>
++#define UNORDERED_MAP tr1::unordered_map
++#else
+ #include <unordered_map>
++#define UNORDERED_MAP unordered_map
++#endif
+
+ #include "Options.h"
+ #include "ld.hpp"
+@@ -57,38 +63,38 @@
+ typedef uint32_t IndirectBindingSlot;
+
+ private:
+- typedef std::unordered_map<const char*, IndirectBindingSlot, CStringHash, CStringEquals> NameToSlot;
++ typedef std::UNORDERED_MAP<const char*, IndirectBindingSlot, CStringHash, CStringEquals> NameToSlot;
+
+ class ContentFuncs {
+ public:
+ size_t operator()(const ld::Atom*) const;
+ bool operator()(const ld::Atom* left, const ld::Atom* right) const;
+ };
+- typedef std::unordered_map<const ld::Atom*, IndirectBindingSlot, ContentFuncs, ContentFuncs> ContentToSlot;
++ typedef std::UNORDERED_MAP<const ld::Atom*, IndirectBindingSlot, ContentFuncs, ContentFuncs> ContentToSlot;
+
+ class ReferencesHashFuncs {
+ public:
+ size_t operator()(const ld::Atom*) const;
+ bool operator()(const ld::Atom* left, const ld::Atom* right) const;
+ };
+- typedef std::unordered_map<const ld::Atom*, IndirectBindingSlot, ReferencesHashFuncs, ReferencesHashFuncs> ReferencesToSlot;
++ typedef std::UNORDERED_MAP<const ld::Atom*, IndirectBindingSlot, ReferencesHashFuncs, ReferencesHashFuncs> ReferencesToSlot;
+
+ class CStringHashFuncs {
+ public:
+ size_t operator()(const ld::Atom*) const;
+ bool operator()(const ld::Atom* left, const ld::Atom* right) const;
+ };
+- typedef std::unordered_map<const ld::Atom*, IndirectBindingSlot, CStringHashFuncs, CStringHashFuncs> CStringToSlot;
++ typedef std::UNORDERED_MAP<const ld::Atom*, IndirectBindingSlot, CStringHashFuncs, CStringHashFuncs> CStringToSlot;
+
+ class UTF16StringHashFuncs {
+ public:
+ size_t operator()(const ld::Atom*) const;
+ bool operator()(const ld::Atom* left, const ld::Atom* right) const;
+ };
+- typedef std::unordered_map<const ld::Atom*, IndirectBindingSlot, UTF16StringHashFuncs, UTF16StringHashFuncs> UTF16StringToSlot;
++ typedef std::UNORDERED_MAP<const ld::Atom*, IndirectBindingSlot, UTF16StringHashFuncs, UTF16StringHashFuncs> UTF16StringToSlot;
+
+ typedef std::map<IndirectBindingSlot, const char*> SlotToName;
+- typedef std::unordered_map<const char*, CStringToSlot*, CStringHash, CStringEquals> NameToMap;
++ typedef std::UNORDERED_MAP<const char*, CStringToSlot*, CStringHash, CStringEquals> NameToMap;
+
+ typedef std::vector<const ld::Atom *> DuplicatedSymbolAtomList;
+ typedef std::map<const char *, DuplicatedSymbolAtomList * > DuplicateSymbols;
+--- ./ld64-241.9/src/other/dyldinfo.cpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/other/dyldinfo.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -33,7 +33,6 @@
+
+ #include <vector>
+ #include <set>
+-#include <unordered_set>
+
+ #include "configure.h"
+ #include "MachOFileAbstraction.hpp"
+--- ./ld64-241.9/src/other/machochecker.cpp.gcc 2014-09-11 00:24:46.000000000 +0200
++++ ./ld64-241.9/src/other/machochecker.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -33,7 +33,13 @@
+
+ #include <vector>
+ #include <set>
++#ifdef __GLIBCXX__
++#include <tr1/unordered_set>
++#define UNORDERED_SET tr1::unordered_set
++#else
+ #include <unordered_set>
++#define UNORDERED_SET unordered_set
++#endif
+
+ #include "configure.h"
+
+@@ -124,7 +130,7 @@
+ bool operator()(const char* left, const char* right) const { return (strcmp(left, right) == 0); }
+ };
+
+- typedef std::unordered_set<const char*, CStringHash, CStringEquals> StringSet;
++ typedef std::UNORDERED_SET<const char*, CStringHash, CStringEquals> StringSet;
+
+ MachOChecker(const uint8_t* fileContent, uint32_t fileLength, const char* path);
+ void checkMachHeader();
+--- ./ld64-241.9/src/other/unwinddump.cpp.gcc 2014-11-04 00:56:18.000000000 +0100
++++ ./ld64-241.9/src/other/unwinddump.cpp 2015-01-12 22:12:18.000000000 +0100
+@@ -33,7 +33,6 @@
+
+ #include <vector>
+ #include <set>
+-#include <unordered_set>
+
+ #include "configure.h"
+ #include "MachOFileAbstraction.hpp"
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-get-comm-align.patch b/sys-devel/binutils-apple/files/ld64-241.9-get-comm-align.patch
new file mode 100644
index 000000000000..58579f007de7
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-get-comm-align.patch
@@ -0,0 +1,30 @@
+Provide macros [GS]ET_COMM_ALIGN if it's missing (<= 10.4).
+
+--- ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp 2015-01-22 22:23:11.000000000 +0100
++++ ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp 2015-01-22 22:28:03.000000000 +0100
+@@ -51,6 +51,10 @@
+ #include "macho_relocatable_file.h"
+
+
++/* missing on < 10.5 */
++#if !defined(GET_COMM_ALIGN)
++#define GET_COMM_ALIGN(n_desc) (((n_desc) >> 8) & 0x0f)
++#endif
+
+ extern void throwf(const char* format, ...) __attribute__ ((noreturn,format(printf, 1, 2)));
+ extern void warning(const char* format, ...) __attribute__((format(printf, 1, 2)));
+--- Gentoo/tmp/var/tmp/portage/sys-devel/binutils-apple-6.1/work/ld64-241.9/src/ld/LinkEditClassic.hpp 2015-01-22 22:29:14.000000000 +0100
++++ ld64-241.9/src/ld/LinkEditClassic.hpp 2015-01-22 22:31:23.000000000 +0100
+@@ -39,6 +39,12 @@
+ #define UNORDERED_MAP unordered_map
+ #endif
+
++#if !defined(SET_COMM_ALIGN)
++/* missing on < 10.5 */
++#define SET_COMM_ALIGN(n_desc,align) \
++ (n_desc) = (((n_desc) & 0xf0ff) | (((align) & 0x0f) << 8))
++#endif
++
+ #include "Options.h"
+ #include "ld.hpp"
+ #include "Architectures.hpp"
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-lto-noremarks.patch b/sys-devel/binutils-apple/files/ld64-241.9-lto-noremarks.patch
new file mode 100644
index 000000000000..d4667ab63b8c
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-lto-noremarks.patch
@@ -0,0 +1,107 @@
+Shut up ld64 by default when using LTO.
+
+diff -ru ld64-241.9.orig/src/ld/Options.cpp ld64-241.9/src/ld/Options.cpp
+--- ld64-241.9.orig/src/ld/Options.cpp 2015-02-02 22:14:29.000000000 +0100
++++ ld64-241.9/src/ld/Options.cpp 2015-02-02 22:15:41.000000000 +0100
+@@ -183,6 +183,9 @@
+ fDebugInfoStripping(kDebugInfoMinimal), fTraceOutputFile(NULL),
+ fMacVersionMin(ld::macVersionUnset), fIOSVersionMin(ld::iOSVersionUnset),
+ fSaveTempFiles(false),
++#ifdef LTO
++ fVerboseLTORemarks(false),
++#endif
+ #ifdef SUPPORT_SNAPSHOTS
+ fSnapshotRequested(false),
+ #endif
+@@ -3138,6 +3141,11 @@
+ else if ( strcmp(arg, "-ignore_optimization_hints") == 0 ) {
+ fIgnoreOptimizationHints = true;
+ }
++#ifdef LTO
++ else if ( strcmp(arg, "-verbose_lto_remarks") == 0 ) {
++ fVerboseLTORemarks = true;
++ }
++#endif
+ else if ( strcmp(arg, "-no_dtrace_dof") == 0 ) {
+ fGenerateDtraceDOF = false;
+ }
+Only in ld64-241.9/src/ld: Options.cpp~
+diff -ru ld64-241.9.orig/src/ld/Options.h ld64-241.9/src/ld/Options.h
+--- ld64-241.9.orig/src/ld/Options.h 2015-02-02 22:14:29.000000000 +0100
++++ ld64-241.9/src/ld/Options.h 2015-02-02 22:16:36.000000000 +0100
+@@ -381,6 +381,9 @@
+ bool forceWeakNonWildCard(const char* symbolName) const;
+ bool forceNotWeakNonWildcard(const char* symbolName) const;
+ bool forceCoalesce(const char* symbolName) const;
++#ifdef LTO
++ bool verboseLTORemarks() const { return fVerboseLTORemarks; }
++#endif
+ #ifdef SUPPORT_SNAPSHOTS
+ Snapshot& snapshot() const { return fLinkSnapshot; }
+ #endif
+@@ -681,6 +684,9 @@
+ std::vector<SymbolsMove> fSymbolsMovesCode;
+ std::vector<SymbolsMove> fSymbolsMovesZeroFill;
+ bool fSaveTempFiles;
++#ifdef LTO
++ bool fVerboseLTORemarks;
++#endif
+ #ifdef SUPPORT_SNAPSHOTS
+ mutable Snapshot fLinkSnapshot;
+ bool fSnapshotRequested;
+Only in ld64-241.9/src/ld: Options.h~
+diff -ru ld64-241.9.orig/src/ld/Resolver.cpp ld64-241.9/src/ld/Resolver.cpp
+--- ld64-241.9.orig/src/ld/Resolver.cpp 2015-02-02 22:14:29.000000000 +0100
++++ ld64-241.9/src/ld/Resolver.cpp 2015-02-02 22:17:16.000000000 +0100
+@@ -1559,6 +1559,7 @@
+ optOpt.mcpu = _options.mcpuLTO();
+ optOpt.llvmOptions = &_options.llvmOptions();
+ optOpt.initialUndefines = &_options.initialUndefines();
++ optOpt.verboseLTORemarks = _options.verboseLTORemarks();
+
+ std::vector<const ld::Atom*> newAtoms;
+ std::vector<const char*> additionalUndefines;
+Only in ld64-241.9/src/ld: Resolver.cpp~
+diff -ru ld64-241.9.orig/src/ld/parsers/lto_file.cpp ld64-241.9/src/ld/parsers/lto_file.cpp
+--- ld64-241.9.orig/src/ld/parsers/lto_file.cpp 2015-02-02 22:14:29.000000000 +0100
++++ ld64-241.9/src/ld/parsers/lto_file.cpp 2015-02-02 22:18:27.000000000 +0100
+@@ -489,13 +489,17 @@
+
+
+ #if LTO_API_VERSION >= 7
+-void Parser::ltoDiagnosticHandler(lto_codegen_diagnostic_severity_t severity, const char* message, void*)
++void Parser::ltoDiagnosticHandler(lto_codegen_diagnostic_severity_t severity, const char* message, void* data)
+ {
+ switch ( severity ) {
+ #if LTO_API_VERSION >= 10
+ case LTO_DS_REMARK:
++ {
++ const OptimizeOptions* options = (const OptimizeOptions*)data;
++ if (options->verboseLTORemarks)
+ fprintf(stderr, "ld: LTO remark: %s\n", message);
+ break;
++ }
+ #endif
+ case LTO_DS_NOTE:
+ case LTO_DS_WARNING:
+@@ -530,7 +533,7 @@
+ // create optimizer and add each Reader
+ lto_code_gen_t generator = ::lto_codegen_create();
+ #if LTO_API_VERSION >= 7
+- lto_codegen_set_diagnostic_handler(generator, ltoDiagnosticHandler, NULL);
++ lto_codegen_set_diagnostic_handler(generator, ltoDiagnosticHandler, (void*)&options);
+ #endif
+
+ // <rdar://problem/12379604> The order that files are merged must match command line order
+Only in ld64-241.9/src/ld/parsers: lto_file.cpp~
+diff -ru ld64-241.9.orig/src/ld/parsers/lto_file.h ld64-241.9/src/ld/parsers/lto_file.h
+--- ld64-241.9.orig/src/ld/parsers/lto_file.h 2015-02-02 22:14:29.000000000 +0100
++++ ld64-241.9/src/ld/parsers/lto_file.h 2015-02-02 22:18:57.000000000 +0100
+@@ -61,6 +61,7 @@
+ const char* mcpu;
+ const std::vector<const char*>* llvmOptions;
+ const std::vector<const char*>* initialUndefines;
++ bool verboseLTORemarks;
+ };
+
+ extern bool optimize( const std::vector<const ld::Atom*>& allAtoms,
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-noarm.patch b/sys-devel/binutils-apple/files/ld64-241.9-noarm.patch
new file mode 100644
index 000000000000..24d288467433
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-noarm.patch
@@ -0,0 +1,1288 @@
+Fully conditionalise arm support so it can be disabled on 10.4.
+
+diff -ur ld64-241.9/src/abstraction/MachOFileAbstraction.hpp ld64-241.9/src/abstraction/MachOFileAbstraction.hpp
+--- ld64-241.9/src/abstraction/MachOFileAbstraction.hpp 2014-11-04 00:30:51.000000000 +0100
++++ ld64-241.9/src/abstraction/MachOFileAbstraction.hpp 2015-01-22 05:53:13.000000000 +0100
+diff -ur ld64-241.9/src/ld/HeaderAndLoadCommands.hpp ld64-241.9/src/ld/HeaderAndLoadCommands.hpp
+--- ld64-241.9/src/ld/HeaderAndLoadCommands.hpp 2014-09-11 00:24:46.000000000 +0200
++++ ld64-241.9/src/ld/HeaderAndLoadCommands.hpp 2015-01-22 06:46:10.000000000 +0100
+@@ -607,8 +607,12 @@
+
+ template <> uint32_t HeaderAndLoadCommandsAtom<x86>::cpuType() const { return CPU_TYPE_I386; }
+ template <> uint32_t HeaderAndLoadCommandsAtom<x86_64>::cpuType() const { return CPU_TYPE_X86_64; }
++#if SUPPORT_ARCH_arm_any
+ template <> uint32_t HeaderAndLoadCommandsAtom<arm>::cpuType() const { return CPU_TYPE_ARM; }
++#endif
++#if SUPPORT_ARCH_arm64
+ template <> uint32_t HeaderAndLoadCommandsAtom<arm64>::cpuType() const { return CPU_TYPE_ARM64; }
++#endif
+
+
+
+@@ -627,17 +631,21 @@
+ return _state.cpuSubType;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ uint32_t HeaderAndLoadCommandsAtom<arm>::cpuSubType() const
+ {
+ return _state.cpuSubType;
+ }
++#endif
+
++#if SUPPORT_ARCH_arm64
+ template <>
+ uint32_t HeaderAndLoadCommandsAtom<arm64>::cpuSubType() const
+ {
+ return CPU_SUBTYPE_ARM64_ALL;
+ }
++#endif
+
+
+
+diff -ur ld64-241.9/src/ld/LinkEdit.hpp ld64-241.9/src/ld/LinkEdit.hpp
+--- ld64-241.9/src/ld/LinkEdit.hpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/ld/LinkEdit.hpp 2015-01-22 05:32:47.000000000 +0100
+@@ -1595,6 +1595,7 @@
+ for (ld::Fixup::iterator fit = atom->fixupsBegin(); fit != atom->fixupsEnd(); ++fit) {
+ if ( fit->kind != ld::Fixup::kindLinkerOptimizationHint)
+ continue;
++#if SUPPORT_ARCH_arm64
+ ld::Fixup::LOH_arm64 extra;
+ extra.addend = fit->u.addend;
+ _encodedData.append_uleb128(extra.info.kind);
+@@ -1606,6 +1607,7 @@
+ _encodedData.append_uleb128((extra.info.delta3 << 2) + fit->offsetInAtom + address);
+ if ( extra.info.count > 2 )
+ _encodedData.append_uleb128((extra.info.delta4 << 2) + fit->offsetInAtom + address);
++#endif
+ }
+ }
+ }
+diff -ur ld64-241.9/src/ld/Options.cpp ld64-241.9/src/ld/Options.cpp
+--- ld64-241.9/src/ld/Options.cpp 2015-01-22 20:59:48.000000000 +0100
++++ ld64-241.9/src/ld/Options.cpp 2015-01-22 20:52:17.000000000 +0100
+@@ -580,8 +580,13 @@
+ #endif
+ }
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
++#if SUPPORT_ARCH_arm_any || SUPPORT_ARCH_arm64
+ if ( (fMacVersionMin == ld::macVersionUnset) && (fIOSVersionMin == ld::iOSVersionUnset) && (fOutputKind != Options::kObjectFile) ) {
+ #if defined(DEFAULT_IPHONEOS_MIN_VERSION)
+ warning("-ios_version_min not specified, assuming " DEFAULT_IPHONEOS_MIN_VERSION);
+@@ -592,6 +597,7 @@
+ #endif
+ }
+ break;
++#endif
+ }
+ #ifdef SUPPORT_SNAPSHOTS
+ fLinkSnapshot.recordArch(fArchitectureName);
+@@ -1683,9 +1689,11 @@
+ symbolStart = NULL;
+ }
+ else if ( strncmp(symbolStart, "arm:", 4) == 0 ) {
++#if SUPPORT_ARCH_arm_any
+ if ( fArchitecture == CPU_TYPE_ARM )
+ symbolStart = &symbolStart[4];
+ else
++#endif
+ symbolStart = NULL;
+ }
+ if ( symbolStart != NULL ) {
+@@ -3668,6 +3676,7 @@
+ #endif
+ }
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( (fOutputKind != Options::kObjectFile) && (fOutputKind != Options::kPreload) ) {
+ #if defined(DEFAULT_IPHONEOS_MIN_VERSION)
+@@ -3679,6 +3688,7 @@
+ #endif
+ }
+ break;
++#endif
+ default:
+ // architecture will be infered later by examining .o files
+ break;
+@@ -3701,12 +3711,14 @@
+ fMacVersionMin = ld::mac10_4;
+ }
+ break;
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
+ if ( fIOSVersionMin < ld::iOS_7_0 ) {
+ //warning("-mios_version_min should be 7.0 or later for arm64");
+ fIOSVersionMin = ld::iOS_7_0;
+ }
+ break;
++#endif
+ }
+
+ // default to adding functions start for dynamic code, static code must opt-in
+@@ -3746,6 +3758,7 @@
+ fAllowTextRelocs = true;
+ fUndefinedTreatment = kUndefinedDynamicLookup;
+ break;
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
+ // arm64 uses new MH_KEXT_BUNDLE type
+ fMakeCompressedDyldInfo = false;
+@@ -3754,6 +3767,8 @@
+ fKextsUseStubs = true;
+ fUndefinedTreatment = kUndefinedDynamicLookup;
+ break;
++#endif
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( fIOSVersionMin >= ld::iOS_5_0 ) {
+ // iOS 5.0 and later use new MH_KEXT_BUNDLE type
+@@ -3765,6 +3780,7 @@
+ fUndefinedTreatment = kUndefinedDynamicLookup;
+ break;
+ }
++#endif
+ // else use object file
+ case CPU_TYPE_I386:
+ // use .o files
+@@ -3817,6 +3833,7 @@
+ if ( fSplitSegs && (fBaseWritableAddress-fBaseAddress != 0x10000000) )
+ fBaseWritableAddress = fBaseAddress + 0x10000000;
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( fOutputKind != Options::kDynamicLibrary ) {
+ fSplitSegs = false;
+@@ -3827,6 +3844,7 @@
+ fBaseWritableAddress = fBaseAddress + 0x08000000;
+ }
+ break;
++#endif
+ default:
+ fSplitSegs = false;
+ fBaseAddress = 0;
+@@ -3841,6 +3859,7 @@
+ break;
+ case CPU_TYPE_X86_64:
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ switch ( fOutputKind ) {
+ case Options::kDynamicExecutable:
+@@ -3863,6 +3882,7 @@
+ fBaseAddress = 0;
+ }
+ break;
++#endif
+ }
+
+ // <rdar://problem/6138961> -r implies no prebinding for all architectures
+@@ -3908,6 +3928,7 @@
+ case CPU_TYPE_X86_64:
+ fPrebind = false;
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ switch ( fOutputKind ) {
+ case Options::kDynamicExecutable:
+@@ -3925,6 +3946,7 @@
+ break;
+ }
+ break;
++#endif
+ }
+ }
+
+@@ -3951,10 +3973,12 @@
+ case CPU_TYPE_I386:
+ if ( fIOSVersionMin != ld::iOSVersionUnset ) // simulator never needs modules
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( fPrebind )
+ fNeedsModuleTable = true; // redo_prebinding requires a module table
+ break;
++#endif
+ }
+ }
+
+@@ -3993,7 +3993,9 @@
+ switch ( fArchitecture ) {
+ case CPU_TYPE_I386:
+ case CPU_TYPE_X86_64:
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ switch ( fOutputKind ) {
+ case Options::kObjectFile:
+ case Options::kStaticExecutable:
+@@ -4010,10 +4012,12 @@
+ break;
+ }
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ fAddCompactUnwindEncoding = false;
+ fRemoveDwarfUnwindIfCompactExists = false;
+ break;
++#endif
+ case 0:
+ // if -arch is missing, assume we don't want compact unwind info
+ fAddCompactUnwindEncoding = false;
+@@ -4015,7 +4043,15 @@
+ fEncryptable = false;
+ break;
+ }
+- if ( (fArchitecture != CPU_TYPE_ARM) && (fArchitecture != CPU_TYPE_ARM64) )
++ if (
++#if SUPPORT_ARCH_arm_any
++ (fArchitecture != CPU_TYPE_ARM) &&
++#endif
++#if SUPPORT_ARCH_arm64
++ (fArchitecture != CPU_TYPE_ARM64) &&
++#endif
++ 1
++ )
+ fEncryptable = false;
+
+ // don't move inits in dyld because dyld wants certain
+@@ -4067,11 +4103,15 @@
+
+ // only ARM and x86_64 enforces that cpu-sub-types must match
+ switch ( fArchitecture ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
+ case CPU_TYPE_X86_64:
+ break;
+ case CPU_TYPE_I386:
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ fAllowCpuSubtypeMismatches = true;
+ break;
+ }
+@@ -4117,6 +4157,7 @@
+ fPositionIndependentExecutable = true;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ // armv7 for iOS4.3 defaults to PIE
+ if ( (fArchitecture == CPU_TYPE_ARM)
+ && fArchSupportsThumb2
+@@ -4124,6 +4165,7 @@
+ && (fIOSVersionMin >= ld::iOS_4_3) ) {
+ fPositionIndependentExecutable = true;
+ }
++#endif
+
+ // Simulator defaults to PIE
+ if ( fTargetIOSSimulator && (fOutputKind == kDynamicExecutable) )
+@@ -4133,10 +4175,12 @@
+ if ( fDisablePositionIndependentExecutable )
+ fPositionIndependentExecutable = false;
+
++#if SUPPORT_ARCH_arm64
+ // arm64 is always PIE
+ if ( (fArchitecture == CPU_TYPE_ARM64) && (fOutputKind == kDynamicExecutable) ) {
+ fPositionIndependentExecutable = true;
+ }
++#endif
+
+ // set fOutputSlidable
+ switch ( fOutputKind ) {
+@@ -4162,9 +4206,11 @@
+ if ( fMacVersionMin >= ld::mac10_7 ) {
+ fTLVSupport = true;
+ }
++#if SUPPORT_ARCH_arm64
+ else if ( (fArchitecture == CPU_TYPE_ARM64) && (fIOSVersionMin >= ld::iOS_8_0) ) {
+ fTLVSupport = true;
+ }
++#endif
+
+ // default to adding version load command for dynamic code, static code must opt-in
+ switch ( fOutputKind ) {
+@@ -4369,9 +4415,15 @@
+ // <rdar://problem/12258065> ARM64 needs 16KB page size for user land code
+ // <rdar://problem/15974532> make armv7[s] use 16KB pages in user land code for iOS 8 or later
+ if ( fSegmentAlignment == 4096 ) {
+- if ( (fArchitecture == CPU_TYPE_ARM64)
+- || ((fArchitecture == CPU_TYPE_ARM) && (fIOSVersionMin >= ld::iOS_8_0) &&
+- ((fSubArchitecture == CPU_SUBTYPE_ARM_V7S) || (fSubArchitecture == CPU_SUBTYPE_ARM_V7))) ) {
++ if (
++#if SUPPORT_ARCH_arm64
++ (fArchitecture == CPU_TYPE_ARM64) ||
++#endif
++#if SUPPORT_ARCH_arm_any
++ ((fArchitecture == CPU_TYPE_ARM) && (fIOSVersionMin >= ld::iOS_8_0) &&
++ ((fSubArchitecture == CPU_SUBTYPE_ARM_V7S) || (fSubArchitecture == CPU_SUBTYPE_ARM_V7))) ||
++#endif
++ 0) {
+ switch ( fOutputKind ) {
+ case Options::kDynamicExecutable:
+ case Options::kDynamicLibrary:
+@@ -4488,12 +4540,16 @@
+ if ( fStackAddr != 0 ) {
+ switch (fArchitecture) {
+ case CPU_TYPE_I386:
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
+ if ( fStackAddr > 0xFFFFFFFFULL )
+ throw "-stack_addr must be < 4G for 32-bit processes";
+ break;
+ case CPU_TYPE_X86_64:
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ break;
+ }
+ if ( (fStackAddr & -4096) != fStackAddr )
+@@ -4514,6 +4570,7 @@
+ if ( (fStackAddr > 0xB0000000ULL) && ((fStackAddr-fStackSize) < 0xB0000000ULL) )
+ warning("custom stack placement overlaps and will disable shared region");
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( fStackSize > 0x2F000000 )
+ throw "-stack_size must be < 752MB";
+@@ -4522,11 +4579,13 @@
+ if ( fStackAddr > 0x30000000ULL)
+ throw "-stack_addr must be < 0x30000000 for arm";
+ break;
++#endif
+ case CPU_TYPE_X86_64:
+ if ( fStackAddr == 0 ) {
+ fStackAddr = 0x00007FFF5C000000ULL;
+ }
+ break;
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
+ if ( fStackSize > 0x20000000 )
+ throw "-stack_size must be < 512MB";
+@@ -4534,6 +4593,7 @@
+ fStackAddr = 0x120000000ULL;
+ }
+ break;
++#endif
+ }
+ if ( (fStackSize & -4096) != fStackSize )
+ throw "-stack_size must be multiples of 4K";
+@@ -4643,8 +4703,12 @@
+ alterObjC1ClassNamesToObjC2 = true;
+ break;
+ case CPU_TYPE_X86_64:
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ alterObjC1ClassNamesToObjC2 = true;
+ break;
+ }
+@@ -4799,11 +4799,15 @@
+ // zero page size not specified on command line, set default
+ switch (fArchitecture) {
+ case CPU_TYPE_I386:
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
+ // first 4KB for 32-bit architectures
+ fZeroPageSize = 0x1000;
+ break;
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ case CPU_TYPE_X86_64:
+ // first 4GB for x86_64 on all OS's
+ fZeroPageSize = 0x100000000ULL;
+@@ -4842,9 +4910,11 @@
+
+ // -force_cpusubtype_ALL is not supported for ARM
+ if ( fForceSubtypeAll ) {
++#if SUPPORT_ARCH_arm_any
+ if ( fArchitecture == CPU_TYPE_ARM ) {
+ warning("-force_cpusubtype_ALL will become unsupported for ARM architectures");
+ }
++#endif
+ }
+
+ // -reexported_symbols_list can only be used with -dynamiclib
+diff -ur ld64-241.9/src/ld/OutputFile.cpp ld64-241.9/src/ld/OutputFile.cpp
+--- ld64-241.9/src/ld/OutputFile.cpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/ld/OutputFile.cpp 2015-01-22 20:16:24.000000000 +0100
+@@ -631,7 +631,12 @@
+ // is encoded in mach-o the same as:
+ // .long _foo + 0x40000000
+ // so if _foo lays out to 0xC0000100, the first is ok, but the second is not.
+- if ( (_options.architecture() == CPU_TYPE_ARM) || (_options.architecture() == CPU_TYPE_I386) ) {
++ if (
++#if SUPPORT_ARCH_arm_any
++ (_options.architecture() == CPU_TYPE_ARM) ||
++#endif
++ (_options.architecture() == CPU_TYPE_I386) ||
++ 0) {
+ // Unlikely userland code does funky stuff like this, so warn for them, but not warn for -preload or -static
+ if ( (_options.outputKind() != Options::kPreload) && (_options.outputKind() != Options::kStaticExecutable) ) {
+ warning("32-bit absolute address out of range (0x%08llX max is 4GB): from %s + 0x%08X (0x%08llX) to 0x%08llX",
+@@ -1235,22 +1240,26 @@
+ return false;
+ const ld::Fixup* f;
+ switch ( fixup->kind ) {
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreTargetAddressARM64Page21:
+ return !mustBeGOT;
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPage21:
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPage21:
+ return true;
++#endif
+ case ld::Fixup::kindSetTargetAddress:
+ f = fixup;
+ do {
+ ++f;
+ } while ( ! f->lastInCluster() );
+ switch (f->kind ) {
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreARM64Page21:
+ return !mustBeGOT;
+ case ld::Fixup::kindStoreARM64GOTLoadPage21:
+ case ld::Fixup::kindStoreARM64GOTLeaPage21:
+ return true;
++#endif
+ default:
+ break;
+ }
+@@ -1267,22 +1276,26 @@
+ return false;
+ const ld::Fixup* f;
+ switch ( fixup->kind ) {
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreTargetAddressARM64PageOff12:
+ return !mustBeGOT;
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPageOff12:
+ case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPageOff12:
+ return true;
++#endif
+ case ld::Fixup::kindSetTargetAddress:
+ f = fixup;
+ do {
+ ++f;
+ } while ( ! f->lastInCluster() );
+ switch (f->kind ) {
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreARM64PageOff12:
+ return !mustBeGOT;
+ case ld::Fixup::kindStoreARM64GOTLoadPageOff12:
+ case ld::Fixup::kindStoreARM64GOTLeaPageOff12:
+ return true;
++#endif
+ default:
+ break;
+ }
+@@ -1318,7 +1331,9 @@
+ std::map<uint32_t, const Fixup*> usedByHints;
+ for (ld::Fixup::iterator fit = atom->fixupsBegin(), end=atom->fixupsEnd(); fit != end; ++fit) {
+ uint8_t* fixUpLocation = &buffer[fit->offsetInAtom];
++#if SUPPORT_ARCH_arm64
+ ld::Fixup::LOH_arm64 lohExtra;
++#endif
+ switch ( (ld::Fixup::Kind)(fit->kind) ) {
+ case ld::Fixup::kindNone:
+ case ld::Fixup::kindNoneFollowOn:
+@@ -1580,6 +1595,7 @@
+ break;
+ case ld::Fixup::kindLinkerOptimizationHint:
+ // expand table of address/offsets used by hints
++#if SUPPORT_ARCH_arm64
+ lohExtra.addend = fit->u.addend;
+ usedByHints[fit->offsetInAtom + (lohExtra.info.delta1 << 2)] = NULL;
+ if ( lohExtra.info.count > 0 )
+@@ -1588,6 +1604,7 @@
+ usedByHints[fit->offsetInAtom + (lohExtra.info.delta3 << 2)] = NULL;
+ if ( lohExtra.info.count > 2 )
+ usedByHints[fit->offsetInAtom + (lohExtra.info.delta4 << 2)] = NULL;
++#endif
+ break;
+ case ld::Fixup::kindStoreTargetAddressLittleEndian32:
+ accumulator = addressOf(state, fit, &toTarget);
+@@ -2095,6 +2112,7 @@
+ //uint8_t loadSize, destReg;
+ //uint32_t scaledOffset;
+ //uint32_t imm12;
++#if SUPPORT_ARCH_arm64
+ ld::Fixup::LOH_arm64 alt;
+ alt.addend = fit->u.addend;
+ setInfo(state, atom, buffer, usedByHints, fit->offsetInAtom, (alt.info.delta1 << 2), &infoA);
+@@ -2453,6 +2471,7 @@
+ fprintf(stderr, "unknown hint kind %d alt.info.kind at 0x%08llX\n", alt.info.kind, infoA.instructionAddress);
+ break;
+ }
++#endif
+ }
+ // apply hints pass 2
+ for (ld::Fixup::iterator fit = atom->fixupsBegin(), end=atom->fixupsEnd(); fit != end; ++fit) {
+@@ -2460,6 +2479,7 @@
+ continue;
+ InstructionInfo infoA;
+ InstructionInfo infoB;
++#if SUPPORT_ARCH_arm64
+ ld::Fixup::LOH_arm64 alt;
+ alt.addend = fit->u.addend;
+ setInfo(state, atom, buffer, usedByHints, fit->offsetInAtom, (alt.info.delta1 << 2), &infoA);
+@@ -2491,6 +2511,7 @@
+ }
+ break;
+ }
++#endif
+ }
+ }
+ #endif // SUPPORT_ARCH_arm64
+@@ -2505,6 +2526,7 @@
+ for (uint8_t* p=from; p < to; ++p)
+ *p = 0x90;
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( thumb ) {
+ for (uint8_t* p=from; p < to; p += 2)
+@@ -2515,6 +2537,7 @@
+ OSWriteLittleInt32((uint32_t*)p, 0, 0xe1a00000);
+ }
+ break;
++#endif
+ default:
+ for (uint8_t* p=from; p < to; ++p)
+ *p = 0x00;
+@@ -2843,7 +2866,11 @@
+
+ // in -r mode, clarify symbolTableNotInFinalLinkedImages
+ if ( _options.outputKind() == Options::kObjectFile ) {
+- if ( (_options.architecture() == CPU_TYPE_X86_64) || (_options.architecture() == CPU_TYPE_ARM64) ) {
++ if ( (_options.architecture() == CPU_TYPE_X86_64) ||
++#if SUPPORT_ARCH_arm64
++ (_options.architecture() == CPU_TYPE_ARM64) ||
++#endif
++ 0 ) {
+ // x86_64 .o files need labels on anonymous literal strings
+ if ( (sect->type() == ld::Section::typeCString) && (atom->combine() == ld::Atom::combineByNameAndContent) ) {
+ (const_cast<ld::Atom*>(atom))->setSymbolTableInclusion(ld::Atom::symbolTableIn);
+@@ -4071,8 +4098,10 @@
+ if ( _options.sharedRegionEligible() ) {
+ // <rdar://problem/13287063> when range checking, ignore high byte of arm64 addends
+ uint64_t checkAddend = addend;
++#if SUPPORT_ARCH_arm64
+ if ( _options.architecture() == CPU_TYPE_ARM64 )
+ checkAddend &= 0x0FFFFFFFFFFFFFFFULL;
++#endif
+ if ( checkAddend != 0 ) {
+ // make sure the addend does not cause the pointer to point outside the target's segment
+ // if it does, update_dyld_shared_cache will not be able to put this dylib into the shared cache
+@@ -4279,12 +4308,17 @@
+
+ bool OutputFile::useExternalSectionReloc(const ld::Atom* atom, const ld::Atom* target, ld::Fixup* fixupWithTarget)
+ {
+- if ( (_options.architecture() == CPU_TYPE_X86_64) || (_options.architecture() == CPU_TYPE_ARM64) ) {
++ if ( (_options.architecture() == CPU_TYPE_X86_64) ||
++#if SUPPORT_ARCH_arm64
++ (_options.architecture() == CPU_TYPE_ARM64) ||
++#endif
++ 0) {
+ // x86_64 and ARM64 use external relocations for everthing that has a symbol
+ return ( target->symbolTableInclusion() != ld::Atom::symbolTableNotIn );
+ }
+
+ // <rdar://problem/9513487> support arm branch interworking in -r mode
++#if SUPPORT_ARCH_arm_any
+ if ( (_options.architecture() == CPU_TYPE_ARM) && (_options.outputKind() == Options::kObjectFile) ) {
+ if ( atom->isThumb() != target->isThumb() ) {
+ switch ( fixupWithTarget->kind ) {
+@@ -4298,6 +4332,7 @@
+ }
+ }
+ }
++#endif
+
+ if ( (_options.architecture() == CPU_TYPE_I386) && (_options.outputKind() == Options::kObjectFile) ) {
+ if ( target->contentType() == ld::Atom::typeTLV )
+@@ -4365,7 +4400,11 @@
+ bool minusTargetUsesExternalReloc = (minusTarget != NULL) && this->useExternalSectionReloc(atom, minusTarget, fixupWithMinusTarget);
+
+ // in x86_64 and arm64 .o files an external reloc means the content contains just the addend
+- if ( (_options.architecture() == CPU_TYPE_X86_64) ||(_options.architecture() == CPU_TYPE_ARM64) ) {
++ if ( (_options.architecture() == CPU_TYPE_X86_64) ||
++#if SUPPORT_ARCH_arm64
++ (_options.architecture() == CPU_TYPE_ARM64) ||
++#endif
++ 0 ) {
+ if ( targetUsesExternalReloc ) {
+ fixupWithTarget->contentAddendOnly = true;
+ fixupWithStore->contentAddendOnly = true;
+Only in ld64-241.9/src/ld: OutputFile.o
+diff -ur ld64-241.9/src/ld/Resolver.cpp ld64-241.9/src/ld/Resolver.cpp
+--- ld64-241.9/src/ld/Resolver.cpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/ld/Resolver.cpp 2015-01-22 20:30:28.000000000 +0100
+@@ -431,6 +431,7 @@
+ // update cpu-sub-type
+ cpu_subtype_t nextObjectSubType = file.cpuSubType();
+ switch ( _options.architecture() ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( _options.subArchitecture() != nextObjectSubType ) {
+ if ( (_options.subArchitecture() == CPU_SUBTYPE_ARM_ALL) && _options.forceCpuSubtypeAll() ) {
+@@ -449,6 +450,7 @@
+ }
+ }
+ break;
++#endif
+
+ case CPU_TYPE_I386:
+ _internal.cpuSubType = CPU_SUBTYPE_I386_ALL;
+diff -ur ld64-241.9/src/ld/parsers/archive_file.cpp ld64-241.9/src/ld/parsers/archive_file.cpp
+--- ld64-241.9/src/ld/parsers/archive_file.cpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/ld/parsers/archive_file.cpp 2015-01-22 05:57:03.000000000 +0100
+@@ -232,8 +232,12 @@
+
+ template <> cpu_type_t File<x86>::architecture() { return CPU_TYPE_I386; }
+ template <> cpu_type_t File<x86_64>::architecture() { return CPU_TYPE_X86_64; }
++#if SUPPORT_ARCH_arm_any
+ template <> cpu_type_t File<arm>::architecture() { return CPU_TYPE_ARM; }
++#endif
++#if SUPPORT_ARCH_arm64
+ template <> cpu_type_t File<arm64>::architecture() { return CPU_TYPE_ARM64; }
++#endif
+
+
+ template <typename A>
+diff -ur ld64-241.9/src/ld/parsers/macho_dylib_file.cpp ld64-241.9/src/ld/parsers/macho_dylib_file.cpp
+--- ld64-241.9/src/ld/parsers/macho_dylib_file.cpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/ld/parsers/macho_dylib_file.cpp 2015-01-22 06:07:53.000000000 +0100
+@@ -258,11 +258,15 @@
+ bool File<A>::_s_logHashtable = false;
+
+ template <> const char* File<x86_64>::objCInfoSegmentName() { return "__DATA"; }
++#if SUPPORT_ARCH_arm_any
+ template <> const char* File<arm>::objCInfoSegmentName() { return "__DATA"; }
++#endif
+ template <typename A> const char* File<A>::objCInfoSegmentName() { return "__OBJC"; }
+
+ template <> const char* File<x86_64>::objCInfoSectionName() { return "__objc_imageinfo"; }
++#if SUPPORT_ARCH_arm_any
+ template <> const char* File<arm>::objCInfoSectionName() { return "__objc_imageinfo"; }
++#endif
+ template <typename A> const char* File<A>::objCInfoSectionName() { return "__image_info"; }
+
+ template <typename A>
+@@ -1020,6 +1024,7 @@
+ }
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ bool Parser<arm>::validFile(const uint8_t* fileContent, bool executableOrDyliborBundle)
+ {
+@@ -1046,9 +1051,11 @@
+ return false;
+ }
+ }
++#endif
+
+
+
++#if SUPPORT_ARCH_arm64
+ template <>
+ bool Parser<arm64>::validFile(const uint8_t* fileContent, bool executableOrDyliborBundle)
+ {
+@@ -1075,6 +1082,7 @@
+ return false;
+ }
+ }
++#endif
+
+
+ bool isDylibFile(const uint8_t* fileContent, cpu_type_t* result, cpu_subtype_t* subResult)
+@@ -1090,17 +1098,21 @@
+ *subResult = CPU_SUBTYPE_X86_ALL;
+ return true;
+ }
++#if SUPPORT_ARCH_arm_any
+ if ( Parser<arm>::validFile(fileContent, false) ) {
+ *result = CPU_TYPE_ARM;
+ const macho_header<Pointer32<LittleEndian> >* header = (const macho_header<Pointer32<LittleEndian> >*)fileContent;
+ *subResult = header->cpusubtype();
+ return true;
+ }
++#endif
++#if SUPPORT_ARCH_arm64
+ if ( Parser<arm64>::validFile(fileContent, false) ) {
+ *result = CPU_TYPE_ARM64;
+ *subResult = CPU_SUBTYPE_ARM64_ALL;
+ return true;
+ }
++#endif
+ return false;
+ }
+
+@@ -1126,6 +1138,7 @@
+ return "x86_64";
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ const char* Parser<arm>::fileKind(const uint8_t* fileContent)
+ {
+@@ -1141,6 +1154,7 @@
+ }
+ return "arm???";
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -1166,9 +1180,11 @@
+ if ( Parser<x86>::validFile(fileContent, true) ) {
+ return Parser<x86>::fileKind(fileContent);
+ }
++#if SUPPORT_ARCH_arm_any
+ if ( Parser<arm>::validFile(fileContent, true) ) {
+ return Parser<arm>::fileKind(fileContent);
+ }
++#endif
+ #if SUPPORT_ARCH_arm64
+ if ( Parser<arm64>::validFile(fileContent, false) ) {
+ return Parser<arm64>::fileKind(fileContent);
+diff -ur ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp
+--- ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp 2015-01-22 20:38:57.000000000 +0100
+@@ -867,6 +867,7 @@
+ }
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ void Atom<arm>::verifyAlignment(const macho_section<P>&) const
+ {
+@@ -875,6 +876,7 @@
+ warning("ARM function not 4-byte aligned: %s from %s", this->name(), this->file()->path());
+ }
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -1262,6 +1264,7 @@
+ return true;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ bool Parser<arm>::validFile(const uint8_t* fileContent, bool subtypeMustMatch, cpu_subtype_t subtype)
+ {
+@@ -1282,8 +1285,10 @@
+ }
+ return true;
+ }
++#endif
+
+
++#if SUPPORT_ARCH_arm64
+ template <>
+ bool Parser<arm64>::validFile(const uint8_t* fileContent, bool subtypeMustMatch, cpu_subtype_t subtype)
+ {
+@@ -1296,6 +1301,7 @@
+ return false;
+ return true;
+ }
++#endif
+
+
+ template <>
+@@ -1320,6 +1326,7 @@
+ return "x86_64";
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ const char* Parser<arm>::fileKind(const uint8_t* fileContent)
+ {
+@@ -1335,6 +1342,7 @@
+ }
+ return "arm???";
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -1599,11 +1607,13 @@
+ return false;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ arm::P::uint_t Parser<arm>::realAddr(arm::P::uint_t addr)
+ {
+ return addr & (-2);
+ }
++#endif
+
+ template <typename A>
+ typename A::P::uint_t Parser<A>::realAddr(typename A::P::uint_t addr)
+@@ -1867,8 +1877,12 @@
+
+ template <> uint8_t Parser<x86>::loadCommandSizeMask() { return 0x03; }
+ template <> uint8_t Parser<x86_64>::loadCommandSizeMask() { return 0x07; }
++#if SUPPORT_ARCH_arm_any
+ template <> uint8_t Parser<arm>::loadCommandSizeMask() { return 0x03; }
++#endif
++#if SUPPORT_ARCH_arm64
+ template <> uint8_t Parser<arm64>::loadCommandSizeMask() { return 0x07; }
++#endif
+
+ template <typename A>
+ bool Parser<A>::parseLoadCommands()
+@@ -4065,12 +4079,14 @@
+ return 1 + (this->_machOSection - parser.firstMachOSection());
+ }
+
++#if SUPPORT_ARCH_arm_any
+ // arm does not have zero cost exceptions
+ template <>
+ uint32_t CFISection<arm>::cfiCount(Parser<arm>& parser)
+ {
+ return 0;
+ }
++#endif
+
+ template <typename A>
+ uint32_t CFISection<A>::cfiCount(Parser<A>& parser)
+@@ -4198,6 +4214,7 @@
+
+
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ void CFISection<arm>::cfiParse(class Parser<arm>& parser, uint8_t* buffer,
+ libunwind::CFI_Atom_Info<CFISection<arm>::OAS>::CFI_Atom_Info cfiArray[],
+@@ -4206,6 +4223,7 @@
+ // arm does not use zero cost exceptions
+ assert(count == 0);
+ }
++#endif
+
+
+
+@@ -4310,8 +4328,12 @@
+
+ template <> bool CFISection<x86_64>::bigEndian() { return false; }
+ template <> bool CFISection<x86>::bigEndian() { return false; }
++#if SUPPORT_ARCH_arm_any
+ template <> bool CFISection<arm>::bigEndian() { return false; }
++#endif
++#if SUPPORT_ARCH_arm64
+ template <> bool CFISection<arm64>::bigEndian() { return false; }
++#endif
+
+
+ template <>
+@@ -5229,11 +5251,13 @@
+ return ld::Fixup::kindStoreLittleEndian32;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ ld::Fixup::Kind NonLazyPointerSection<arm>::fixupKind()
+ {
+ return ld::Fixup::kindStoreLittleEndian32;
+ }
++#endif
+
+ template <>
+ ld::Fixup::Kind NonLazyPointerSection<arm64>::fixupKind()
+@@ -7346,10 +7370,14 @@
+ return ( mach_o::relocatable::Parser<x86_64>::validFile(fileContent) );
+ case CPU_TYPE_I386:
+ return ( mach_o::relocatable::Parser<x86>::validFile(fileContent) );
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ return ( mach_o::relocatable::Parser<arm>::validFile(fileContent, opts.objSubtypeMustMatch, opts.subType) );
++#endif
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
+ return ( mach_o::relocatable::Parser<arm64>::validFile(fileContent, opts.objSubtypeMustMatch, opts.subType) );
++#endif
+ }
+ return false;
+ }
+@@ -7370,17 +7398,21 @@
+ *subResult = CPU_SUBTYPE_X86_ALL;
+ return true;
+ }
++#if SUPPORT_ARCH_arm_any
+ if ( mach_o::relocatable::Parser<arm>::validFile(fileContent, false, 0) ) {
+ *result = CPU_TYPE_ARM;
+ const macho_header<Pointer32<LittleEndian> >* header = (const macho_header<Pointer32<LittleEndian> >*)fileContent;
+ *subResult = header->cpusubtype();
+ return true;
+ }
++#endif
++#if SUPPORT_ARCH_arm_any
+ if ( mach_o::relocatable::Parser<arm64>::validFile(fileContent, false, 0) ) {
+ *result = CPU_TYPE_ARM64;
+ *subResult = CPU_SUBTYPE_ARM64_ALL;
+ return true;
+ }
++#endif
+ return false;
+ }
+
+@@ -7395,9 +7427,11 @@
+ if ( mach_o::relocatable::Parser<x86>::validFile(fileContent) ) {
+ return mach_o::relocatable::Parser<x86>::fileKind(fileContent);
+ }
++#if SUPPORT_ARCH_arm_any
+ if ( mach_o::relocatable::Parser<arm>::validFile(fileContent, false, 0) ) {
+ return mach_o::relocatable::Parser<arm>::fileKind(fileContent);
+ }
++#endif
+ return NULL;
+ }
+
+@@ -7409,9 +7443,11 @@
+ if ( mach_o::relocatable::Parser<x86_64>::validFile(fileContent) ) {
+ return mach_o::relocatable::Parser<x86_64>::hasObjC2Categories(fileContent);
+ }
++#if SUPPORT_ARCH_arm_any
+ else if ( mach_o::relocatable::Parser<arm>::validFile(fileContent, false, 0) ) {
+ return mach_o::relocatable::Parser<arm>::hasObjC2Categories(fileContent);
+ }
++#endif
+ else if ( mach_o::relocatable::Parser<x86>::validFile(fileContent, false, 0) ) {
+ return mach_o::relocatable::Parser<x86>::hasObjC2Categories(fileContent);
+ }
+diff -ur ld64-241.9/src/ld/passes/branch_island.cpp ld64-241.9/src/ld/passes/branch_island.cpp
+--- ld64-241.9/src/ld/passes/branch_island.cpp 2014-09-11 00:24:46.000000000 +0200
++++ ld64-241.9/src/ld/passes/branch_island.cpp 2015-01-22 06:23:52.000000000 +0100
+@@ -285,6 +285,7 @@
+ static uint64_t textSizeWhenMightNeedBranchIslands(const Options& opts, bool seenThumbBranch)
+ {
+ switch ( opts.architecture() ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( ! seenThumbBranch )
+ return 32000000; // ARM can branch +/- 32MB
+@@ -293,6 +294,7 @@
+ else
+ return 4000000; // thumb1 can branch +/- 4MB
+ break;
++#endif
+ }
+ assert(0 && "unexpected architecture");
+ return 0x100000000LL;
+@@ -302,6 +304,7 @@
+ static uint64_t maxDistanceBetweenIslands(const Options& opts, bool seenThumbBranch)
+ {
+ switch ( opts.architecture() ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ if ( ! seenThumbBranch )
+ return 30*1024*1024; // 2MB of branch islands per 32MB
+@@ -310,6 +313,7 @@
+ else
+ return 3500000; // 0.5MB of branch islands per 4MB
+ break;
++#endif
+ }
+ assert(0 && "unexpected architecture");
+ return 0x100000000LL;
+@@ -654,8 +658,10 @@
+
+ // only ARM needs branch islands
+ switch ( opts.architecture() ) {
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ break;
++#endif
+ default:
+ return;
+ }
+diff -ur ld64-241.9/src/ld/passes/branch_shim.cpp ld64-241.9/src/ld/passes/branch_shim.cpp
+--- ld64-241.9/src/ld/passes/branch_shim.cpp 2014-09-11 00:24:46.000000000 +0200
++++ ld64-241.9/src/ld/passes/branch_shim.cpp 2015-01-22 06:33:01.000000000 +0100
+@@ -276,6 +276,9 @@
+ //
+ void doPass(const Options& opts, ld::Internal& state)
+ {
++#if !SUPPORT_ARCH_arm_any
++ return;
++#else
+ // only make branch shims in final linked images
+ if ( opts.outputKind() == Options::kObjectFile )
+ return;
+@@ -386,6 +389,7 @@
+ // append all new shims to end of __text
+ sect->atoms.insert(sect->atoms.end(), shims.begin(), shims.end());
+ }
++#endif
+ }
+
+
+diff -ur ld64-241.9/src/ld/passes/dtrace_dof.cpp ld64-241.9/src/ld/passes/dtrace_dof.cpp
+--- ld64-241.9/src/ld/passes/dtrace_dof.cpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/ld/passes/dtrace_dof.cpp 2015-01-22 06:33:51.000000000 +0100
+@@ -179,8 +179,12 @@
+ switch ( opts.architecture() ) {
+ case CPU_TYPE_I386:
+ case CPU_TYPE_X86_64:
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
++#endif
++#if SUPPORT_ARCH_arm64
+ case CPU_TYPE_ARM64:
++#endif
+ storeKind = ld::Fixup::kindStoreLittleEndian32;
+ break;
+ default:
+diff -ur ld64-241.9/src/ld/passes/stubs/stubs.cpp ld64-241.9/src/ld/passes/stubs/stubs.cpp
+--- ld64-241.9/src/ld/passes/stubs/stubs.cpp 2014-09-11 00:24:46.000000000 +0200
++++ ld64-241.9/src/ld/passes/stubs/stubs.cpp 2015-01-22 06:34:56.000000000 +0100
+@@ -324,9 +324,11 @@
+ if ( _options.outputKind() != Options::kDynamicLibrary )
+ throwf("resolver functions (%s) can only be used in dylibs", atom->name());
+ if ( !_options.makeCompressedDyldInfo() ) {
++#if SUPPORT_ARCH_arm_any
+ if ( _options.architecture() == CPU_TYPE_ARM )
+ throwf("resolver functions (%s) can only be used when targeting iOS 4.2 or later", atom->name());
+ else
++#endif
+ throwf("resolver functions (%s) can only be used when targeting Mac OS X 10.6 or later", atom->name());
+ }
+ stubFor[atom] = NULL;
+@@ -354,6 +356,7 @@
+ throw "symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o";
+
+ // disable arm close stubs in some cases
++#if SUPPORT_ARCH_arm_any
+ if ( _architecture == CPU_TYPE_ARM ) {
+ if ( codeSize > 4*1024*1024 )
+ _largeText = true;
+@@ -377,6 +380,7 @@
+ }
+ }
+ }
++#endif
+
+ // make stub atoms
+ for (std::map<const ld::Atom*,ld::Atom*>::iterator it = stubFor.begin(); it != stubFor.end(); ++it) {
+diff -ur ld64-241.9/src/other/ObjectDump.cpp ld64-241.9/src/other/ObjectDump.cpp
+--- ld64-241.9/src/other/ObjectDump.cpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/other/ObjectDump.cpp 2015-01-22 05:32:46.000000000 +0100
+@@ -806,6 +806,7 @@
+ case ld::Fixup::kindStoreThumbHigh16:
+ printf(", then store high-16 in Thumb movt");
+ break;
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreARM64Branch26:
+ printf(", then store as ARM64 26-bit pcrel branch");
+ break;
+@@ -845,6 +846,7 @@
+ case ld::Fixup::kindStoreARM64PCRelToGOT:
+ printf(", then store as 32-bit delta to GOT entry");
+ break;
++#endif
+ case ld::Fixup::kindDtraceExtra:
+ printf("dtrace static probe extra info");
+ break;
+@@ -989,6 +991,7 @@
+ case ld::Fixup::kindSetTargetTLVTemplateOffsetLittleEndian64:
+ printf("tlv template offset of %s", referenceTargetAtomName(ref));
+ break;
++#if SUPPORT_ARCH_arm64
+ case ld::Fixup::kindStoreTargetAddressARM64Branch26:
+ printf("ARM64 store 26-bit pcrel branch to %s", referenceTargetAtomName(ref));
+ break;
+@@ -1022,6 +1025,7 @@
+ case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadNowLeaPageOff12:
+ printf("ARM64 store 12-bit page offset of lea for TLV of %s", referenceTargetAtomName(ref));
+ break;
++#endif
+ //default:
+ // printf("unknown fixup");
+ // break;
+diff -ur ld64-241.9/src/other/rebase.cpp ld64-241.9/src/other/rebase.cpp
+--- ld64-241.9/src/other/rebase.cpp 2014-09-11 00:24:46.000000000 +0200
++++ ld64-241.9/src/other/rebase.cpp 2015-01-22 05:46:29.000000000 +0100
+@@ -160,9 +160,11 @@
+ case CPU_TYPE_X86_64:
+ fRebasers.push_back(new Rebaser<x86_64>(&p[fileOffset]));
+ break;
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ fRebasers.push_back(new Rebaser<arm>(&p[fileOffset]));
+ break;
++#endif
+ default:
+ throw "unknown file format";
+ }
+@@ -186,9 +188,11 @@
+ else if ( (OSSwapLittleToHostInt32(mh->magic) == MH_MAGIC_64) && (OSSwapLittleToHostInt32(mh->cputype) == CPU_TYPE_X86_64)) {
+ fRebasers.push_back(new Rebaser<x86_64>(mh));
+ }
++#if SUPPORT_ARCH_arm_any
+ else if ( (OSSwapLittleToHostInt32(mh->magic) == MH_MAGIC) && (OSSwapLittleToHostInt32(mh->cputype) == CPU_TYPE_ARM)) {
+ fRebasers.push_back(new Rebaser<arm>(mh));
+ }
++#endif
+ else {
+ throw "unknown file format";
+ }
+@@ -236,7 +240,9 @@
+ template <> cpu_type_t Rebaser<ppc64>::getArchitecture() const { return CPU_TYPE_POWERPC64; }
+ template <> cpu_type_t Rebaser<x86>::getArchitecture() const { return CPU_TYPE_I386; }
+ template <> cpu_type_t Rebaser<x86_64>::getArchitecture() const { return CPU_TYPE_X86_64; }
++#if SUPPORT_ARCH_arm_any
+ template <> cpu_type_t Rebaser<arm>::getArchitecture() const { return CPU_TYPE_ARM; }
++#endif
+
+ template <typename A>
+ uint64_t Rebaser<A>::getBaseAddress() const
+@@ -875,8 +881,10 @@
+ return "i386";
+ case CPU_TYPE_X86_64:
+ return "x86_64";
++#if SUPPORT_ARCH_arm_any
+ case CPU_TYPE_ARM:
+ return "arm";
++#endif
+ }
+ return "unknown";
+ }
+@@ -969,6 +977,7 @@
+ else if ( arch == CPU_TYPE_X86_64 ) {
+ return 0x200000000ULL;
+ }
++#if SUPPORT_ARCH_arm_any
+ else if ( arch == CPU_TYPE_ARM ) {
+ // place dylibs below dyld
+ uint64_t topAddr = 0x2FE00000;
+@@ -977,6 +986,7 @@
+ throwf("total size of images (0x%X) does not fit below 0x2FE00000", totalSize);
+ return topAddr - totalSize;
+ }
++#endif
+ else
+ throw "unknown architecture";
+ }
+@@ -1043,7 +1053,9 @@
+ onlyArchs.insert(CPU_TYPE_POWERPC64);
+ onlyArchs.insert(CPU_TYPE_I386);
+ onlyArchs.insert(CPU_TYPE_X86_64);
++#if SUPPORT_ARCH_arm_any
+ onlyArchs.insert(CPU_TYPE_ARM);
++#endif
+ }
+
+ // scan files and collect sizes
+diff -ur ld64-241.9/src/other/unwinddump.cpp ld64-241.9/src/other/unwinddump.cpp
+--- ld64-241.9/src/other/unwinddump.cpp 2015-01-22 20:59:47.000000000 +0100
++++ ld64-241.9/src/other/unwinddump.cpp 2015-01-22 05:45:28.000000000 +0100
+@@ -97,7 +97,9 @@
+
+ template <> const char* UnwindPrinter<x86>::archName() { return "i386"; }
+ template <> const char* UnwindPrinter<x86_64>::archName() { return "x86_64"; }
++#if SUPPORT_ARCH_arm_any
+ template <> const char* UnwindPrinter<arm>::archName() { return "arm"; }
++#endif
+ #if SUPPORT_ARCH_arm64
+ template <> const char* UnwindPrinter<arm64>::archName() { return "arm64"; }
+ #endif
+@@ -1072,7 +1074,9 @@
+ #if SUPPORT_ARCH_arm64
+ onlyArchs.insert(CPU_TYPE_ARM64);
+ #endif
++#if SUPPORT_ARCH_arm_any
+ onlyArchs.insert(CPU_TYPE_ARM);
++#endif
+ }
+
+ // process each file
+--- ld64-241.9/src/other/machochecker.cpp 2015-01-23 01:54:12.000000000 +0100
++++ ld64-241.9/src/other/machochecker.cpp 2015-01-23 01:57:11.000000000 +0100
+@@ -252,6 +252,7 @@
+ return false;
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ bool MachOChecker<arm>::validFile(const uint8_t* fileContent)
+ {
+@@ -269,6 +270,7 @@
+ }
+ return false;
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -294,7 +296,9 @@
+ template <> uint8_t MachOChecker<ppc64>::loadCommandSizeMask() { return 0x07; }
+ template <> uint8_t MachOChecker<x86>::loadCommandSizeMask() { return 0x03; }
+ template <> uint8_t MachOChecker<x86_64>::loadCommandSizeMask() { return 0x07; }
++#if SUPPORT_ARCH_arm_any
+ template <> uint8_t MachOChecker<arm>::loadCommandSizeMask() { return 0x03; }
++#endif
+ #if SUPPORT_ARCH_arm64
+ template <> uint8_t MachOChecker<arm64>::loadCommandSizeMask() { return 0x07; }
+ #endif
+@@ -324,11 +328,13 @@
+ return threadInfo->thread_register(7);
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ arm::P::uint_t MachOChecker<arm>::getInitialStackPointer(const macho_thread_command<arm::P>* threadInfo)
+ {
+ return threadInfo->thread_register(13);
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -362,11 +368,13 @@
+ return threadInfo->thread_register(16);
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ arm::P::uint_t MachOChecker<arm>::getEntryPoint(const macho_thread_command<arm::P>* threadInfo)
+ {
+ return threadInfo->thread_register(15);
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
+@@ -1025,6 +1033,7 @@
+ return fFirstWritableSegment->vmaddr();
+ }
+
++#if SUPPORT_ARCH_arm_any
+ template <>
+ arm::P::uint_t MachOChecker<arm>::relocBase()
+ {
+@@ -1033,6 +1042,7 @@
+ else
+ return fFirstSegment->vmaddr();
+ }
++#endif
+
+ #if SUPPORT_ARCH_arm64
+ template <>
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-nosnapshots.patch b/sys-devel/binutils-apple/files/ld64-241.9-nosnapshots.patch
new file mode 100644
index 000000000000..f484111ab34b
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-nosnapshots.patch
@@ -0,0 +1,644 @@
+Allow to disable snapshot support because of missing Block API on OS X < 10.6.
+
+--- ld64-241.9/src/ld/InputFiles.cpp.orig 2015-01-16 15:26:31.000000000 -0800
++++ ld64-241.9/src/ld/InputFiles.cpp 2015-01-16 15:26:54.000000000 -0800
+@@ -1144,7 +1144,9 @@
+ case ld::File::Reloc:
+ {
+ ld::relocatable::File* reloc = (ld::relocatable::File*)file;
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordObjectFile(reloc->path());
++#endif
+ if ( _options.dumpDependencyInfo() )
+ _options.dumpDependency(Options::depObjectFile, reloc->path());
+ }
+@@ -1244,7 +1246,9 @@
+ if ( dylibFile->justInTimeforEachAtom(name, handler) ) {
+ // we found a definition in this dylib
+ // done, unless it is a weak definition in which case we keep searching
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordDylibSymbol(dylibFile, name);
++#endif
+ if ( !dylibFile->hasWeakExternals() || !dylibFile->hasWeakDefinition(name)) {
+ return true;
+ }
+@@ -1258,7 +1262,9 @@
+ if ( archiveFile->justInTimeDataOnlyforEachAtom(name, handler) ) {
+ if ( _options.traceArchives() )
+ logArchive(archiveFile);
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordArchive(archiveFile->path());
++#endif
+ // found data definition in static library, done
+ return true;
+ }
+@@ -1267,7 +1273,9 @@
+ if ( archiveFile->justInTimeforEachAtom(name, handler) ) {
+ if ( _options.traceArchives() )
+ logArchive(archiveFile);
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordArchive(archiveFile->path());
++#endif
+ // found definition in static library, done
+ return true;
+ }
+@@ -1294,7 +1302,9 @@
+ if ( dylibFile->justInTimeforEachAtom(name, handler) ) {
+ // we found a definition in this dylib
+ // done, unless it is a weak definition in which case we keep searching
++#ifdef SUPPORT_SNAPSHOTS
+ _options.snapshot().recordDylibSymbol(dylibFile, name);
++#endif
+ if ( !dylibFile->hasWeakExternals() || !dylibFile->hasWeakDefinition(name)) {
+ return true;
+ }
+--- ld64-241.9/src/ld/ld.cpp.orig 2015-01-16 15:26:32.000000000 -0800
++++ ld64-241.9/src/ld/ld.cpp 2015-01-16 15:26:54.000000000 -0800
+@@ -1180,11 +1180,13 @@
+ // implement assert() function to print out a backtrace before aborting
+ void __assert_rtn(const char* func, const char* file, int line, const char* failedexpr)
+ {
++#ifdef SUPPORT_SNAPSHOTS
+ Snapshot *snapshot = Snapshot::globalSnapshot;
+
+ snapshot->setSnapshotMode(Snapshot::SNAPSHOT_DEBUG);
+ snapshot->createSnapshot();
+ snapshot->recordAssertionMessage("Assertion failed: (%s), function %s, file %s, line %d.\n", failedexpr, func, file, line);
++#endif
+
+ void* callStack[128];
+ int depth = ::backtrace(callStack, 128);
+@@ -1202,9 +1204,13 @@
+ }
+ long offset = (uintptr_t)callStack[i] - (uintptr_t)info.dli_saddr;
+ fprintf(stderr, "%d %p %s + %ld\n", i, callStack[i], symboName, offset);
++#ifdef SUPPORT_SNAPSHOTS
+ snapshot->recordAssertionMessage("%d %p %s + %ld\n", i, callStack[i], symboName, offset);
++#endif
+ }
++#ifdef SUPPORT_SNAPSHOTS
+ fprintf(stderr, "A linker snapshot was created at:\n\t%s\n", snapshot->rootDir());
++#endif
+ fprintf(stderr, "ld: Assertion failed: (%s), function %s, file %s, line %d.\n", failedexpr, func, file, line);
+ exit(1);
+ }
+--- ld64-241.9/src/ld/Options.cpp.orig 2015-01-16 15:26:32.000000000 -0800
++++ ld64-241.9/src/ld/Options.cpp 2015-01-16 15:27:26.000000000 -0800
+@@ -183,7 +183,11 @@
+ fMarkAppExtensionSafe(false), fCheckAppExtensionSafe(false), fForceLoadSwiftLibs(false),
+ fDebugInfoStripping(kDebugInfoMinimal), fTraceOutputFile(NULL),
+ fMacVersionMin(ld::macVersionUnset), fIOSVersionMin(ld::iOSVersionUnset),
+- fSaveTempFiles(false), fSnapshotRequested(false), fPipelineFifo(NULL),
++ fSaveTempFiles(false),
++#ifdef SUPPORT_SNAPSHOTS
++ fSnapshotRequested(false),
++#endif
++ fPipelineFifo(NULL),
+ fDependencyInfoPath(NULL), fDependencyFileDescriptor(-1)
+ {
+ this->checkForClassic(argc, argv);
+@@ -589,7 +593,9 @@
+ }
+ break;
+ }
++#ifdef SUPPORT_SNAPSHOTS
+ fLinkSnapshot.recordArch(fArchitectureName);
++#endif
+ // only use compressed LINKEDIT for:
+ // Mac OS X 10.6 or later
+ // iOS 3.1 or later
+@@ -1908,8 +1914,10 @@
+ //
+ void Options::parse(int argc, const char* argv[])
+ {
++#ifdef SUPPORT_SNAPSHOTS
+ // Store the original args in the link snapshot.
+ fLinkSnapshot.recordRawArgs(argc, argv);
++#endif
+
+ // pass one builds search list from -L and -F options
+ this->buildSearchPaths(argc, argv);
+@@ -1922,17 +1930,21 @@
+ const char* arg = argv[i];
+
+ if ( arg[0] == '-' ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // by default, copy one arg to the snapshot link command, and do no file copying
+ int snapshotArgIndex = i;
+ int snapshotArgCount = -1; // -1 means compute count based on change in index
+ int snapshotFileArgIndex = -1; // -1 means no data file parameter to arg
++#endif
+
+ // Since we don't care about the files passed, just the option names, we do this here.
+ if (fPrintOptions)
+ fprintf (stderr, "[Logging ld64 options]\t%s\n", arg);
+
+ if ( (arg[1] == 'L') || (arg[1] == 'F') ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0; // stripped out of link snapshot
++#endif
+ if (arg[2] == '\0')
+ ++i;
+ // previously handled by buildSearchPaths()
+@@ -1979,12 +1991,16 @@
+ fOutputKind = kKextBundle;
+ }
+ else if ( strcmp(arg, "-o") == 0 ) {
+- snapshotArgCount = 0;
+ fOutputFile = argv[++i];
++#ifdef SUPPORT_SNAPSHOTS
++ snapshotArgCount = 0;
+ fLinkSnapshot.setSnapshotName(fOutputFile);
++#endif
+ }
+ else if ( strncmp(arg, "-lazy-l", 7) == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[7], true);
+ info.options.fLazyLoad = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -1992,13 +2008,17 @@
+ fUsingLazyDylibLinking = true;
+ }
+ else if ( strcmp(arg, "-lto_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ fOverridePathlibLTO = argv[++i];
+ if ( fOverridePathlibLTO == NULL )
+ throw "missing argument to -lto_library";
+ }
+ else if ( (arg[1] == 'l') && (strncmp(arg,"-lazy_",6) !=0) ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[2]);
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+@@ -2006,8 +2026,10 @@
+ // This causes a dylib to be weakly bound at
+ // link time. This corresponds to weak_import.
+ else if ( strncmp(arg, "-weak-l", 7) == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[7]);
+ info.options.fWeakImport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -2065,12 +2087,16 @@
+ else if ( strcmp(arg, "-sectorder") == 0 ) {
+ if ( (argv[i+1]==NULL) || (argv[i+2]==NULL) || (argv[i+3]==NULL) )
+ throw "-sectorder missing <segment> <section> <file-path>";
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 3;
++#endif
+ parseSectionOrderFile(argv[i+1], argv[i+2], argv[i+3]);
+ i += 3;
+ }
+ else if ( strcmp(arg, "-order_file") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ parseOrderFile(argv[++i], false);
+ }
+ else if ( strcmp(arg, "-order_file_statistics") == 0 ) {
+@@ -2081,7 +2107,9 @@
+ else if ( (strcmp(arg, "-sectcreate") == 0) || (strcmp(arg, "-segcreate") == 0) ) {
+ if ( (argv[i+1]==NULL) || (argv[i+2]==NULL) || (argv[i+3]==NULL) )
+ throw "-sectcreate missing <segment> <section> <file-path>";
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 3;
++#endif
+ addSection(argv[i+1], argv[i+2], argv[i+3]);
+ i += 3;
+ }
+@@ -2110,7 +2138,9 @@
+ }
+ // Same as -@ from the FSF linker.
+ else if ( strcmp(arg, "-filelist") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ const char* path = argv[++i];
+ if ( (path == NULL) || (path[0] == '-') )
+ throw "-filelist missing <path>";
+@@ -2137,7 +2167,9 @@
+ }
+ }
+ else if ( strcmp(arg, "-interposable_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ fInterposeMode = kInterposeSome;
+ loadExportFile(argv[++i], "-interposable_list", fInterposeList);
+ }
+@@ -2146,14 +2178,18 @@
+ fInterposeMode = kInterposeNone;
+ }
+ else if ( strcmp(arg, "-exported_symbols_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fExportMode == kDontExportSome )
+ throw "can't use -exported_symbols_list and -unexported_symbols_list";
+ fExportMode = kExportSome;
+ loadExportFile(argv[++i], "-exported_symbols_list", fExportSymbols);
+ }
+ else if ( strcmp(arg, "-unexported_symbols_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fExportMode == kExportSome )
+ throw "can't use -unexported_symbols_list and -exported_symbols_list";
+ fExportMode = kDontExportSome;
+@@ -2172,14 +2208,18 @@
+ fDontExportSymbols.insert(argv[++i]);
+ }
+ else if ( strcmp(arg, "-non_global_symbols_no_strip_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fLocalSymbolHandling == kLocalSymbolsSelectiveExclude )
+ throw "can't use -non_global_symbols_no_strip_list and -non_global_symbols_strip_list";
+ fLocalSymbolHandling = kLocalSymbolsSelectiveInclude;
+ loadExportFile(argv[++i], "-non_global_symbols_no_strip_list", fLocalSymbolsIncluded);
+ }
+ else if ( strcmp(arg, "-non_global_symbols_strip_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fLocalSymbolHandling == kLocalSymbolsSelectiveInclude )
+ throw "can't use -non_global_symbols_no_strip_list and -non_global_symbols_strip_list";
+ fLocalSymbolHandling = kLocalSymbolsSelectiveExclude;
+@@ -2195,16 +2235,20 @@
+ }
+ // Similar to -weak-l but uses the absolute path name to the library.
+ else if ( strcmp(arg, "-weak_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFile(argv[++i]);
+ info.options.fWeakImport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-lazy_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFile(argv[++i]);
+ info.options.fLazyLoad = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -2212,22 +2256,28 @@
+ fUsingLazyDylibLinking = true;
+ }
+ else if ( strcmp(arg, "-framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-weak_framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.options.fWeakImport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-lazy_framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.options.fLazyLoad = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -2305,8 +2355,10 @@
+ // This should probably be deprecated when we respect -L and -F
+ // when searching for libraries.
+ else if ( strcmp(arg, "-dylib_file") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // ignore for snapshot because a stub dylib will be created in the snapshot
+ snapshotArgCount = 0;
++#endif
+ addDylibOverride(argv[++i]);
+ }
+ // What to expand @executable_path to if found in dependent dylibs
+@@ -2363,7 +2415,9 @@
+ }
+ // ??? Deprecate when we get rid of basing at build time.
+ else if ( strcmp(arg, "-seg_addr_table") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ const char* name = argv[++i];
+ if ( name == NULL )
+ throw "-seg_addr_table missing argument";
+@@ -2427,7 +2481,9 @@
+ i += 2;
+ }
+ else if ( strcmp(arg, "-bundle_loader") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ fBundleLoader = argv[++i];
+ if ( (fBundleLoader == NULL) || (fBundleLoader[0] == '-') )
+ throw "-bundle_loader missing <path>";
+@@ -2659,7 +2715,9 @@
+ // previously handled by buildSearchPaths()
+ }
+ else if ( strcmp(arg, "-syslibroot") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ ++i;
+ // previously handled by buildSearchPaths()
+ }
+@@ -2670,7 +2728,9 @@
+ fUUIDMode = kUUIDRandom;
+ }
+ else if ( strcmp(arg, "-dtrace") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ const char* name = argv[++i];
+ if ( name == NULL )
+ throw "-dtrace missing argument";
+@@ -2693,7 +2753,9 @@
+ fAliases.push_back(pair);
+ }
+ else if ( strcmp(arg, "-alias_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ parseAliasFile(argv[++i]);
+ }
+ else if ( strcmp(arg, "-save-temps") == 0 ) {
+@@ -2724,48 +2786,60 @@
+ fDisablePositionIndependentExecutable = true;
+ }
+ else if ( strncmp(arg, "-reexport-l", 11) == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[11], true);
+ info.options.fReExport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-reexport_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFile(argv[++i]);
+ info.options.fReExport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-reexport_framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.options.fReExport = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strncmp(arg, "-upward-l", 9) == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findLibrary(&arg[9], true);
+ info.options.fUpward = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-upward_library") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFile(argv[++i]);
+ info.options.fUpward = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+ addLibrary(info);
+ }
+ else if ( strcmp(arg, "-upward_framework") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ // SNAPSHOT FIXME: what should we do for link snapshots? (ignore for now)
+ snapshotArgCount = 0;
++#endif
+ FileInfo info = findFramework(argv[++i]);
+ info.options.fUpward = true;
+ info.ordinal = ld::File::Ordinal::makeArgOrdinal((uint16_t)i);
+@@ -2819,7 +2893,9 @@
+ fMarkDeadStrippableDylib = true;
+ }
+ else if ( strcmp(arg, "-exported_symbols_order") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ loadSymbolOrderFile(argv[++i], fExportSymbolsOrder);
+ }
+ else if ( strcmp(arg, "-no_compact_linkedit") == 0 ) {
+@@ -2911,11 +2987,15 @@
+ fObjcCategoryMerging = false;
+ }
+ else if ( strcmp(arg, "-force_symbols_weak_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ loadExportFile(argv[++i], "-force_symbols_weak_list", fForceWeakSymbols);
+ }
+ else if ( strcmp(arg, "-force_symbols_not_weak_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ loadExportFile(argv[++i], "-force_symbols_not_weak_list", fForceNotWeakSymbols);
+ }
+ else if ( strcmp(arg, "-force_symbol_weak") == 0 ) {
+@@ -2931,7 +3011,9 @@
+ fForceNotWeakSymbols.insert(symbol);
+ }
+ else if ( strcmp(arg, "-reexported_symbols_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ if ( fExportMode == kExportSome )
+ throw "can't use -exported_symbols_list and -reexported_symbols_list";
+ loadExportFile(argv[++i], "-reexported_symbols_list", fReExportSymbols);
+@@ -2947,6 +3029,7 @@
+ else if ( strcmp(arg, "-page_align_data_atoms") == 0 ) {
+ fPageAlignDataAtoms = true;
+ }
++#ifdef SUPPORT_SNAPSHOTS
+ else if (strcmp(arg, "-debug_snapshot") == 0) {
+ fLinkSnapshot.setSnapshotMode(Snapshot::SNAPSHOT_DEBUG);
+ fSnapshotRequested = true;
+@@ -2959,6 +3042,7 @@
+ fLinkSnapshot.setSnapshotPath(path);
+ fSnapshotRequested = true;
+ }
++#endif
+ else if ( strcmp(arg, "-new_main") == 0 ) {
+ fEntryPointLoadCommandForceOn = true;
+ }
+@@ -2993,7 +3077,9 @@
+ fKextsUseStubs = true;
+ }
+ else if ( strcmp(argv[i], "-dependency_info") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotArgCount = 0;
++#endif
+ ++i;
+ // previously handled by buildSearchPaths()
+ }
+@@ -3001,7 +3087,9 @@
+ fExportDynamic = true;
+ }
+ else if ( strcmp(arg, "-force_symbols_coalesce_list") == 0 ) {
++#ifdef SUPPORT_SNAPSHOTS
+ snapshotFileArgIndex = 1;
++#endif
+ loadExportFile(argv[++i], "-force_symbols_coalesce_list", fForceCoalesceSymbols);
+ }
+ else if ( strcmp(arg, "-add_linker_option") == 0 ) {
+@@ -3158,10 +3246,12 @@
+ throwf("unknown option: %s", arg);
+ }
+
++#ifdef SUPPORT_SNAPSHOTS
+ if (snapshotArgCount == -1)
+ snapshotArgCount = i-snapshotArgIndex+1;
+ if (snapshotArgCount > 0)
+ fLinkSnapshot.addSnapshotLinkArg(snapshotArgIndex, snapshotArgCount, snapshotFileArgIndex);
++#endif
+ }
+ else {
+ FileInfo info = findFile(arg);
+@@ -3180,8 +3270,10 @@
+ addLibrary(info);
+ }
+
++#ifdef SUPPORT_SNAPSHOTS
+ if (fSnapshotRequested)
+ fLinkSnapshot.createSnapshot();
++#endif
+ }
+
+
+@@ -3452,6 +3544,7 @@
+ if ( customDyldPath != NULL )
+ fDyldInstallPath = customDyldPath;
+
++#ifdef SUPPORT_SNAPSHOTS
+ const char* debugArchivePath = getenv("LD_DEBUG_SNAPSHOT");
+ if (debugArchivePath != NULL) {
+ fLinkSnapshot.setSnapshotMode(Snapshot::SNAPSHOT_DEBUG);
+@@ -3459,6 +3552,7 @@
+ fLinkSnapshot.setSnapshotPath(debugArchivePath);
+ fSnapshotRequested = true;
+ }
++#endif
+
+ const char* pipeFdString = getenv("LD_PIPELINE_FIFO");
+ if (pipeFdString != NULL) {
+@@ -4351,7 +4445,9 @@
+ if ( strcmp(&lastSlash[1], subUmbrella) == 0 ) {
+ info.options.fReExport = true;
+ found = true;
++#ifdef SUPPORT_SNAPSHOTS
+ fLinkSnapshot.recordSubUmbrella(info.path);
++#endif
+ break;
+ }
+ }
+@@ -4374,7 +4470,9 @@
+ if ( strncmp(&lastSlash[1], subLibrary, dot-lastSlash-1) == 0 ) {
+ info.options.fReExport = true;
+ found = true;
++#ifdef SUPPORT_SNAPSHOTS
+ fLinkSnapshot.recordSubLibrary(info.path);
++#endif
+ break;
+ }
+ }
+--- ld64-241.9/src/ld/Options.h.orig 2015-01-16 15:26:32.000000000 -0800
++++ ld64-241.9/src/ld/Options.h 2015-01-16 15:26:54.000000000 -0800
+@@ -48,7 +48,9 @@
+ extern void throwf (const char* format, ...) __attribute__ ((noreturn,format(printf, 1, 2)));
+ extern void warning(const char* format, ...) __attribute__((format(printf, 1, 2)));
+
++#ifdef SUPPORT_SNAPSHOTS
+ class Snapshot;
++#endif
+
+ class LibraryOptions
+ {
+@@ -379,7 +381,9 @@
+ bool forceWeakNonWildCard(const char* symbolName) const;
+ bool forceNotWeakNonWildcard(const char* symbolName) const;
+ bool forceCoalesce(const char* symbolName) const;
++#ifdef SUPPORT_SNAPSHOTS
+ Snapshot& snapshot() const { return fLinkSnapshot; }
++#endif
+ bool errorBecauseOfWarnings() const;
+ bool needsThreadLoadCommand() const { return fNeedsThreadLoadCommand; }
+ bool needsEntryPointLoadCommand() const { return fEntryPointLoadCommand; }
+@@ -677,8 +681,10 @@
+ std::vector<SymbolsMove> fSymbolsMovesCode;
+ std::vector<SymbolsMove> fSymbolsMovesZeroFill;
+ bool fSaveTempFiles;
++#ifdef SUPPORT_SNAPSHOTS
+ mutable Snapshot fLinkSnapshot;
+ bool fSnapshotRequested;
++#endif
+ const char* fPipelineFifo;
+ const char* fDependencyInfoPath;
+ mutable int fDependencyFileDescriptor;
+--- ld64-241.9/src/ld/Snapshot.cpp.orig 2014-09-10 15:24:46.000000000 -0700
++++ ld64-241.9/src/ld/Snapshot.cpp 2015-01-16 15:26:54.000000000 -0800
+@@ -6,6 +6,7 @@
+ // Copyright (c) 2011 Apple Inc. All rights reserved.
+ //
+
++#ifdef SUPPORT_SNAPSHOTS
+ #include <string.h>
+ #include <unistd.h>
+ #include <stdio.h>
+@@ -536,3 +538,5 @@
+ }
+ }
+ }
++
++#endif /* SUPPORT_SNAPSHOTS */
+--- ld64-236.3/src/ld/Snapshot.h.orig 2015-01-23 07:59:55.000000000 +0100
++++ ld64-236.3/src/ld/Snapshot.h 2015-01-23 07:58:14.000000000 +0100
+@@ -8,6 +8,8 @@
+
+ #ifndef ld64_Snapshot_h
+ #define ld64_Snapshot_h
++
++#ifdef SUPPORT_SNAPSHOTS
+ #include <stdint.h>
+ #include <string.h>
+ #include <map>
+@@ -151,3 +153,5 @@
+ };
+
+ #endif
++
++#endif
diff --git a/sys-devel/binutils-apple/files/ld64-241.9-register-names.patch b/sys-devel/binutils-apple/files/ld64-241.9-register-names.patch
new file mode 100644
index 000000000000..6b855e5883bd
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-241.9-register-names.patch
@@ -0,0 +1,50 @@
+Force use of old register names on old OS X (< 10.5).
+
+diff -ur ld64-241.9/src/ld/parsers/libunwind/Registers.hpp ld64-241.9/src/ld/parsers/libunwind/Registers.hpp
+--- ld64-241.9/src/ld/parsers/libunwind/Registers.hpp 2014-09-11 00:24:46.000000000 +0200
++++ ld64-241.9/src/ld/parsers/libunwind/Registers.hpp 2015-01-22 22:16:23.000000000 +0100
+@@ -40,6 +40,44 @@
+ #include "libunwind.h"
+ #include "InternalMacros.h"
+
++#include <AvailabilityMacros.h>
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
++/* member names of i386_thread_state and x86_thread_state64 have changed and
++ * default of __DARWIN_UNIX03 activating those new names as well. Instead of
++ * defining __DARWIN_UNIX03 with all its unknown consequences, we use defines
++ * to make our source use the old names on an old system. */
++
++#define __esp esp
++#define __eip eip
++#define __ebp ebp
++#define __ebx ebx
++#define __ecx ecx
++#define __edx edx
++#define __esi esi
++#define __edi edi
++#define __esp esp
++#define __eax eax
++#define __rip rip
++#define __rsp rsp
++#define __rax rax
++#define __rdx rdx
++#define __rcx rcx
++#define __rbx rbx
++#define __rsi rsi
++#define __rdi rdi
++#define __rbp rbp
++#define __rsp rsp
++#define __r8 r8
++#define __r9 r9
++#define __r10 r10
++#define __r11 r11
++#define __r12 r12
++#define __r13 r13
++#define __r14 r14
++#define __r15 r15
++#endif
++
+ namespace libunwind {
+
+
diff --git a/sys-devel/binutils-apple/files/ld64-95.2.12-Makefile b/sys-devel/binutils-apple/files/ld64-95.2.12-Makefile
new file mode 100644
index 000000000000..8016434d3849
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-95.2.12-Makefile
@@ -0,0 +1,26 @@
+CPPFLAGS += -Iinclude -Iabstraction -Ild -Iother -I.
+
+# dropped machocheck due to compilation failures
+all: rebase unwinddump dyldinfo ObjectDump ld64
+
+libprunetrie.a: other/PruneTrie.o other/prune_trie.h
+ $(AR) -s -r -c libprunetrie.a other/PruneTrie.o
+
+ld64: libprunetrie.a ld/ld.o ld/Options.o ld/debugline.o version.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+rebase: other/rebase.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+dyldinfo: other/dyldinfo.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+unwinddump: other/unwinddump.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+ObjectDump: other/ObjectDump.o ld/debugline.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
+machocheck: other/machochecker.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
+
diff --git a/sys-devel/binutils-apple/files/ld64-95.2.12-darwin8-no-mlong-branch-warning.patch b/sys-devel/binutils-apple/files/ld64-95.2.12-darwin8-no-mlong-branch-warning.patch
new file mode 100644
index 000000000000..790fb97339c5
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-95.2.12-darwin8-no-mlong-branch-warning.patch
@@ -0,0 +1,15 @@
+The whole system (/usr/bin/crt0.o for example) is long-branch compiled,
+so *any* linkage operation causes this warning to be raised. Don't do
+it.
+
+--- ld/MachOReaderRelocatable.hpp
++++ ld/MachOReaderRelocatable.hpp
+@@ -4165,8 +4165,6 @@
+ if ( nextReloc->r_type() != PPC_RELOC_PAIR ) {
+ throw "PPC_RELOC_JBSR missing following pair";
+ }
+- if ( !fHasLongBranchStubs )
+- warning("object file compiled with -mlong-branch which is no longer needed. To remove this warning, recompile without -mlong-branch: %s", fPath);
+ fHasLongBranchStubs = true;
+ result = true;
+ if ( reloc->r_extern() ) {
diff --git a/sys-devel/binutils-apple/files/libunwind-30-Makefile b/sys-devel/binutils-apple/files/libunwind-30-Makefile
new file mode 100644
index 000000000000..cb502d94868d
--- /dev/null
+++ b/sys-devel/binutils-apple/files/libunwind-30-Makefile
@@ -0,0 +1,23 @@
+CPPFLAGS += -I../include
+
+all: libunwind.a
+
+OBJS=Registers.o unw_getcontext.o libuwind.o UnwindLevel1-gcc-ext.o UnwindLevel1.o Unwind-sjlj.o
+
+libunwind.a: $(OBJS)
+ libtool -static -o $@ $^
+
+libunwind.dylib: $(OBJS)
+ $(CXX) $(CXXFLAGS) -dynamiclib -single_module -compatibility_version 1 -o $@ $^
+
+Registers.o: Registers.s
+ $(CXX) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^
+
+unw_getcontext.o: unw_getcontext.s
+ $(CXX) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^
+
+libuwind.o: libuwind.cxx
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DYLDINCS) -c -o $@ $^
+
+%.o: %.c
+ $(CXX) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^
diff --git a/sys-devel/binutils-apple/metadata.xml b/sys-devel/binutils-apple/metadata.xml
new file mode 100644
index 000000000000..6b093e5ee839
--- /dev/null
+++ b/sys-devel/binutils-apple/metadata.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>prefix</herd>
+ <use>
+ <flag name="lto">Add support for Link-Time Optimization with LLVM</flag>
+ <flag name="libcxx">Add support for libcxx</flag>
+ </use>
+</pkgmetadata>