<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[131451] trunk/dports/devel/ld64</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/131451">131451</a></dd>
<dt>Author</dt> <dd>jeremyhu@macports.org</dd>
<dt>Date</dt> <dd>2015-01-12 02:37:11 -0800 (Mon, 12 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>ld64: Update ld64-127 to properly sort C++ initializers from archives</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportsdevelld64Portfile">trunk/dports/devel/ld64/Portfile</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkdportsdevelld64filesld64127cxx_initializer_order_and_simpatch">trunk/dports/devel/ld64/files/ld64-127-cxx_initializer_order_and_sim.patch</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportsdevelld64Portfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/devel/ld64/Portfile (131450 => 131451)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx">     # XCode 4.2
</span><span class="cx">     # This was the last ld64 release that supported linking ppc executables.
</span><span class="cx">     version             127.2
</span><del>-    revision            8
</del><ins>+    revision            9
</ins><span class="cx">     checksums           rmd160  8ee709341549a1944732daef6ebab7ef1acfcc6e \
</span><span class="cx">                         sha256  97b75547b2bd761306ab3e15ae297f01e7ab9760b922bc657f4ef72e4e052142
</span><span class="cx">     supported_archs     i386 x86_64
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">     set makefile        &quot;Makefile-127&quot;
</span><span class="cx"> 
</span><span class="cx">     patchfiles-delete   ld64-133-no-CrashReporterClient.h.patch ld64-136-i386-badAddress.patch PR-16935960.patch PR-16936488.patch
</span><del>-    patchfiles-append   ld64-127-any-cctools.patch ld64-127-long-branch-warn.patch
</del><ins>+    patchfiles-append   ld64-127-any-cctools.patch ld64-127-long-branch-warn.patch ld64-127-cxx_initializer_order_and_sim.patch
</ins><span class="cx"> } elseif {${os.major} &lt; 11} {
</span><span class="cx">     # XCode 4.6
</span><span class="cx">     # Until we figure out a way to better bootstrap ld64-236 on SnowLeopard or fix its build failure
</span></span></pre></div>
<a id="trunkdportsdevelld64filesld64127cxx_initializer_order_and_simpatch"></a>
<div class="addfile"><h4>Added: trunk/dports/devel/ld64/files/ld64-127-cxx_initializer_order_and_sim.patch (0 => 131451)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,255 @@
</span><ins>+diff --git ChangeLog ChangeLog
+index fd449c8..6343447 100644
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,15 @@
++2011-11-01    Nick Kledzik    &lt;kledzik@apple.com&gt;
++
++        &lt;rdar://problem/10255241&gt; make linking for simulator more robust
++  
++2011-08-31    Nick Kledzik    &lt;kledzik@apple.com&gt;
++
++        &lt;rdar://problem/8924157&gt; [regression] C++ Initializers from archives not sorted
++        Added test case: unit-tests/test-cases/archive-init-order
++
++2011-08-11    Nick Kledzik    &lt;kledzik@apple.com&gt;
++
++        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 &quot;-segaddr missing segName Adddress&quot;;
+                                 seg.address = parseAddress(argv[++i]);
+-                                uint64_t temp = seg.address &amp; (-4096); // page align
+-                                if ( (seg.address != temp)  )
+-                                        warning(&quot;-segaddr %s not page aligned, rounding down&quot;, seg.name);
++                                uint64_t temp = ((seg.address+fSegmentAlignment-1) &amp; (-fSegmentAlignment)); 
++                                if ( seg.address != temp )
++                                        warning(&quot;-segaddr %s not %lld byte aligned&quot;, 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 &lt; ld::mac10_4 ) {
++                        if ( (fMacVersionMin &lt; ld::mac10_4) &amp;&amp; (fIOSVersionMin == ld::iOSVersionUnset) ) {
+                                 //warning(&quot;-macosx_version_min should be 10.4 or later for x86_64&quot;);
+                                 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 &lt; 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-&gt;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}' &gt; main-actual.txt
++        sort main-actual.txt &gt; 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
</ins></span></pre>
</div>
</div>

</body>
</html>