[131451] trunk/dports/devel/ld64

jeremyhu at macports.org jeremyhu at macports.org
Mon Jan 12 02:37:11 PST 2015


Revision: 131451
          https://trac.macports.org/changeset/131451
Author:   jeremyhu at macports.org
Date:     2015-01-12 02:37:11 -0800 (Mon, 12 Jan 2015)
Log Message:
-----------
ld64: Update ld64-127 to properly sort C++ initializers from archives

Modified Paths:
--------------
    trunk/dports/devel/ld64/Portfile

Added Paths:
-----------
    trunk/dports/devel/ld64/files/ld64-127-cxx_initializer_order_and_sim.patch

Modified: trunk/dports/devel/ld64/Portfile
===================================================================
--- trunk/dports/devel/ld64/Portfile	2015-01-12 10:20:12 UTC (rev 131450)
+++ trunk/dports/devel/ld64/Portfile	2015-01-12 10:37:11 UTC (rev 131451)
@@ -94,7 +94,7 @@
     # XCode 4.2
     # This was the last ld64 release that supported linking ppc executables.
     version             127.2
-    revision            8
+    revision            9
     checksums           rmd160  8ee709341549a1944732daef6ebab7ef1acfcc6e \
                         sha256  97b75547b2bd761306ab3e15ae297f01e7ab9760b922bc657f4ef72e4e052142
     supported_archs     i386 x86_64
@@ -102,7 +102,7 @@
     set makefile	"Makefile-127"
 
     patchfiles-delete   ld64-133-no-CrashReporterClient.h.patch ld64-136-i386-badAddress.patch PR-16935960.patch PR-16936488.patch
-    patchfiles-append   ld64-127-any-cctools.patch ld64-127-long-branch-warn.patch
+    patchfiles-append   ld64-127-any-cctools.patch ld64-127-long-branch-warn.patch ld64-127-cxx_initializer_order_and_sim.patch
 } elseif {${os.major} < 11} {
     # XCode 4.6
     # Until we figure out a way to better bootstrap ld64-236 on SnowLeopard or fix its build failure

Added: trunk/dports/devel/ld64/files/ld64-127-cxx_initializer_order_and_sim.patch
===================================================================
--- trunk/dports/devel/ld64/files/ld64-127-cxx_initializer_order_and_sim.patch	                        (rev 0)
+++ trunk/dports/devel/ld64/files/ld64-127-cxx_initializer_order_and_sim.patch	2015-01-12 10:37:11 UTC (rev 131451)
@@ -0,0 +1,255 @@
+diff --git ChangeLog ChangeLog
+index fd449c8..6343447 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,15 @@
++2011-11-01    Nick Kledzik    <kledzik at apple.com>
++
++	<rdar://problem/10255241> make linking for simulator more robust
++  
++2011-08-31    Nick Kledzik    <kledzik at apple.com>
++
++	<rdar://problem/8924157> [regression] C++ Initializers from archives not sorted
++	Added test case: unit-tests/test-cases/archive-init-order
++
++2011-08-11    Nick Kledzik    <kledzik at apple.com>
++
++	Fix spurious -segaddr alignment warning
+ 
+ -------- tagged ld64-127.2
+ 
+diff --git src/ld/Options.cpp src/ld/Options.cpp
+index 3f5b054..f03a36c 100644
+--- src/ld/Options.cpp
++++ src/ld/Options.cpp
+@@ -2127,9 +2127,9 @@ void Options::parse(int argc, const char* argv[])
+ 				 if ( (seg.name == NULL) || (argv[i+1] == NULL) )
+ 					throw "-segaddr missing segName Adddress";
+ 				seg.address = parseAddress(argv[++i]);
+-				uint64_t temp = seg.address & (-4096); // page align
+-				if ( (seg.address != temp)  )
+-					warning("-segaddr %s not page aligned, rounding down", seg.name);
++				uint64_t temp = ((seg.address+fSegmentAlignment-1) & (-fSegmentAlignment)); 
++				if ( seg.address != temp )
++					warning("-segaddr %s not %lld byte aligned", seg.name, fSegmentAlignment);
+ 				fCustomSegmentAddresses.push_back(seg);
+ 			}
+ 			// ??? Deprecate when we deprecate split-seg.
+@@ -3080,7 +3080,7 @@ void Options::reconfigureDefaults()
+ 			}
+ 			break;
+ 		case CPU_TYPE_X86_64:
+-			if ( fMacVersionMin < ld::mac10_4 ) {
++			if ( (fMacVersionMin < ld::mac10_4) && (fIOSVersionMin == ld::iOSVersionUnset) ) {
+ 				//warning("-macosx_version_min should be 10.4 or later for x86_64");
+ 				fMacVersionMin = ld::mac10_4;
+ 			}
+@@ -3387,29 +3387,14 @@ void Options::reconfigureDefaults()
+ 
+ 	
+ 	// only use compressed LINKEDIT for:
+-	//			x86_64 and i386 on Mac OS X 10.6 or later
+-	//			arm on iPhoneOS 3.1 or later
++	//			Mac OS X 10.6 or later
++	//			iOS 3.1 or later
+ 	if ( fMakeCompressedDyldInfo ) {
+-		switch (fArchitecture) {
+-			case CPU_TYPE_I386:
+-				if ( fIOSVersionMin != ld::iOSVersionUnset ) // simulator always uses compressed LINKEDIT
+-					break;
+-			case CPU_TYPE_X86_64:
+-				if ( fMacVersionMin < ld::mac10_6 ) 
+-					fMakeCompressedDyldInfo = false;
+-				break;
+-            case CPU_TYPE_ARM:
+-				if ( !minOS(ld::mac10_6, ld::iOS_3_1) )
+-					fMakeCompressedDyldInfo = false;
+-				break;
+-			case CPU_TYPE_POWERPC:
+-			case CPU_TYPE_POWERPC64:
+-			default:
+-				fMakeCompressedDyldInfo = false;
+-		}
++		if ( !minOS(ld::mac10_6, ld::iOS_3_1) )
++			fMakeCompressedDyldInfo = false;
+ 	}
+ 
+-		
++
+ 	// only ARM enforces that cpu-sub-types must match
+ 	if ( fArchitecture != CPU_TYPE_ARM )
+ 		fAllowCpuSubtypeMismatches = true;
+diff --git src/ld/passes/order_file.cpp src/ld/passes/order_file.cpp
+index 5e814bd..7a5daa2 100644
+--- src/ld/passes/order_file.cpp
++++ src/ld/passes/order_file.cpp
+@@ -237,6 +237,7 @@ bool Layout::orderableSection(const ld::Internal::FinalSection* sect)
+ {
+ 	// atoms in only some sections are ordered 
+ 	switch ( sect->type() ) {
++		case ld::Section::typeInitializerPointers:
+ 		case ld::Section::typeUnclassified:
+ 		case ld::Section::typeCode:
+ 		case ld::Section::typeZeroFill:
+diff --git unit-tests/test-cases/archive-init-order/Makefile unit-tests/test-cases/archive-init-order/Makefile
+new file mode 100644
+index 0000000..83364e8
+--- /dev/null
++++ unit-tests/test-cases/archive-init-order/Makefile
+@@ -0,0 +1,48 @@
++##
++# Copyright (c) 2011 Apple Inc. All rights reserved.
++#
++# @APPLE_LICENSE_HEADER_START@
++# 
++# This file contains Original Code and/or Modifications of Original Code
++# as defined in and that are subject to the Apple Public Source License
++# Version 2.0 (the 'License'). You may not use this file except in
++# compliance with the License. Please obtain a copy of the License at
++# http://www.opensource.apple.com/apsl/ and read it before using this
++# file.
++# 
++# The Original Code and all software distributed under the License are
++# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
++# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
++# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
++# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
++# Please see the License for the specific language governing rights and
++# limitations under the License.
++# 
++# @APPLE_LICENSE_HEADER_END@
++##
++TESTROOT = ../..
++include ${TESTROOT}/include/common.makefile
++
++#
++# Check the order of functions from archives.
++#
++
++run: all
++
++all:
++	${CC} ${CCFLAGS} foo.c -c -o foo.o 
++	${CC} ${CCFLAGS} foo2.c -c -o foo2.o 
++	${CC} ${CCFLAGS} foo3.c -c -o foo3.o 
++	${CC} ${CCFLAGS} bar.c -c -o bar.o 
++	${CC} ${CCFLAGS} bar2.c -c -o bar2.o 
++	${CC} ${CCFLAGS} bar3.c -c -o bar3.o 
++	libtool -static foo.o foo2.o foo3.o -o libfoo.a
++	libtool -static bar3.o bar2.o bar.o -o libbar.a
++	${CC} ${CCFLAGS} main.c -lbar -lfoo -L. -o main -Wl,-map,main.map
++	grep anon main.map | awk '{ print $$4}' > main-actual.txt
++	sort main-actual.txt > main-should.txt
++	diff main-actual.txt main-should.txt
++	${PASS_IFF_GOOD_MACHO} main
++
++clean:
++	rm -rf *.o *.a main main.map main*.txt
+diff --git unit-tests/test-cases/archive-init-order/bar.c unit-tests/test-cases/archive-init-order/bar.c
+new file mode 100644
+index 0000000..850c211
+--- /dev/null
++++ unit-tests/test-cases/archive-init-order/bar.c
+@@ -0,0 +1,4 @@
++int bar() { return 0; }
++
++__attribute__((constructor))
++void bar_init() { }
+diff --git unit-tests/test-cases/archive-init-order/bar2.c unit-tests/test-cases/archive-init-order/bar2.c
+new file mode 100644
+index 0000000..4c268ba
+--- /dev/null
++++ unit-tests/test-cases/archive-init-order/bar2.c
+@@ -0,0 +1,4 @@
++int bar2() { return 0; }
++
++__attribute__((constructor))
++void bar2_init() { }
+diff --git unit-tests/test-cases/archive-init-order/bar3.c unit-tests/test-cases/archive-init-order/bar3.c
+new file mode 100644
+index 0000000..a55167f
+--- /dev/null
++++ unit-tests/test-cases/archive-init-order/bar3.c
+@@ -0,0 +1,4 @@
++int bar3() { return 0; }
++
++__attribute__((constructor))
++void bar3_init() { }
+diff --git unit-tests/test-cases/archive-init-order/foo.c unit-tests/test-cases/archive-init-order/foo.c
+new file mode 100644
+index 0000000..6149aa1
+--- /dev/null
++++ unit-tests/test-cases/archive-init-order/foo.c
+@@ -0,0 +1,4 @@
++int foo() { return 1; }
++
++__attribute__((constructor))
++void foo_init() { }
+diff --git unit-tests/test-cases/archive-init-order/foo2.c unit-tests/test-cases/archive-init-order/foo2.c
+new file mode 100644
+index 0000000..a429fe5
+--- /dev/null
++++ unit-tests/test-cases/archive-init-order/foo2.c
+@@ -0,0 +1,4 @@
++int foo2() { return 1; }
++
++__attribute__((constructor))
++void foo2_init() { }
+diff --git unit-tests/test-cases/archive-init-order/foo3.c unit-tests/test-cases/archive-init-order/foo3.c
+new file mode 100644
+index 0000000..b097ebf
+--- /dev/null
++++ unit-tests/test-cases/archive-init-order/foo3.c
+@@ -0,0 +1,4 @@
++int foo3() { return 1; }
++
++__attribute__((constructor))
++void foo3_init() { }
+diff --git unit-tests/test-cases/archive-init-order/main.c unit-tests/test-cases/archive-init-order/main.c
+new file mode 100644
+index 0000000..242b32a
+--- /dev/null
++++ unit-tests/test-cases/archive-init-order/main.c
+@@ -0,0 +1,41 @@
++/* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*- 
++ *
++ * Copyright (c) 2011 Apple Inc. All rights reserved.
++ *
++ * @APPLE_LICENSE_HEADER_START@
++ * 
++ * This file contains Original Code and/or Modifications of Original Code
++ * as defined in and that are subject to the Apple Public Source License
++ * Version 2.0 (the 'License'). You may not use this file except in
++ * compliance with the License. Please obtain a copy of the License at
++ * http://www.opensource.apple.com/apsl/ and read it before using this
++ * file.
++ * 
++ * The Original Code and all software distributed under the License are
++ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
++ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
++ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
++ * Please see the License for the specific language governing rights and
++ * limitations under the License.
++ * 
++ * @APPLE_LICENSE_HEADER_END@
++ */
++
++extern int foo();
++extern int foo2();
++extern int foo3();
++extern int bar();
++extern int bar2();
++extern int bar3();
++
++int main()
++{
++    foo();
++    bar();
++    foo2();
++    bar2();
++    foo3();
++    bar3();
++	return 0;
++}
+\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150112/28e4fe76/attachment.html>


More information about the macports-changes mailing list