@@ -690,10 +690,6 @@ template <class LP> void Writer::createLoadCommands() {
690
690
make<LCDysymtab>(symtabSection, indirectSymtabSection));
691
691
if (!config->umbrella .empty ())
692
692
in.header ->addLoadCommand (make<LCSubFramework>(config->umbrella ));
693
- if (functionStartsSection)
694
- in.header ->addLoadCommand (make<LCFunctionStarts>(functionStartsSection));
695
- if (dataInCodeSection)
696
- in.header ->addLoadCommand (make<LCDataInCode>(dataInCodeSection));
697
693
if (config->emitEncryptionInfo )
698
694
in.header ->addLoadCommand (make<LCEncryptionInfo<LP>>());
699
695
for (StringRef path : config->runtimePaths )
@@ -702,7 +698,6 @@ template <class LP> void Writer::createLoadCommands() {
702
698
switch (config->outputType ) {
703
699
case MH_EXECUTE:
704
700
in.header ->addLoadCommand (make<LCLoadDylinker>());
705
- in.header ->addLoadCommand (make<LCMain>());
706
701
break ;
707
702
case MH_DYLIB:
708
703
in.header ->addLoadCommand (make<LCDylib>(LC_ID_DYLIB, config->installName ,
@@ -723,6 +718,10 @@ template <class LP> void Writer::createLoadCommands() {
723
718
else
724
719
in.header ->addLoadCommand (make<LCMinVersion>(config->platformInfo ));
725
720
721
+ // This is down here to match ld64's load command order.
722
+ if (config->outputType == MH_EXECUTE)
723
+ in.header ->addLoadCommand (make<LCMain>());
724
+
726
725
int64_t dylibOrdinal = 1 ;
727
726
DenseMap<StringRef, int64_t > ordinalForInstallName;
728
727
for (InputFile *file : inputFiles) {
@@ -789,6 +788,10 @@ template <class LP> void Writer::createLoadCommands() {
789
788
}
790
789
}
791
790
791
+ if (functionStartsSection)
792
+ in.header ->addLoadCommand (make<LCFunctionStarts>(functionStartsSection));
793
+ if (dataInCodeSection)
794
+ in.header ->addLoadCommand (make<LCDataInCode>(dataInCodeSection));
792
795
if (codeSignatureSection)
793
796
in.header ->addLoadCommand (make<LCCodeSignature>(codeSignatureSection));
794
797
0 commit comments