-
Notifications
You must be signed in to change notification settings - Fork 11
/
ld.hpp
1453 lines (1321 loc) · 60.6 KB
/
ld.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (c) 2005-2010 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@
*/
#ifndef __LD_HPP__
#define __LD_HPP__
#include <stdint.h>
#include <math.h>
#include <unistd.h>
#include <assert.h>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <unordered_set>
#include "configure.h"
#include "PlatformSupport.h"
//FIXME: Only needed until we move VersionSet into PlatformSupport
class Options;
namespace ld {
//
// minumum OS versions
//
struct PlatformVersion {
Platform platform;
uint32_t minVersion;
uint32_t sdkVersion;
PlatformVersion(Platform P) : PlatformVersion(P, 0, 0) {}
PlatformVersion(Platform P, uint32_t V) : PlatformVersion(P, V, V) {}
PlatformVersion(Platform P, uint32_t M, uint32_t S) : platform(P), minVersion(M), sdkVersion(S) {}
bool operator==(const PlatformVersion& other) const { return platform == other.platform; }
bool operator<(const PlatformVersion& other) const { return platform < other.platform; }
};
struct VersionSet {
private:
std::set<PlatformVersion> _versions;
public:
VersionSet() {}
VersionSet(const std::set<PlatformVersion>& V) : _versions(V) {}
void insert(PlatformVersion platformVersion) {
assert(_versions.find(platformVersion) == _versions.end());
_versions.insert(platformVersion);
}
void erase(const Platform& platform) {
auto i = std::find_if(_versions.begin(), _versions.end(), [&platform](const PlatformVersion& version) {
return platform == version.platform;
});
if (i == _versions.end()) return;
_versions.erase(i);
}
void updateMinVersion(const Platform& platform, uint32_t minVersion) {
auto i = std::find_if(_versions.begin(), _versions.end(), [&platform](const PlatformVersion& version) {
return platform == version.platform;
});
if (i == _versions.end()) return;
auto newVersion = *i;
newVersion.minVersion = minVersion;
newVersion.sdkVersion = i->sdkVersion;
_versions.erase(i);
_versions.insert(newVersion);
}
void updateSDKVersion(const Platform& platform, uint32_t sdkVersion) {
auto i = std::find_if(_versions.begin(), _versions.end(), [&platform](const PlatformVersion& version) {
return platform == version.platform;
});
if (i == _versions.end()) return;
auto newVersion = *i;
newVersion.minVersion = i->minVersion;
newVersion.sdkVersion = sdkVersion;
_versions.erase(i);
_versions.insert(newVersion);
}
size_t count() const { return _versions.size(); }
size_t empty() const { return _versions.empty(); }
void clear() { _versions.clear(); }
void forEach(void (^callback)(ld::Platform platform, uint32_t minVersion, uint32_t sdkVersion, bool &stop)) const {
bool stop = false;
for (const auto& version : _versions) {
callback(version.platform, version.minVersion, version.sdkVersion, stop);
if (stop)
return;
}
}
bool contains(ld::Platform platform) const {
auto i = std::find_if(_versions.begin(), _versions.end(), [&platform](const PlatformVersion& version) {
return platform == version.platform;
});
return (i != _versions.end());
}
bool contains(const ld::PlatformSet& platforms) const {
__block bool retval = true;
forEach(^(ld::Platform platform, uint32_t minVersion, uint32_t sdkVersion, bool &stop) {
if (platforms.find(platform) == platforms.end()) {
stop = true;
retval = false;
}
});
return retval;
}
uint32_t minOS(ld::Platform platform) const {
ld::Platform base = basePlatform(platform);
for (const auto& version : _versions) {
if (basePlatform(version.platform) == base) {
return version.minVersion;
}
}
return 0;
}
bool minOS(const PlatformVersion& version) const {
return minOS(version.platform) >= version.minVersion;
}
bool minOS(const ld::VersionSet& requiredMinVersions) const {
__block bool retval = true;
forEach(^(ld::Platform platform, uint32_t minVersion, uint32_t sdkVersion, bool &stop) {
if (!requiredMinVersions.contains(basePlatform(platform)))
return;
if (minVersion < requiredMinVersions.minOS(basePlatform(platform))) {
stop = true;
retval = false;
}
});
return retval;
}
std::string to_str() const {
std::string retval;
auto appendPlatform = [&](const std::string& platform) {
if (retval.empty()) {
retval = platform;
} else {
retval += "/";
retval += platform;
}
};
forEach(^(ld::Platform platform, uint32_t minVersion, uint32_t sdkVersion, bool &stop) {
appendPlatform(nameFromPlatform(platform));
});
return retval;
}
void checkObjectCrosslink(const VersionSet& objectPlatforms, const std::string& targetPath, bool internalSDK,
bool bitcode, bool platformMismatchesAreWarning) const;
void checkDylibCrosslink(const VersionSet& dylibPlatforms, const std::string& targetPath,
const std::string& dylibType, bool internalSDK, bool indirectDylib,
bool bitcode, bool isUnzipperedTwin, const char* installName,
bool fromSDK, bool platformMismatchesAreWarning) const;
bool operator==(const VersionSet& other) const { return _versions == other._versions; }
bool operator<(const VersionSet& other) const { return _versions < other._versions; }
};
static const PlatformVersion mac10_4 (Platform::macOS, 0x000A0400);
static const PlatformVersion mac10_5 (Platform::macOS, 0x000A0500);
static const PlatformVersion mac10_6 (Platform::macOS, 0x000A0600);
static const PlatformVersion mac10_7 (Platform::macOS, 0x000A0700);
static const PlatformVersion mac10_8 (Platform::macOS, 0x000A0800);
static const PlatformVersion mac10_9 (Platform::macOS, 0x000A0900);
static const PlatformVersion mac10_12 (Platform::macOS, 0x000A0C00);
static const PlatformVersion mac10_14 (Platform::macOS, 0x000A0E00);
static const PlatformVersion mac10_15 (Platform::macOS, 0x000A0F00);
static const PlatformVersion mac10_16 (Platform::macOS, 0x000A1000);
static const PlatformVersion mac11_0 (Platform::macOS, 0x000B0000);
static const PlatformVersion mac12_0 (Platform::macOS, 0x000C0000);
static const PlatformVersion mac10_Future (Platform::macOS, 0x10000000);
static const PlatformVersion iOS_2_0 (Platform::iOS, 0x00020000);
static const PlatformVersion iOS_3_1 (Platform::iOS, 0x00030100);
static const PlatformVersion iOS_4_2 (Platform::iOS, 0x00040200);
static const PlatformVersion iOS_4_3 (Platform::iOS, 0x00040300);
static const PlatformVersion iOS_5_0 (Platform::iOS, 0x00050000);
static const PlatformVersion iOS_6_0 (Platform::iOS, 0x00060000);
static const PlatformVersion iOS_7_0 (Platform::iOS, 0x00070000);
static const PlatformVersion iOS_8_0 (Platform::iOS, 0x00080000);
static const PlatformVersion iOS_9_0 (Platform::iOS, 0x00090000);
static const PlatformVersion iOS_10_0 (Platform::iOS, 0x000A0000);
static const PlatformVersion iOS_11_0 (Platform::iOS, 0x000B0000);
static const PlatformVersion iOS_12_0 (Platform::iOS, 0x000C0000);
static const PlatformVersion iOS_13_0 (Platform::iOS, 0x000D0000);
static const PlatformVersion iOS_14_0 (Platform::iOS, 0x000E0000);
static const PlatformVersion iOS_15_0 (Platform::iOS, 0x000F0000);
static const PlatformVersion iOS_Future (Platform::iOS, 0x10000000);
static const PlatformVersion watchOS_1_0 (Platform::watchOS, 0x00010000);
static const PlatformVersion watchOS_2_0 (Platform::watchOS, 0x00020000);
static const PlatformVersion watchOS_5_0 (Platform::watchOS, 0x00050000);
static const PlatformVersion watchOS_6_0 (Platform::watchOS, 0x00060000);
static const PlatformVersion watchOS_7_0 (Platform::watchOS, 0x00070000);
static const PlatformVersion watchOS_8_0 (Platform::watchOS, 0x00080000);
static const PlatformVersion watchOS_Future (Platform::watchOS, 0x10000000);
static const PlatformVersion tvOS_9_0 (Platform::tvOS, 0x00090000);
static const PlatformVersion tvOS_12_0 (Platform::tvOS, 0x000C0000);
static const PlatformVersion tvOS_13_0 (Platform::tvOS, 0x000D0000);
static const PlatformVersion tvOS_14_0 (Platform::tvOS, 0x000E0000);
static const PlatformVersion tvOS_15_0 (Platform::tvOS, 0x000F0000);
static const PlatformVersion tvOS_Future (Platform::tvOS, 0x10000000);
static const PlatformVersion bridgeOS_1_0 (Platform::bridgeOS, 0x00010000);
static const PlatformVersion bridgeOS_4_0 (Platform::bridgeOS, 0x00040000);
static const PlatformVersion bridgeOS_5_0 (Platform::bridgeOS, 0x00050000);
static const PlatformVersion bridgeOS_6_0 (Platform::bridgeOS, 0x00060000);
static const PlatformVersion bridgeOS_Future (Platform::bridgeOS, 0x10000000);
static const PlatformVersion driverKit_19_0 (Platform::driverKit, 0x00130000);
static const PlatformVersion driverKit_20_0 (Platform::driverKit, 0x00140000);
static const PlatformVersion driverKit_21_0 (Platform::driverKit, 0x00150000);
static const PlatformVersion driverKit_Future (Platform::driverKit, 0x10000000);
#if TARGET_FEATURE_REALITYOS
static const PlatformVersion realityOS_1_0 (Platform::realityOS, 0x00000001);
static const PlatformVersion realityOS_Future (Platform::realityOS, 0x10000000);
#endif // TARGET_FEATURE_REALITYOS
// Platform Sets
static const PlatformSet simulatorPlatforms ( {
Platform::iOS_simulator,
Platform::tvOS_simulator,
Platform::watchOS_simulator,
#if TARGET_FEATURE_REALITYOS
Platform::reality_simulator,
#endif // TARGET_FEATURE_REALITYOS
} );
//FIXME do we need to add simulatots to these?
//FIXME Are the dates correct?
static const VersionSet version2007 ({mac10_4, iOS_2_0});
static const VersionSet version2008 ({mac10_5, iOS_2_0});
static const VersionSet version2008Fall ({mac10_5, iOS_3_1});
static const VersionSet version2009 ({mac10_6, iOS_3_1});
static const VersionSet version2010 ({mac10_7, iOS_4_2});
static const VersionSet version2010Fall ({mac10_7, iOS_4_3});
static const VersionSet version2012 ({mac10_8, iOS_6_0});
static const VersionSet version2013 ({mac10_9, iOS_7_0});
static const VersionSet version2019Fall ({mac10_15, iOS_13_0, watchOS_6_0, tvOS_13_0, bridgeOS_4_0});
static const VersionSet version2020Fall ({mac10_16, iOS_14_0, watchOS_7_0, tvOS_14_0, bridgeOS_5_0});
#if TARGET_FEATURE_REALITYOS
static const VersionSet version2021Fall {{mac12_0, iOS_15_0, watchOS_8_0, tvOS_15_0, bridgeOS_6_0, realityOS_1_0}};
#else
static const VersionSet version2021Fall {{mac12_0, iOS_15_0, watchOS_8_0, tvOS_15_0, bridgeOS_6_0}};
#endif // TARGET_FEATURE_REALITYOS
static const VersionSet supportsSplitSegV2 ({mac10_12, iOS_9_0, watchOS_2_0, tvOS_9_0, driverKit_20_0});
// FIXME: Use the comment out line instead.
static const VersionSet supportsLCBuildVersion ({mac10_14, iOS_12_0, watchOS_5_0, tvOS_12_0, bridgeOS_1_0});
#if TARGET_FEATURE_REALITYOS
static const VersionSet supportsPIE ({mac10_5, iOS_4_2, realityOS_1_0});
#else
static const VersionSet supportsPIE ({mac10_5, iOS_4_2});
#endif
static const VersionSet supportsTLV ({mac10_7, iOS_9_0});
static const VersionSet supportsChainedFixups ({mac10_16, iOS_14_0, watchOS_7_0, tvOS_14_0, bridgeOS_Future});
// Forward declaration for bitcode support
class Bitcode;
//
// ld::File
//
// Abstract base class for all object or library files the linker processes.
//
// forEachAtom() iterates over the Atoms in the order they occur in the file.
//
// justInTimeforEachAtom(name) iterates over lazily created Atoms. For instance if
// File is a static library, justInTimeforEachAtom() will iterate over the base set
// of Atoms from the archive member implementing 'name'.
//
class File
{
public:
class AtomHandler {
public:
virtual ~AtomHandler() {}
virtual void doAtom(const class Atom&) = 0;
virtual void doFile(const class File&) = 0;
};
//
// ld::File::Ordinal
//
// Codifies the rules of ordering input files for symbol precedence. These are:
// - Input files listed on the command line are ordered according to their index in the argument list.
// - Input files listed in a file list are ordered first at the index of the file list argument, then
// by index in the file list
// - Input files extracted from archives are ordered using the ordinal of the archive itself plus the
// index of the object file within the archive
// - Indirect dylibs are ordered after all input files derived from the command line, in the order that
// they are discovered.
// - The LTO object file is last.
//
class Ordinal
{
private:
// The actual numeric ordinal. Lower values have higher precedence and a zero value is invalid.
// The 64 bit ordinal is broken into 4 16 bit chunks. The high 16 bits are a "partition" that
// is used to distinguish major ordinal groups: command line, indirect dylib, LTO.
// The remaining chunks are used according to the partition (see below).
uint64_t _ordinal;
Ordinal (uint64_t ordinal) : _ordinal(ordinal) {}
enum { kArgListPartition=0, kIndirectDylibPartition=1, kLTOPartition = 2, kLinkerOptionPartition = 3, InvalidParition=0xffff };
Ordinal(uint16_t partition, uint16_t majorIndex, uint16_t minorIndex, uint16_t counter) {
_ordinal = ((uint64_t)partition<<48) | ((uint64_t)majorIndex<<32) | ((uint64_t)minorIndex<<16) | ((uint64_t)counter<<0);
}
const uint16_t partition() const { return (_ordinal>>48)&0xffff; }
const uint16_t majorIndex() const { return (_ordinal>>32)&0xffff; }
const uint16_t minorIndex() const { return (_ordinal>>16)&0xffff; }
const uint16_t counter() const { return (_ordinal>>00)&0xffff; }
const Ordinal nextMajorIndex() const { assert(majorIndex() < 0xffff); return Ordinal(_ordinal+((uint64_t)1<<32)); }
const Ordinal nextMinorIndex() const { assert(minorIndex() < 0xffff); return Ordinal(_ordinal+((uint64_t)1<<16)); }
const Ordinal nextCounter() const { assert(counter() < 0xffff); return Ordinal(_ordinal+((uint64_t)1<<0)); }
public:
Ordinal() : _ordinal(0) {};
uint64_t rawValue() { return _ordinal; }
static const Ordinal NullOrdinal() { return Ordinal((uint64_t)0); }
const bool validOrdinal() const { return _ordinal != 0; }
bool operator ==(const Ordinal& rhs) const { return _ordinal == rhs._ordinal; }
bool operator !=(const Ordinal& rhs) const { return _ordinal != rhs._ordinal; }
bool operator < (const Ordinal& rhs) const { return _ordinal < rhs._ordinal; }
bool operator > (const Ordinal& rhs) const { return _ordinal > rhs._ordinal; }
// For ordinals derived from the command line args the partition is ArgListPartition
// The majorIndex is the arg index that pulls in the file, file list, or archive.
// The minorIndex is used for files pulled in by a file list and the value is the index of the file in the file list.
// The counter is used for .a files and the value is the index of the object in the archive.
// Thus, an object pulled in from a .a that was listed in a file list could use all three fields.
static const Ordinal makeArgOrdinal(uint16_t argIndex) { return Ordinal(kArgListPartition, argIndex, 0, 0); };
const Ordinal nextFileListOrdinal() const { return nextMinorIndex(); }
const Ordinal archiveOrdinalWithMemberIndex(uint16_t memberIndex) const { return Ordinal(partition(), majorIndex(), minorIndex(), memberIndex); }
// For indirect libraries the partition is IndirectDylibPartition and the counter is used or order the libraries.
static const ld::File::Ordinal indirectDylibBase() { return Ordinal(kIndirectDylibPartition, 0, 0, 0); }
const Ordinal nextIndirectDylibOrdinal() const { return nextCounter(); }
// For the LTO mach-o the partition is LTOPartition. As there is only one LTO file no other fields are needed.
static const ld::File::Ordinal LTOOrdinal() { return Ordinal(kLTOPartition, 0, 0, 0); }
// For linker options embedded in object files
static const ld::File::Ordinal linkeOptionBase() { return Ordinal(kIndirectDylibPartition, 1, 0, 0); }
const Ordinal nextLinkerOptionOrdinal() { return nextCounter(); };
};
typedef enum { Reloc, Dylib, Archive, Other } Type;
File(const char* pth, time_t modTime, Ordinal ord, Type type)
: _path(pth), _modTime(modTime), _ordinal(ord), _type(type) { }
virtual ~File() {}
const char* path() const { return _path; }
time_t modificationTime() const{ return _modTime; }
Ordinal ordinal() const { return _ordinal; }
virtual bool forEachAtom(AtomHandler&) const = 0;
virtual bool justInTimeforEachAtom(const char* name, AtomHandler&) const = 0;
virtual uint8_t swiftVersion() const { return 0; } // ABI version, now fixed
virtual uint16_t swiftLanguageVersion() const { return 0; } // language version in 4.4 format
virtual uint32_t cpuSubType() const { return 0; }
virtual uint8_t cpuSubTypeFlags() const { return 0; }
virtual uint32_t subFileCount() const { return 1; }
virtual const VersionSet& platforms() const { return _platforms; }
bool fileExists() const { return _modTime != 0; }
Type type() const { return _type; }
virtual Bitcode* getBitcode() const { return NULL; }
const char* leafName() const;
private:
const char* _path;
time_t _modTime;
const Ordinal _ordinal;
const Type _type;
// Note this is just a placeholder as platforms() needs something to return
static const VersionSet _platforms;
};
inline const char* File::leafName() const {
const char* pth = this->path();
if ( pth == NULL )
return "<internal>";
const char* lastSlash = strrchr(pth, '/');
return (lastSlash != NULL) ? lastSlash+1 : pth;
}
namespace relocatable {
//
// ld::relocatable::File
//
// Abstract base class for object files the linker processes.
//
// debugInfo() returns if the object file contains debugger information (stabs or dwarf).
//
// stabs() lazily creates a vector of Stab objects for each atom
//
// canScatterAtoms() true for all compiler generated code. Hand written assembly can opt-in
// via .subsections_via_symbols directive. When true it means the linker can break up section
// content at symbol boundaries and do optimizations like coalescing, dead code stripping, or
// apply order files.
//
// optimize() used by libLTO to lazily generate code from llvm bit-code files
//
class File : public ld::File
{
public:
enum DebugInfoKind { kDebugInfoNone=0, kDebugInfoStabs=1, kDebugInfoDwarf=2, kDebugInfoStabsUUID=3 };
enum SourceKind { kSourceUnknown=0, kSourceObj, kSourceLTO, kSourceArchive, kSourceCompilerArchive };
struct Stab {
const class Atom* atom;
uint8_t type;
uint8_t other;
uint16_t desc;
uint32_t value;
const char* string;
};
typedef const std::vector< std::vector<const char*> > LinkerOptionsList;
typedef std::vector<std::pair<uint32_t,uint32_t>> ToolVersionList;
struct AstTimeAndPath { uint64_t time; std::string path; };
File(const char* pth, time_t modTime, Ordinal ord)
: ld::File(pth, modTime, ord, Reloc) { }
virtual ~File() {}
virtual DebugInfoKind debugInfo() const = 0;
virtual const char* debugInfoPath() const { return path(); }
virtual time_t debugInfoModificationTime() const { return modificationTime(); }
virtual const std::vector<Stab>* stabs() const = 0;
virtual bool canScatterAtoms() const = 0;
virtual bool hasLongBranchStubs() { return false; }
virtual bool hasllvmProfiling() const { return false; }
virtual bool hasObjC() const { return false; }
virtual bool objcHasCategoryClassPropertiesField() const { return false; }
virtual LinkerOptionsList* linkerOptions() const = 0;
virtual const ToolVersionList& toolVersions() const = 0;
virtual SourceKind sourceKind() const { return kSourceUnknown; }
virtual const uint8_t* fileContent() const { return nullptr; }
virtual const std::vector<AstTimeAndPath>* astFiles() const { return nullptr; }
virtual void forEachLtoSymbol(void (^handler)(const char*)) const { }
};
} // namespace relocatable
namespace dylib {
//
// ld::dylib::File
//
// Abstract base class for dynamic shared libraries read by the linker processes.
//
class File : public ld::File
{
public:
class DylibHandler
{
public:
virtual ~DylibHandler() {}
virtual File* findDylib(const char* installPath, const ld::dylib::File* fromDylib, bool speculative) = 0;
};
File(const char* pth, time_t modTime, Ordinal ord)
: ld::File(pth, modTime, ord, Dylib), _dylibInstallPath(NULL), _frameworkName(NULL),
_dylibTimeStamp(0), _dylibCurrentVersion(0), _dylibCompatibilityVersion(0),
_explicitlyLinked(false), _implicitlyLinked(false), _speculativelyLoaded(false),
_forcedWeakLinked(false), _needed(false), _reExported(false),
_upward(false), _dead(false) { }
const char* installPath() const { return _dylibInstallPath; }
const char* frameworkName() const { return _frameworkName; }
uint32_t timestamp() const { return _dylibTimeStamp; }
uint32_t currentVersion() const { return _dylibCurrentVersion; }
uint32_t compatibilityVersion() const{ return _dylibCompatibilityVersion; }
void setExplicitlyLinked() { _explicitlyLinked = true; }
bool explicitlyLinked() const { return _explicitlyLinked; }
void setImplicitlyLinked() { _implicitlyLinked = true; }
bool implicitlyLinked() const { return _implicitlyLinked; }
void setSpeculativelyLoaded() { _speculativelyLoaded = true; }
bool speculativelyLoaded() const { return _speculativelyLoaded; }
// attributes of how dylib will be used when linked
void setForcedWeakLinked() { _forcedWeakLinked = true; }
bool forcedWeakLinked() const { return _forcedWeakLinked; }
void setNeededDylib() { _needed = true; }
bool neededDylib() const { return _needed; }
void setWillBeReExported() { _reExported = true; }
bool willBeReExported() const { return _reExported; }
void setWillBeUpwardDylib() { _upward = true; }
bool willBeUpwardDylib() const { return _upward; }
void setWillBeRemoved(bool value) { _dead = value; }
bool willRemoved() const { return _dead; }
virtual void processIndirectLibraries(DylibHandler* handler, bool addImplicitDylibs) = 0;
virtual bool providedExportAtom() const = 0;
virtual const char* parentUmbrella() const = 0;
virtual const std::vector<const char*>* allowableClients() const = 0;
virtual const std::vector<const char*>& rpaths() const = 0;
virtual bool hasWeakExternals() const = 0;
virtual bool deadStrippable() const = 0;
virtual bool hasWeakDefinition(const char* name) const = 0;
virtual bool hasDefinition(const char* name) const = 0;
virtual bool hasPublicInstallName() const = 0;
virtual bool allSymbolsAreWeakImported() const = 0;
virtual bool installPathVersionSpecific() const { return false; }
virtual bool appExtensionSafe() const = 0;
virtual void forEachExportedSymbol(void (^handler)(const char* symbolName, bool weakDef)) const = 0;
virtual bool hasReExportedDependentsThatProvidedExportAtom() const { return false; }
virtual bool isUnzipperedTwin() const { return false; }
public:
const char* _dylibInstallPath;
const char* _frameworkName;
uint32_t _dylibTimeStamp;
uint32_t _dylibCurrentVersion;
uint32_t _dylibCompatibilityVersion;
bool _explicitlyLinked;
bool _implicitlyLinked;
bool _speculativelyLoaded;
bool _forcedWeakLinked;
bool _needed;
bool _reExported;
bool _upward;
bool _dead;
};
} // namespace dylib
namespace archive {
//
// ld::archive::File
//
// Abstract base class for static libraries read by the linker processes.
//
class File : public ld::File
{
public:
File(const char* pth, time_t modTime, Ordinal ord)
: ld::File(pth, modTime, ord, Archive) { }
virtual ~File() {}
virtual bool justInTimeDataOnlyforEachAtom(const char* name, AtomHandler&) const = 0;
};
} // namespace archive
//
// ld::Section
//
class Section
{
public:
enum Type { typeUnclassified, typeCode, typePageZero, typeImportProxies, typeLinkEdit, typeMachHeader, typeStack,
typeLiteral4, typeLiteral8, typeLiteral16, typeConstants, typeTempLTO, typeTempAlias,
typeCString, typeNonStdCString, typeCStringPointer, typeUTF16Strings, typeCFString, typeObjC1Classes,
typeCFI, typeLSDA, typeDtraceDOF, typeUnwindInfo, typeObjCClassRefs, typeObjC2CategoryList, typeObjC2ClassList,
typeZeroFill, typeTentativeDefs, typeLazyPointer, typeStub, typeNonLazyPointer, typeDyldInfo,
typeLazyDylibPointer, typeStubHelper, typeInitializerPointers, typeTerminatorPointers,
typeStubClose, typeLazyPointerClose, typeAbsoluteSymbols, typeThreadStarts, typeChainStarts,
typeTLVDefs, typeTLVZeroFill, typeTLVInitialValues, typeTLVInitializerPointers, typeTLVPointers,
typeFirstSection, typeLastSection, typeDebug, typeSectCreate, typeInitOffsets, typeInterposing };
Section(const char* sgName, const char* sctName,
Type t, bool hidden=false)
: _segmentName(sgName), _sectionName(sctName),
_type(t), _hidden(hidden) {}
Section(const Section& sect)
: _segmentName(sect.segmentName()), _sectionName(sect.sectionName()),
_type(sect.type()), _hidden(sect.isSectionHidden()) {}
bool operator==(const Section& rhs) const { return ( (_hidden==rhs._hidden) &&
(strcmp(_segmentName, rhs._segmentName)==0) &&
(strcmp(_sectionName, rhs._sectionName)==0) ); }
bool operator!=(const Section& rhs) const { return ! (*this == rhs); }
const char* segmentName() const { return _segmentName; }
const char* sectionName() const { return _sectionName; }
Type type() const { return _type; }
bool isSectionHidden() const { return _hidden; }
private:
const char* _segmentName;
const char* _sectionName;
Type _type;
bool _hidden;
};
//
// ld::Fixup
//
// A Fixup describes how part of an Atom's content must be fixed up. For instance,
// an instruction may contain a displacement to another Atom that must be
// fixed up by the linker.
//
// A Fixup my reference another Atom. There are two kinds of references: direct and by-name.
// With a direct reference, the target is bound by the File that created it.
// For instance a reference to a static would produce a direct reference.
// A by-name reference requires the linker to find the target Atom with the
// required name in order to be bound.
//
// For a link to succeed all Fixup must be bound.
//
// A Reference also has a fix-up-offset. This is the offset into the content of the
// Atom holding the reference where the fix-up (relocation) will be applied.
//
//
struct Fixup
{
enum TargetBinding { bindingNone, bindingByNameUnbound, bindingDirectlyBound, bindingByContentBound, bindingsIndirectlyBound };
enum Cluster { k1of1, k1of2, k2of2, k1of3, k2of3, k3of3, k1of4, k2of4, k3of4, k4of4, k1of5, k2of5, k3of5, k4of5, k5of5 };
enum Kind { kindNone, kindNoneFollowOn,
// grouping
kindNoneGroupSubordinate,
kindNoneGroupSubordinateFDE, kindNoneGroupSubordinateLSDA, kindNoneGroupSubordinatePersonality,
// value calculations
kindSetTargetAddress,
kindSubtractTargetAddress,
kindAddAddend,
kindSubtractAddend,
kindSetTargetImageOffset,
kindSetTargetSectionOffset,
kindSetTargetTLVTemplateOffset,
// pointer store kinds (of current calculated value)
kindStore8,
kindStoreLittleEndian16,
kindStoreLittleEndianLow24of32,
kindStoreLittleEndian32,
kindStoreLittleEndian64,
kindStoreBigEndian16,
kindStoreBigEndianLow24of32,
kindStoreBigEndian32,
kindStoreBigEndian64,
// Intel specific store kinds
kindStoreX86BranchPCRel8, kindStoreX86BranchPCRel32,
kindStoreX86PCRel8, kindStoreX86PCRel16,
kindStoreX86PCRel32, kindStoreX86PCRel32_1, kindStoreX86PCRel32_2, kindStoreX86PCRel32_4,
kindStoreX86PCRel32GOTLoad, kindStoreX86PCRel32GOTLoadNowLEA, kindStoreX86PCRel32GOT,
kindStoreX86PCRel32TLVLoad, kindStoreX86PCRel32TLVLoadNowLEA,
kindStoreX86Abs32TLVLoad, kindStoreX86Abs32TLVLoadNowLEA,
// ARM specific store kinds
kindStoreARMBranch24, kindStoreThumbBranch22,
kindStoreARMLoad12,
kindStoreARMLow16, kindStoreARMHigh16,
kindStoreThumbLow16, kindStoreThumbHigh16,
#if SUPPORT_ARCH_arm64
// ARM64 specific store kinds
kindStoreARM64Branch26,
kindStoreARM64Page21, kindStoreARM64PageOff12,
kindStoreARM64GOTLoadPage21, kindStoreARM64GOTLoadPageOff12,
kindStoreARM64GOTLeaPage21, kindStoreARM64GOTLeaPageOff12,
kindStoreARM64TLVPLoadPage21, kindStoreARM64TLVPLoadPageOff12,
kindStoreARM64TLVPLoadNowLeaPage21, kindStoreARM64TLVPLoadNowLeaPageOff12,
kindStoreARM64PointerToGOT, kindStoreARM64PCRelToGOT,
#endif
#if SUPPORT_ARCH_arm64_32
kindStoreARM64PointerToGOT32,
#endif
// dtrace probes
kindDtraceExtra,
kindStoreX86DtraceCallSiteNop, kindStoreX86DtraceIsEnableSiteClear,
kindStoreARMDtraceCallSiteNop, kindStoreARMDtraceIsEnableSiteClear,
kindStoreARM64DtraceCallSiteNop, kindStoreARM64DtraceIsEnableSiteClear,
kindStoreThumbDtraceCallSiteNop, kindStoreThumbDtraceIsEnableSiteClear,
// lazy binding
kindLazyTarget, kindSetLazyOffset,
// islands
kindIslandTarget,
// data-in-code markers
kindDataInCodeStartData, kindDataInCodeStartJT8, kindDataInCodeStartJT16,
kindDataInCodeStartJT32, kindDataInCodeStartJTA32, kindDataInCodeEnd,
// linker optimization hints
kindLinkerOptimizationHint,
// pointer store combinations
kindStoreTargetAddressLittleEndian32, // kindSetTargetAddress + kindStoreLittleEndian32
kindStoreTargetAddressLittleEndian64, // kindSetTargetAddress + kindStoreLittleEndian64
kindStoreTargetAddressBigEndian32, // kindSetTargetAddress + kindStoreBigEndian32
kindStoreTargetAddressBigEndian64, // kindSetTargetAddress + kindStoreBigEndian364
kindSetTargetTLVTemplateOffsetLittleEndian32, // kindSetTargetTLVTemplateOffset + kindStoreLittleEndian32
kindSetTargetTLVTemplateOffsetLittleEndian64, // kindSetTargetTLVTemplateOffset + kindStoreLittleEndian64
// Intel value calculation and store combinations
kindStoreTargetAddressX86PCRel32, // kindSetTargetAddress + kindStoreX86PCRel32
kindStoreTargetAddressX86BranchPCRel32, // kindSetTargetAddress + kindStoreX86BranchPCRel32
kindStoreTargetAddressX86PCRel32GOTLoad,// kindSetTargetAddress + kindStoreX86PCRel32GOTLoad
kindStoreTargetAddressX86PCRel32GOTLoadNowLEA,// kindSetTargetAddress + kindStoreX86PCRel32GOTLoadNowLEA
kindStoreTargetAddressX86PCRel32TLVLoad, // kindSetTargetAddress + kindStoreX86PCRel32TLVLoad
kindStoreTargetAddressX86PCRel32TLVLoadNowLEA, // kindSetTargetAddress + kindStoreX86PCRel32TLVLoadNowLEA
kindStoreTargetAddressX86Abs32TLVLoad, // kindSetTargetAddress + kindStoreX86Abs32TLVLoad
kindStoreTargetAddressX86Abs32TLVLoadNowLEA, // kindSetTargetAddress + kindStoreX86Abs32TLVLoadNowLEA
// ARM value calculation and store combinations
kindStoreTargetAddressARMBranch24, // kindSetTargetAddress + kindStoreARMBranch24
kindStoreTargetAddressThumbBranch22, // kindSetTargetAddress + kindStoreThumbBranch22
kindStoreTargetAddressARMLoad12, // kindSetTargetAddress + kindStoreARMLoad12
#if SUPPORT_ARCH_arm64
// ARM64 value calculation and store combinations
kindStoreTargetAddressARM64Branch26, // kindSetTargetAddress + kindStoreARM64Branch26
kindStoreTargetAddressARM64Page21, // kindSetTargetAddress + kindStoreARM64Page21
kindStoreTargetAddressARM64PageOff12, // kindSetTargetAddress + kindStoreARM64PageOff12
kindStoreTargetAddressARM64PageOff12ConvertAddToLoad, // kindSetTargetAddress + kindStoreARM64PageOff12 and convert add to load
kindStoreTargetAddressARM64GOTLoadPage21, // kindSetTargetAddress + kindStoreARM64GOTLoadPage21
kindStoreTargetAddressARM64GOTLoadPageOff12,// kindSetTargetAddress + kindStoreARM64GOTLoadPageOff12
kindStoreTargetAddressARM64GOTLeaPage21, // kindSetTargetAddress + kindStoreARM64GOTLeaPage21
kindStoreTargetAddressARM64GOTLeaPageOff12, // kindSetTargetAddress + kindStoreARM64GOTLeaPageOff12
kindStoreTargetAddressARM64TLVPLoadPage21, // kindSetTargetAddress + kindStoreARM64TLVPLoadPage21
kindStoreTargetAddressARM64TLVPLoadPageOff12,// kindSetTargetAddress + kindStoreARM64TLVPLoadPageOff12
kindStoreTargetAddressARM64TLVPLoadNowLeaPage21, // kindSetTargetAddress + kindStoreARM64TLVPLoadNowLeaPage21
kindStoreTargetAddressARM64TLVPLoadNowLeaPageOff12, // kindSetTargetAddress + kindStoreARM64TLVPLoadNowLeaPageOff12
#endif
#if SUPPORT_ARCH_arm64e
kindStoreLittleEndianAuth64,
kindStoreTargetAddressLittleEndianAuth64, // kindSetTargetAddress + kindStoreLittleEndianAuth64
kindSetAuthData,
#endif
};
#if SUPPORT_ARCH_arm64e
struct AuthData {
// clang encodes the combination of the key bits as these values.
typedef enum {
ptrauth_key_asia = 0,
ptrauth_key_asib = 1,
ptrauth_key_asda = 2,
ptrauth_key_asdb = 3,
} ptrauth_key;
uint16_t discriminator;
bool hasAddressDiversity;
ptrauth_key key;
};
#endif
union {
const Atom* target;
const char* name;
uint64_t addend;
uint32_t bindingIndex;
#if SUPPORT_ARCH_arm64e
AuthData authData;
#endif
} u;
uint32_t offsetInAtom;
Kind kind : 8;
Cluster clusterSize : 4;
bool weakImport : 1;
TargetBinding binding : 3;
bool contentAddendOnly : 1;
bool contentDetlaToAddendOnly : 1;
bool contentIgnoresAddend : 1;
typedef Fixup* iterator;
Fixup() :
offsetInAtom(0), kind(kindNone), clusterSize(k1of1), weakImport(false),
binding(bindingNone),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false) { u.target = NULL; }
Fixup(Kind k, Atom* targetAtom) :
offsetInAtom(0), kind(k), clusterSize(k1of1), weakImport(false),
binding(Fixup::bindingDirectlyBound),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false)
{ assert(targetAtom != NULL); u.target = targetAtom; }
Fixup(uint32_t off, Cluster c, Kind k) :
offsetInAtom(off), kind(k), clusterSize(c), weakImport(false),
binding(Fixup::bindingNone),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false)
{ u.addend = 0; }
Fixup(uint32_t off, Cluster c, Kind k, bool weakIm, const char* name) :
offsetInAtom(off), kind(k), clusterSize(c), weakImport(weakIm),
binding(Fixup::bindingByNameUnbound),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false)
{ assert(name != NULL); u.name = name; }
Fixup(uint32_t off, Cluster c, Kind k, TargetBinding b, const char* name) :
offsetInAtom(off), kind(k), clusterSize(c), weakImport(false), binding(b),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false)
{ assert(name != NULL); u.name = name; }
Fixup(uint32_t off, Cluster c, Kind k, const Atom* targetAtom) :
offsetInAtom(off), kind(k), clusterSize(c), weakImport(false),
binding(Fixup::bindingDirectlyBound),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false)
{ assert(targetAtom != NULL); u.target = targetAtom; }
Fixup(uint32_t off, Cluster c, Kind k, TargetBinding b, const Atom* targetAtom) :
offsetInAtom(off), kind(k), clusterSize(c), weakImport(false), binding(b),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false)
{ assert(targetAtom != NULL); u.target = targetAtom; }
Fixup(uint32_t off, Cluster c, Kind k, uint64_t addend) :
offsetInAtom(off), kind(k), clusterSize(c), weakImport(false),
binding(Fixup::bindingNone),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false)
{ u.addend = addend; }
#if SUPPORT_ARCH_arm64e
Fixup(uint32_t off, Cluster c, Kind k, AuthData authData) :
offsetInAtom(off), kind(k), clusterSize(c), weakImport(false),
binding(Fixup::bindingNone),
contentAddendOnly(false), contentDetlaToAddendOnly(false), contentIgnoresAddend(false)
{ u.authData = authData; }
#endif
Fixup(Kind k, uint32_t lohKind, uint32_t off1, uint32_t off2) :
offsetInAtom(off1), kind(k), clusterSize(k1of1),
weakImport(false), binding(Fixup::bindingNone), contentAddendOnly(false),
contentDetlaToAddendOnly(false), contentIgnoresAddend(false) {
assert(k == kindLinkerOptimizationHint);
LOH_arm64 extra;
extra.addend = 0;
extra.info.kind = lohKind;
extra.info.count = 1;
extra.info.delta1 = 0;
extra.info.delta2 = (off2 - off1) >> 2;
u.addend = extra.addend;
}
bool firstInCluster() const {
switch (clusterSize) {
case k1of1:
case k1of2:
case k1of3:
case k1of4:
case k1of5:
return true;
default:
break;
}
return false;
}
bool lastInCluster() const {
switch (clusterSize) {
case k1of1:
case k2of2:
case k3of3:
case k4of4:
case k5of5:
return true;
default:
break;
}
return false;
}
bool isStore() const {
switch ( kind ) {
case ld::Fixup::kindNone:
case ld::Fixup::kindNoneFollowOn:
case ld::Fixup::kindNoneGroupSubordinate:
case ld::Fixup::kindNoneGroupSubordinateFDE:
case ld::Fixup::kindNoneGroupSubordinateLSDA:
case ld::Fixup::kindNoneGroupSubordinatePersonality:
case ld::Fixup::kindSetTargetAddress:
case ld::Fixup::kindSubtractTargetAddress:
case ld::Fixup::kindAddAddend:
case ld::Fixup::kindSubtractAddend:
case ld::Fixup::kindSetTargetImageOffset:
case ld::Fixup::kindSetTargetSectionOffset:
#if SUPPORT_ARCH_arm64e
case ld::Fixup::kindSetAuthData:
#endif
return false;
default:
break;
}
return true;
}
bool setsTarget(bool isObjectFile) const {
switch ( kind ) {
case ld::Fixup::kindSetTargetAddress:
case ld::Fixup::kindLazyTarget:
case ld::Fixup::kindStoreTargetAddressLittleEndian32:
case ld::Fixup::kindStoreTargetAddressLittleEndian64:
#if SUPPORT_ARCH_arm64e
case ld::Fixup::kindStoreTargetAddressLittleEndianAuth64:
#endif
case ld::Fixup::kindStoreTargetAddressBigEndian32:
case ld::Fixup::kindStoreTargetAddressBigEndian64:
case ld::Fixup::kindStoreTargetAddressX86PCRel32:
case ld::Fixup::kindStoreTargetAddressX86BranchPCRel32:
case ld::Fixup::kindStoreTargetAddressX86PCRel32GOTLoad:
case ld::Fixup::kindStoreTargetAddressX86PCRel32GOTLoadNowLEA:
case ld::Fixup::kindStoreTargetAddressX86PCRel32TLVLoad:
case ld::Fixup::kindStoreTargetAddressX86PCRel32TLVLoadNowLEA:
case ld::Fixup::kindStoreTargetAddressX86Abs32TLVLoad:
case ld::Fixup::kindStoreTargetAddressARMBranch24:
case ld::Fixup::kindStoreTargetAddressThumbBranch22:
case ld::Fixup::kindStoreTargetAddressARMLoad12:
#if SUPPORT_ARCH_arm64
case ld::Fixup::kindStoreTargetAddressARM64Branch26:
case ld::Fixup::kindStoreTargetAddressARM64Page21:
case ld::Fixup::kindStoreTargetAddressARM64PageOff12:
case ld::Fixup::kindStoreTargetAddressARM64PageOff12ConvertAddToLoad:
case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPage21:
case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPageOff12:
case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPage21:
case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPageOff12:
case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPage21:
case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPageOff12:
case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadNowLeaPage21:
case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadNowLeaPageOff12:
#endif
return true;
case ld::Fixup::kindStoreX86DtraceCallSiteNop:
case ld::Fixup::kindStoreX86DtraceIsEnableSiteClear:
case ld::Fixup::kindStoreARMDtraceCallSiteNop:
case ld::Fixup::kindStoreARMDtraceIsEnableSiteClear:
case ld::Fixup::kindStoreARM64DtraceCallSiteNop:
case ld::Fixup::kindStoreARM64DtraceIsEnableSiteClear:
case ld::Fixup::kindStoreThumbDtraceCallSiteNop:
case ld::Fixup::kindStoreThumbDtraceIsEnableSiteClear:
return isObjectFile;
default:
break;
}
return false;
}
bool isPcRelStore(bool isKextBundle) const {
switch ( kind ) {
case ld::Fixup::kindStoreX86BranchPCRel8:
case ld::Fixup::kindStoreX86BranchPCRel32:
case ld::Fixup::kindStoreX86PCRel8:
case ld::Fixup::kindStoreX86PCRel16:
case ld::Fixup::kindStoreX86PCRel32:
case ld::Fixup::kindStoreX86PCRel32_1:
case ld::Fixup::kindStoreX86PCRel32_2:
case ld::Fixup::kindStoreX86PCRel32_4:
case ld::Fixup::kindStoreX86PCRel32GOTLoad:
case ld::Fixup::kindStoreX86PCRel32GOTLoadNowLEA:
case ld::Fixup::kindStoreX86PCRel32GOT:
case ld::Fixup::kindStoreX86PCRel32TLVLoad:
case ld::Fixup::kindStoreX86PCRel32TLVLoadNowLEA:
case ld::Fixup::kindStoreARMBranch24:
case ld::Fixup::kindStoreThumbBranch22:
case ld::Fixup::kindStoreARMLoad12:
case ld::Fixup::kindStoreTargetAddressX86PCRel32:
case ld::Fixup::kindStoreTargetAddressX86PCRel32GOTLoad:
case ld::Fixup::kindStoreTargetAddressX86PCRel32GOTLoadNowLEA:
case ld::Fixup::kindStoreTargetAddressX86PCRel32TLVLoad:
case ld::Fixup::kindStoreTargetAddressX86PCRel32TLVLoadNowLEA:
case ld::Fixup::kindStoreTargetAddressARMBranch24:
case ld::Fixup::kindStoreTargetAddressThumbBranch22:
case ld::Fixup::kindStoreTargetAddressARMLoad12:
#if SUPPORT_ARCH_arm64
case ld::Fixup::kindStoreARM64Page21:
case ld::Fixup::kindStoreARM64PageOff12:
case ld::Fixup::kindStoreARM64GOTLoadPage21:
case ld::Fixup::kindStoreARM64GOTLoadPageOff12:
case ld::Fixup::kindStoreARM64GOTLeaPage21:
case ld::Fixup::kindStoreARM64GOTLeaPageOff12:
case ld::Fixup::kindStoreARM64TLVPLoadPage21:
case ld::Fixup::kindStoreARM64TLVPLoadPageOff12: