diff options
author | Fabian Groffen <grobian@gentoo.org> | 2015-01-27 06:59:53 +0000 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2015-01-27 06:59:53 +0000 |
commit | cf884bed6ec1967a641eb2b66f94af35576d6371 (patch) | |
tree | c26cb8532b203ce0c13ad47653850678f5b4bd4c /sys-devel | |
parent | Version bump. Add ruby22. Avoid dependency on rake-compiler completely. (diff) | |
download | gentoo-2-cf884bed6ec1967a641eb2b66f94af35576d6371.tar.gz gentoo-2-cf884bed6ec1967a641eb2b66f94af35576d6371.tar.bz2 gentoo-2-cf884bed6ec1967a641eb2b66f94af35576d6371.zip |
Version bumps thanks to the hard work by Michael Weisner in bug #473068
(Portage version: 2.2.14-prefix/cvs/SunOS i386, signed Manifest commit with key 0x5F75F607C5C74E89)
Diffstat (limited to 'sys-devel')
34 files changed, 7676 insertions, 2 deletions
diff --git a/sys-devel/binutils-apple/ChangeLog b/sys-devel/binutils-apple/ChangeLog index 9f30910c63cd..7446dd7110fc 100644 --- a/sys-devel/binutils-apple/ChangeLog +++ b/sys-devel/binutils-apple/ChangeLog @@ -1,6 +1,35 @@ # ChangeLog for sys-devel/binutils-apple -# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/ChangeLog,v 1.35 2013/11/12 19:24:02 grobian Exp $ +# Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/ChangeLog,v 1.36 2015/01/27 06:59:53 grobian Exp $ + +*binutils-apple-6.1 (27 Jan 2015) +*binutils-apple-5.1 (27 Jan 2015) + + 27 Jan 2015; Fabian Groffen <grobian@gentoo.org> +binutils-apple-5.1.ebuild, + +binutils-apple-6.1.ebuild, +files/binutils-apple-4.5-as.patch, + +files/binutils-apple-5.1-as-dir.patch, + +files/binutils-apple-5.1-constant-types.patch, + +files/binutils-apple-5.1-extraneous-includes.patch, + +files/binutils-apple-5.1-nolto.patch, + +files/binutils-apple-5.1-otool-stdc.patch, + +files/binutils-apple-5.1-ranlib.patch, + +files/binutils-apple-5.1-strnlen.patch, +files/cctools-839-intel-retf.patch, + +files/cctools-839-lto.patch, +files/ld64-136-Makefile, + +files/ld64-136-compile_stubs.h, +files/ld64-236.3-Makefile, + +files/ld64-236.3-arm64-fixup.patch, +files/ld64-236.3-constant-types.patch, + +files/ld64-236.3-crashreporter.patch, +files/ld64-236.3-gcc.patch, + +files/ld64-236.3-missing-cputypes.patch, +files/ld64-236.3-noarm.patch, + +files/ld64-236.3-nolto.patch, +files/ld64-236.3-noppc.patch, + +files/ld64-236.3-nosnapshots.patch, +files/ld64-241.9-arm64-cputype.patch, + +files/ld64-241.9-atomic-volatile.patch, +files/ld64-241.9-cc_md5.patch, + +files/ld64-241.9-extraneous-includes.patch, +files/ld64-241.9-gcc.patch, + +files/ld64-241.9-get-comm-align.patch, +files/ld64-241.9-noarm.patch, + +files/ld64-241.9-nosnapshots.patch, +files/ld64-241.9-register-names.patch, + files/binutils-apple-3.1.1-libtool-ranlib.patch, + files/binutils-apple-3.1.1-no-headers.patch, + files/binutils-apple-4.0-no-oss-dir.patch, + files/ld64-123.2-debug-backtrace.patch: + Version bumps thanks to the hard work by Michael Weisner in bug #473068 12 Nov 2013; Fabian Groffen <grobian@gentoo.org> +files/ld64-128.2-stdlib.patch, binutils-apple-4.3.ebuild: 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..bf7cbead012c --- /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 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/binutils-apple-5.1.ebuild,v 1.1 2015/01/27 06:59:53 grobian Exp $ + +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 ) + test? ( >=dev-lang/perl-5.8.8 ) + libcxx? ( sys-libs/libcxx-apple )" +DEPEND="${RDEPEND} + || ( >=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-} != ${CATEGORY} ]] ; 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} -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} -ge 10 ] && \ + append-cppflags -DSUPPORT_SNAPSHOTS + + CCTOOLS_OFLAG= + if [ ${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..8d0156799c54 --- /dev/null +++ b/sys-devel/binutils-apple/binutils-apple-6.1.ebuild @@ -0,0 +1,354 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/binutils-apple-6.1.ebuild,v 1.1 2015/01/27 06:59:53 grobian Exp $ + +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 ) + test? ( >=dev-lang/perl-5.8.8 ) + libcxx? ( sys-libs/libcxx-apple )" +DEPEND="${RDEPEND} + || ( >=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-} != ${CATEGORY} ]] ; 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 + + # 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} -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} -ge 10 ] && \ + append-cppflags -DSUPPORT_SNAPSHOTS + + CCTOOLS_OFLAG= + if [ ${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/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/cctools-839-lto.patch b/sys-devel/binutils-apple/files/cctools-839-lto.patch new file mode 100644 index 000000000000..4c3522fce924 --- /dev/null +++ b/sys-devel/binutils-apple/files/cctools-839-lto.patch @@ -0,0 +1,42 @@ +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,17 @@ void *mod) + lto_dispose(mod); + } + ++#else ++ ++#include <stdlib.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/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..85ca347b2b4f --- /dev/null +++ b/sys-devel/binutils-apple/files/ld64-236.3-nolto.patch @@ -0,0 +1,220 @@ +Allow to fully disable LTO. + +--- ./src/ld/InputFiles.cpp.lto 2014-04-05 00:42:29.000000000 +0200 ++++ ./src/ld/InputFiles.cpp 2014-08-29 09:01:04.000000000 +0200 +@@ -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) ) { +--- ./src/ld/ld.cpp.lto 2014-04-05 00:42:29.000000000 +0200 ++++ ./src/ld/ld.cpp 2014-08-29 09:00:29.000000000 +0200 +@@ -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/Options.cpp.lto 2014-04-05 00:42:29.000000000 +0200 ++++ ./src/ld/Options.cpp 2014-08-29 09:00:29.000000000 +0200 +@@ -42,10 +42,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; +@@ -3082,10 +3086,12 @@ + 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); + exit(0); ++#endif + } + } + else if ( strcmp(argv[i], "-syslibroot") == 0 ) { +--- ./src/ld/parsers/archive_file.cpp.lto 2014-04-05 00:42:29.000000000 +0200 ++++ ./src/ld/parsers/archive_file.cpp 2014-08-29 09:00:29.000000000 +0200 +@@ -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 +@@ -232,11 +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 + + + +@@ -257,7 +263,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; +@@ -378,6 +388,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, +@@ -387,6 +398,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/ld/Resolver.cpp.lto 2014-04-05 00:42:29.000000000 +0200 ++++ ./src/ld/Resolver.cpp 2014-08-29 09:00:29.000000000 +0200 +@@ -56,7 +56,9 @@ + #include "InputFiles.h" + #include "SymbolTable.h" + #include "Resolver.h" ++#ifdef LTO + #include "parsers/lto_file.h" ++#endif + + + namespace ld { +@@ -1436,6 +1438,7 @@ + + void Resolver::linkTimeOptimize() + { ++#ifdef LTO + // only do work here if some llvm obj files where loaded + if ( ! _haveLLVMObjs ) + return; +@@ -1533,6 +1536,9 @@ + // check new code does not override some dylib + this->checkDylibSymbolCollisions(); + } ++#else ++ return; ++#endif + } + + +--- ./src/other/ObjectDump.cpp.lto 2014-04-05 00:42:29.000000000 +0200 ++++ ./src/other/ObjectDump.cpp 2014-08-29 09:01:34.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; +@@ -1245,10 +1247,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-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 { + + |