LLVM: lib/MC/MachObjectWriter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

34#include

35#include

36#include

37#include

38#include

39#include

40

41using namespace llvm;

42

43#define DEBUG_TYPE "mc"

44

46 Relocations.clear();

47 IndirectSymBase.clear();

48 IndirectSymbols.clear();

49 DataRegions.clear();

50 SectionAddress.clear();

51 SectionOrder.clear();

53 LocalSymbolData.clear();

54 ExternalSymbolData.clear();

55 UndefinedSymbolData.clear();

56 LOHContainer.reset();

57 VersionInfo.Major = 0;

59 TargetVariantVersionInfo.Major = 0;

60 TargetVariantVersionInfo.SDKVersion = VersionTuple();

61 LinkerOptions.clear();

63}

64

66

68 return true;

69

70

71

72 if (cast(S).isWeakDefinition())

73 return true;

74

75

76 return false;

77}

78

79bool MachObjectWriter::

80MachSymbolData::operator<(const MachSymbolData &RHS) const {

81 return Symbol->getName() < RHS.Symbol->getName();

82}

83

85 const MCFixupKindInfo &FKI = Asm.getBackend().getFixupKindInfo(

87

89}

90

95 Asm.getFragmentOffset(*Fragment);

96}

97

100

104 return C->getValue();

105

110

111

112 if (Target.getSymA() && Target.getSymA()->getSymbol().isUndefined())

113 report_fatal_error("unable to evaluate offset to undefined symbol '" +

115 if (Target.getSymB() && Target.getSymB()->getSymbol().isUndefined())

116 report_fatal_error("unable to evaluate offset to undefined symbol '" +

118

120 if (Target.getSymA())

122 if (Target.getSymB())

125 }

126

128 Asm.getSymbolOffset(S);

129}

130

134 unsigned Next = cast(Sec)->getLayoutOrder() + 1;

135 if (Next >= SectionOrder.size())

136 return 0;

137

138 const MCSection &NextSec = *SectionOrder[Next];

140 return 0;

142}

143

145

146 if (!Symbol.isTemporary())

147 return true;

148

149 if (Symbol.isUsedInReloc())

150 return true;

151

152 return false;

153}

154

156

158 return &S;

159

160

162 return nullptr;

163

164

165

168 return nullptr;

169

170

172}

173

175 unsigned NumLoadCommands,

176 unsigned LoadCommandsSize,

177 bool SubsectionsViaSymbols) {

179

182

183

184

185

187 (void) Start;

188

190

192

193 uint32_t Cpusubtype = TargetObjectWriter->getCPUSubtype();

194

195

196

197

201 0, false);

202

204

211

214}

215

218 W.OS << Str;

220}

221

222

223

224

225

230

231

232

234 (void) Start;

235

236 unsigned SegmentLoadCommandSize =

243

244 writeWithPadding(Name, 16);

248 W.write<uint64_t>(SectionDataStartOffset);

250 } else {

253 W.write<uint32_t>(SectionDataStartOffset);

255 }

256

258

262

263 assert(W.OS.tell() - Start == SegmentLoadCommandSize);

264}

265

268 uint64_t FileOffset, unsigned Flags,

270 unsigned NumRelocations) {

271 uint64_t SectionSize = Asm.getSectionAddressSize(Sec);

272 const MCSectionMachO &Section = cast(Sec);

273

274

275 if (Section.isVirtualSection()) {

276 assert(Asm.getSectionFileSize(Sec) == 0 && "Invalid file size!");

277 FileOffset = 0;

278 }

279

280

281

282

284 (void) Start;

285

286 writeWithPadding(Section.getName(), 16);

287 writeWithPadding(Section.getSegmentName(), 16);

291 } else {

294 }

295 assert(isUInt<32>(FileOffset) && "Cannot encode offset of section");

297

299 assert((!NumRelocations || isUInt<32>(RelocationsStart)) &&

300 "Cannot encode offset of relocations");

301 W.write<uint32_t>(NumRelocations ? RelocationsStart : 0);

304 W.write<uint32_t>(IndirectSymBase.lookup(&Sec));

305 W.write<uint32_t>(Section.getStubSize());

308

311}

312

317

318

320 (void) Start;

321

328

330}

331

334 uint32_t FirstExternalSymbol,

336 uint32_t FirstUndefinedSymbol,

337 uint32_t NumUndefinedSymbols,

338 uint32_t IndirectSymbolOffset,

339 uint32_t NumIndirectSymbols) {

340

341

343 (void) Start;

344

365

367}

368

369MachObjectWriter::MachSymbolData *

370MachObjectWriter::findSymbolData(const MCSymbol &Sym) {

371 for (auto *SymbolData :

372 {&LocalSymbolData, &ExternalSymbolData, &UndefinedSymbolData})

373 for (MachSymbolData &Entry : *SymbolData)

374 if (Entry.Symbol == &Sym)

375 return &Entry;

376

377 return nullptr;

378}

379

384 const auto *Ref = dyn_cast(Value);

385 if (Ref)

386 return *S;

387 S = &Ref->getSymbol();

388 }

389 return *S;

390}

391

393 const MCSymbol *Symbol = MSD.Symbol;

394 const auto &Data = cast(*Symbol);

396 uint8_t SectionIndex = MSD.SectionIndex;

399 bool IsAlias = Symbol != AliasedSymbol;

400

401 const MCSymbol &OrigSymbol = *Symbol;

402 MachSymbolData *AliaseeInfo;

403 if (IsAlias) {

404 AliaseeInfo = findSymbolData(*AliasedSymbol);

405 if (AliaseeInfo)

406 SectionIndex = AliaseeInfo->SectionIndex;

407 Symbol = AliasedSymbol;

408

409 }

410

411

412

413

414 if (IsAlias && Symbol->isUndefined())

416 else if (Symbol->isUndefined())

418 else if (Symbol->isAbsolute())

420 else

422

423

424

425 if (Data.isPrivateExtern())

427

428

429 if (Data.isExternal() || (!IsAlias && Symbol->isUndefined()))

431

432

433 if (IsAlias && Symbol->isUndefined())

434 Address = AliaseeInfo->StringIndex;

435 else if (Symbol->isDefined())

437 else if (Symbol->isCommon()) {

438

439

440 Address = Symbol->getCommonSize();

441 }

442

443

444

447 W.OS << char(SectionIndex);

448

449

450

451 bool EncodeAsAltEntry =

452 IsAlias && cast(OrigSymbol).isAltEntry();

453 W.write<uint16_t>(cast(Symbol)->getEncodedFlags(EncodeAsAltEntry));

456 else

458}

459

464 (void) Start;

465

470

472}

473

475 const std::vectorstd::string &Options, bool is64Bit)

476{

478 for (const std::string &Option : Options)

479 Size += Option.size() + 1;

481}

482

484 const std::vectorstd::string &Options)

485{

488 (void) Start;

489

494 for (const std::string &Option : Options) {

495

496 W.OS << Option << '\0';

497 BytesWritten += Option.size() + 1;

498 }

499

500

503

505}

506

508

509

511 return false;

512 return true;

513}

514

520 Asm.getContext().reportError(Fixup.getLoc(),

521 "unsupported relocation expression");

522 return;

523 }

524

525 TargetObjectWriter->recordRelocation(this, Asm, Fragment, Fixup, Target,

526 FixedValue);

527}

528

530

531

532

533

534

535

536

537

538

539 for (IndirectSymbolData &ISD : IndirectSymbols) {

540 const MCSectionMachO &Section = cast(*ISD.Section);

541

546 MCSymbol &Symbol = *ISD.Symbol;

548 "' not in a symbol pointer or stub section");

549 }

550 }

551

552

553 for (auto [IndirectIndex, ISD] : enumerate(IndirectSymbols)) {

554 const auto &Section = cast(*ISD.Section);

555

558 continue;

559

560

561 IndirectSymBase.insert(std::make_pair(ISD.Section, IndirectIndex));

562

563 Asm.registerSymbol(*ISD.Symbol);

564 }

565

566

567 for (auto [IndirectIndex, ISD] : enumerate(IndirectSymbols)) {

568 const auto &Section = cast(*ISD.Section);

569

572 continue;

573

574

575 IndirectSymBase.insert(std::make_pair(ISD.Section, IndirectIndex));

576

577

578

579

580 if (Asm.registerSymbol(*ISD.Symbol))

581 cast(ISD.Symbol)->setReferenceTypeUndefinedLazy(true);

582 }

583}

584

585

587 MCAssembler &Asm, std::vector &LocalSymbolData,

588 std::vector &ExternalSymbolData,

589 std::vector &UndefinedSymbolData) {

590

592 unsigned Index = 1;

594 SectionIndexMap[&Sec] = Index++;

595 assert(Index <= 256 && "Too many sections!");

596

597

598 for (const MCSymbol &Symbol : Asm.symbols()) {

600 continue;

601

603 }

605

606

607

608

609

610

611 for (const MCSymbol &Symbol : Asm.symbols()) {

612

614 continue;

615

616 if (!Symbol.isExternal() && !Symbol.isUndefined())

617 continue;

618

619 MachSymbolData MSD;

620 MSD.Symbol = &Symbol;

621 MSD.StringIndex = StringTable.getOffset(Symbol.getName());

622

623 if (Symbol.isUndefined()) {

624 MSD.SectionIndex = 0;

625 UndefinedSymbolData.push_back(MSD);

626 } else if (Symbol.isAbsolute()) {

627 MSD.SectionIndex = 0;

628 ExternalSymbolData.push_back(MSD);

629 } else {

630 MSD.SectionIndex = SectionIndexMap.lookup(&Symbol.getSection());

631 assert(MSD.SectionIndex && "Invalid section index!");

632 ExternalSymbolData.push_back(MSD);

633 }

634 }

635

636

637 for (const MCSymbol &Symbol : Asm.symbols()) {

638

640 continue;

641

642 if (Symbol.isExternal() || Symbol.isUndefined())

643 continue;

644

645 MachSymbolData MSD;

646 MSD.Symbol = &Symbol;

647 MSD.StringIndex = StringTable.getOffset(Symbol.getName());

648

649 if (Symbol.isAbsolute()) {

650 MSD.SectionIndex = 0;

651 LocalSymbolData.push_back(MSD);

652 } else {

653 MSD.SectionIndex = SectionIndexMap.lookup(&Symbol.getSection());

654 assert(MSD.SectionIndex && "Invalid section index!");

655 LocalSymbolData.push_back(MSD);

656 }

657 }

658

659

662

663

664 Index = 0;

665 for (auto *SymbolData :

666 {&LocalSymbolData, &ExternalSymbolData, &UndefinedSymbolData})

667 for (MachSymbolData &Entry : *SymbolData)

668 Entry.Symbol->setIndex(Index++);

669

670 for (const MCSection &Section : Asm) {

671 for (RelAndSymbol &Rel : Relocations[&Section]) {

672 if (!Rel.Sym)

673 continue;

674

675

676 unsigned Index = Rel.Sym->getIndex();

677 assert(isInt<24>(Index));

679 Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (~0U << 24)) | Index | (1 << 27);

680 else

681 Rel.MRE.r_word1 = (Rel.MRE.r_word1 & 0xff) | Index << 8 | (1 << 4);

682 }

683 }

684}

685

687

688 unsigned i = 0;

689

691 if (!Sec.isVirtualSection()) {

693 cast(Sec).setLayoutOrder(i++);

694 }

695 }

697 if (Sec.isVirtualSection()) {

699 cast(Sec).setLayoutOrder(i++);

700 }

701 }

702

704 for (const MCSection *Sec : SectionOrder) {

705 StartAddress = alignTo(StartAddress, Sec->getAlign());

706 SectionAddress[Sec] = StartAddress;

707 StartAddress += Asm.getSectionAddressSize(*Sec);

708

709

710

711

713 }

714}

715

718

719

721}

722

725 bool InSet, bool IsPCRel) const {

726 if (InSet)

727 return true;

728

729

730

731

732

733

737

738 if (IsPCRel) {

739

740

741

742

743

744

745

746

747

748

749

750

751

752 bool hasReliableSymbolDifference = isX86_64();

753 if (!hasReliableSymbolDifference) {

754 if (!SA.isInSection() || &SecA != &SecB ||

757 return false;

758 return true;

759 }

760 }

761

762

763 if (&SecA != &SecB)

764 return false;

765

766

768}

769

771 switch (Type) {

776 }

778}

779

782 Asm.getContext().getObjectFileInfo()->getAddrSigSection();

783 unsigned Log2Size = is64Bit() ? 3 : 2;

785 if (!S->isRegistered())

786 continue;

791 }

792}

793

796 auto NumBytesWritten = [&] { return W.OS.tell() - StartOffset; };

797

799

800

802 UndefinedSymbolData);

803

805 MCSection *CGProfileSection = Asm.getContext().getMachOSection(

807 auto &Frag = cast(*CGProfileSection->begin());

808 Frag.getContents().clear();

811 uint32_t FromIndex = CGPE.From->getSymbol().getIndex();

812 uint32_t ToIndex = CGPE.To->getSymbol().getIndex();

816 }

817 }

818

819 unsigned NumSections = Asm.end() - Asm.begin();

820

821

822

823 unsigned NumLoadCommands = 1;

827

828

829 if (VersionInfo.Major != 0) {

830 ++NumLoadCommands;

831 if (VersionInfo.EmitBuildVersion)

833 else

835 }

836

837

838 if (TargetVariantVersionInfo.Major != 0) {

839 ++NumLoadCommands;

840 assert(TargetVariantVersionInfo.EmitBuildVersion &&

841 "target variant should use build version");

843 }

844

845

846 unsigned NumDataRegions = DataRegions.size();

847 if (NumDataRegions) {

848 ++NumLoadCommands;

850 }

851

852

855 if (LOHSize) {

856 ++NumLoadCommands;

858 }

859

860

861 unsigned NumSymbols = LocalSymbolData.size() + ExternalSymbolData.size() +

862 UndefinedSymbolData.size();

863 if (NumSymbols) {

864 NumLoadCommands += 2;

867 }

868

869

870 for (const auto &Option : LinkerOptions) {

871 ++NumLoadCommands;

873 }

874

875

876

879 uint64_t SectionDataSize = 0;

880 uint64_t SectionDataFileSize = 0;

882 for (const MCSection &Sec : Asm) {

884 uint64_t Size = Asm.getSectionAddressSize(Sec);

885 uint64_t FileSize = Asm.getSectionFileSize(Sec);

887

888 VMSize = std::max(VMSize, Address + Size);

889

890 if (Sec.isVirtualSection())

891 continue;

892

893 SectionDataSize = std::max(SectionDataSize, Address + Size);

894 SectionDataFileSize = std::max(SectionDataFileSize, Address + FileSize);

895 }

896

897

898

899

900 unsigned SectionDataPadding =

902 SectionDataFileSize += SectionDataPadding;

903

904

910 SectionDataSize, Prot, Prot);

911

912

913 uint64_t RelocTableEnd = SectionDataStart + SectionDataFileSize;

914 for (const MCSection &Section : Asm) {

915 const auto &Sec = cast(Section);

916 std::vector &Relocs = Relocations[&Sec];

917 unsigned NumRelocs = Relocs.size();

919 unsigned Flags = Sec.getTypeAndAttributes();

920 if (Sec.hasInstructions())

922 if (!cast(Sec).isVirtualSection() &&

923 !isUInt<32>(SectionStart)) {

924 Asm.getContext().reportError(

925 SMLoc(), "cannot encode offset of section; object file too large");

926 return NumBytesWritten();

927 }

928 if (NumRelocs && !isUInt<32>(RelocTableEnd)) {

929 Asm.getContext().reportError(

931 "cannot encode offset of relocations; object file too large");

932 return NumBytesWritten();

933 }

935 RelocTableEnd, NumRelocs);

937 }

938

939

940 auto EmitDeploymentTargetVersion =

943 assert(!V.empty() && "empty version");

944 unsigned Update = V.getSubminor().value_or(0);

945 unsigned Minor = V.getMinor().value_or(0);

946 assert(Update < 256 && "unencodable update target version");

947 assert(Minor < 256 && "unencodable minor target version");

948 assert(V.getMajor() < 65536 && "unencodable major target version");

949 return Update | (Minor << 8) | (V.getMajor() << 16);

950 };

952 VersionInfo.Major, VersionInfo.Minor, VersionInfo.Update));

954 ? EncodeVersion(VersionInfo.SDKVersion)

955 : 0;

956 if (VersionInfo.EmitBuildVersion) {

957

960 W.write<uint32_t>(VersionInfo.TypeOrPlatform.Platform);

964 } else {

971 }

972 };

973 if (VersionInfo.Major != 0)

974 EmitDeploymentTargetVersion(VersionInfo);

975 if (TargetVariantVersionInfo.Major != 0)

976 EmitDeploymentTargetVersion(TargetVariantVersionInfo);

977

978

979 uint64_t DataInCodeTableEnd = RelocTableEnd + NumDataRegions * 8;

980 if (NumDataRegions) {

981 uint64_t DataRegionsOffset = RelocTableEnd;

982 uint64_t DataRegionsSize = NumDataRegions * 8;

984 DataRegionsSize);

985 }

986

987

988 uint64_t LOHTableEnd = DataInCodeTableEnd + LOHSize;

989 if (LOHSize)

991 DataInCodeTableEnd, LOHSize);

992

993

994 if (NumSymbols) {

995 unsigned FirstLocalSymbol = 0;

996 unsigned NumLocalSymbols = LocalSymbolData.size();

997 unsigned FirstExternalSymbol = FirstLocalSymbol + NumLocalSymbols;

998 unsigned NumExternalSymbols = ExternalSymbolData.size();

999 unsigned FirstUndefinedSymbol = FirstExternalSymbol + NumExternalSymbols;

1000 unsigned NumUndefinedSymbols = UndefinedSymbolData.size();

1001 unsigned NumIndirectSymbols = IndirectSymbols.size();

1002 unsigned NumSymTabSymbols =

1003 NumLocalSymbols + NumExternalSymbols + NumUndefinedSymbols;

1004 uint64_t IndirectSymbolSize = NumIndirectSymbols * 4;

1005 uint64_t IndirectSymbolOffset = 0;

1006

1007

1008 if (NumIndirectSymbols)

1009 IndirectSymbolOffset = LOHTableEnd;

1010

1011

1012 uint64_t SymbolTableOffset = LOHTableEnd + IndirectSymbolSize;

1013

1014

1015 uint64_t StringTableOffset =

1016 SymbolTableOffset + NumSymTabSymbols * (is64Bit() ?

1020 StringTableOffset, StringTable.getSize());

1021

1023 FirstExternalSymbol, NumExternalSymbols,

1024 FirstUndefinedSymbol, NumUndefinedSymbols,

1025 IndirectSymbolOffset, NumIndirectSymbols);

1026 }

1027

1028

1029 for (const auto &Option : LinkerOptions)

1031

1032

1033 for (const MCSection &Sec : Asm) {

1034 Asm.writeSectionData(W.OS, &Sec);

1035

1038 }

1039

1040

1042

1043

1044 for (const MCSection &Sec : Asm) {

1045

1046

1047 std::vector &Relocs = Relocations[&Sec];

1048 for (const RelAndSymbol &Rel : llvm::reverse(Relocs)) {

1051 }

1052 }

1053

1054

1058 if (Data.End)

1060 else

1062

1064 << " start: " << Start << "(" << Data.Start->getName()

1065 << ")" << " end: " << End << "(" << Data.End->getName()

1066 << ")" << " size: " << End - Start << "\n");

1070 }

1071

1072

1073 if (LOHSize) {

1074#ifndef NDEBUG

1075 unsigned Start = W.OS.tell();

1076#endif

1077 LOHContainer.emit(Asm, *this);

1078

1082 }

1083

1084

1085 if (NumSymbols) {

1086

1087 for (auto &ISD : IndirectSymbols) {

1088

1089

1093

1094 if (ISD.Symbol->isDefined() && !ISD.Symbol->isExternal()) {

1096 if (ISD.Symbol->isAbsolute())

1099 continue;

1100 }

1101 }

1102

1104 }

1105

1106

1107

1108

1109 for (auto *SymbolData :

1110 {&LocalSymbolData, &ExternalSymbolData, &UndefinedSymbolData})

1111 for (MachSymbolData &Entry : *SymbolData)

1113

1114

1116 }

1117

1118 return NumBytesWritten();

1119}

This file defines the DenseMap class.

static unsigned ComputeLinkerOptionsLoadCommandSize(const std::vector< std::string > &Options, bool is64Bit)

static bool isFixupTargetValid(const MCValue &Target)

static MachO::LoadCommandType getLCFromMCVM(MCVersionMinType Type)

static bool isSymbolLinkerVisible(const MCSymbol &Symbol)

PowerPC TLS Dynamic Call Fixup

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

static bool is64Bit(const char *name)

ValueT lookup(const_arg_type_t< KeyT > Val) const

lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...

static bool isSectionAtomizableBySymbols(const MCSection &Section)

True if the section is atomized using the symbols in it.

Base class for the full range of assembler expressions which are needed for parsing.

bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const

Try to evaluate the expression to a relocatable value, i.e.

Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...

const MCSymbol * getAtom() const

MCSection * getParent() const

void emit(const MCAssembler &Asm, MachObjectWriter &ObjWriter) const

Emit all Linker Optimization Hint in one big table.

uint64_t getEmitSize(const MCAssembler &Asm, const MachObjectWriter &ObjWriter) const

Get the size of the directives if emitted.

SmallVector< CGProfileEntry, 0 > CGProfile

bool SubsectionsViaSymbols

std::vector< const MCSymbol * > & getAddrsigSyms()

virtual void reset()

lifetime management

This represents a section on a Mach-O system (used by Mac OS X).

Instances of this class represent a uniqued identifier for a section in the current translation unit.

bool isVirtualSection() const

Check whether this section is "virtual", that is has no actual object file contents.

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

const MCExpr * getVariableValue(bool SetUsed=true) const

getVariableValue - Get the value for variable symbols.

bool isInSection() const

isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).

StringRef getName() const

getName - Get the symbol name.

bool isVariable() const

isVariable - Check if this is a variable symbol.

bool isUndefined(bool SetUsed=true) const

isUndefined - Check if this symbol undefined (i.e., implicitly defined).

MCSection & getSection() const

Get the section associated with a defined, non-absolute symbol.

bool isTemporary() const

isTemporary - Check if this is an assembler temporary symbol.

MCFragment * getFragment(bool SetUsed=true) const

This represents an "assembler immediate".

uint64_t getPaddingSize(const MCAssembler &Asm, const MCSection *SD) const

void computeSectionAddresses(const MCAssembler &Asm)

void writeSection(const MCAssembler &Asm, const MCSection &Sec, uint64_t VMAddr, uint64_t FileOffset, unsigned Flags, uint64_t RelocationsStart, unsigned NumRelocations)

bool doesSymbolRequireExternRelocation(const MCSymbol &S)

void computeSymbolTable(MCAssembler &Asm, std::vector< MachSymbolData > &LocalSymbolData, std::vector< MachSymbolData > &ExternalSymbolData, std::vector< MachSymbolData > &UndefinedSymbolData)

Compute the symbol table data.

uint64_t getFragmentAddress(const MCAssembler &Asm, const MCFragment *Fragment) const

{ bool EmitBuildVersion VersionInfoType

void executePostLayoutBinding(MCAssembler &Asm) override

Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...

uint64_t getSectionAddress(const MCSection *Sec) const

void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)

void populateAddrSigSection(MCAssembler &Asm)

bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind)

support::endian::Writer W

void writeLinkerOptionsLoadCommand(const std::vector< std::string > &Options)

void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) override

Record a relocation entry.

void writeNlist(MachSymbolData &MSD, const MCAssembler &Asm)

VersionTuple SDKVersion

An optional version of the SDK that was used to build the source.

bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override

void writeDysymtabLoadCommand(uint32_t FirstLocalSymbol, uint32_t NumLocalSymbols, uint32_t FirstExternalSymbol, uint32_t NumExternalSymbols, uint32_t FirstUndefinedSymbol, uint32_t NumUndefinedSymbols, uint32_t IndirectSymbolOffset, uint32_t NumIndirectSymbols)

const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const

uint64_t getSymbolAddress(const MCSymbol &S, const MCAssembler &Asm) const

MCVersionMinType Type

Used when EmitBuildVersion==false.

void writeSegmentLoadCommand(StringRef Name, unsigned NumSections, uint64_t VMAddr, uint64_t VMSize, uint64_t SectionDataStartOffset, uint64_t SectionDataSize, uint32_t MaxProt, uint32_t InitProt)

Write a segment load command.

const MCSymbol * getAtom(const MCSymbol &S) const

void writeLinkeditLoadCommand(uint32_t Type, uint32_t DataOffset, uint32_t DataSize)

void writeHeader(MachO::HeaderFileType Type, unsigned NumLoadCommands, unsigned LoadCommandsSize, bool SubsectionsViaSymbols)

void reset() override

lifetime management

void writeSymtabLoadCommand(uint32_t SymbolOffset, uint32_t NumSymbols, uint32_t StringTableOffset, uint32_t StringTableSize)

void bindIndirectSymbols(MCAssembler &Asm)

uint64_t writeObject(MCAssembler &Asm) override

Write the object file and returns the number of bytes written.

Represents a location in source code.

static SectionKind getMetadata()

void push_back(const T &Elt)

StringRef - Represent a constant reference to a string, i.e.

A table of densely packed, null-terminated strings indexed by offset.

Target - Wrapper for Target specific information.

const char * getName() const

getName - Get the target name.

The instances of the Type class are immutable: once they are created, they are never changed.

LLVM Value Representation.

StringRef getName() const

Return a constant reference to the value's name.

Represents a version number in the form major[.minor[.subminor[.build]]].

raw_ostream & write_zeros(unsigned NumZeros)

write_zeros - Insert 'NumZeros' nulls.

uint64_t tell() const

tell - Return the current offset with the file.

A raw_ostream that writes to an SmallVector or SmallString.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

@ C

The default llvm calling convention, compatible with C.

@ S_ATTR_SOME_INSTRUCTIONS

S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.

@ S_THREAD_LOCAL_VARIABLE_POINTERS

S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread local structures.

@ S_LAZY_SYMBOL_POINTERS

S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.

@ S_NON_LAZY_SYMBOL_POINTERS

S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.

@ S_SYMBOL_STUBS

S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in the Reserved2 field.

uint32_t CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(unsigned PtrAuthABIVersion, bool PtrAuthKernelABIVersion)

@ MH_SUBSECTIONS_VIA_SYMBOLS

void write(void *memory, value_type value, endianness endian)

Write a value to memory with a particular endianness.

This is an optimization pass for GlobalISel generic memory operations.

auto enumerate(FirstRange &&First, RestRanges &&...Rest)

Given two or more input ranges, returns a new range whose values are tuples (A, B,...

auto reverse(ContainerTy &&C)

void sort(IteratorTy Start, IteratorTy End)

@ MCVM_WatchOSVersionMin

.watchos_version_min

@ MCVM_OSXVersionMin

.macosx_version_min

@ MCVM_TvOSVersionMin

.tvos_version_min

@ MCVM_IOSVersionMin

.ios_version_min

raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

void report_fatal_error(Error Err, bool gen_crash_diag=true)

Report a serious error, calling any installed error handler.

MCFixupKind

Extensible enumeration to represent the type of a fixup.

uint64_t offsetToAlignment(uint64_t Value, Align Alignment)

Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...

@ Ref

The access may reference the value stored in memory.

uint64_t alignTo(uint64_t Size, Align A)

Returns a multiple of A needed to store Size bytes.

unsigned Log2(Align A)

Returns the log2 of the alignment.

This struct is a compact representation of a valid (non-zero power of two) alignment.

Target independent information on a fixup kind.

@ FKF_IsPCRel

Is this fixup kind PCrelative? This is used by the assembler backend to evaluate fixup values in a ta...

unsigned Flags

Flags describing additional information on this fixup kind.

void write(ArrayRef< value_type > Val)