LLVM: lib/ObjCopy/ELF/ELFObject.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_LIB_OBJCOPY_ELF_ELFOBJECT_H

10#define LLVM_LIB_OBJCOPY_ELF_ELFOBJECT_H

11

22#include

23#include

24#include

25#include

26#include

27#include

28

29namespace llvm {

32namespace elf {

33

49

52

53public:

55

59

62 size_t size() const { return Sections.size(); }

63

65

66 template

68 Twine TypeErrMsg);

69};

70

72

89

106

108protected:

110

111public:

113

125

127};

128

130private:

131 using Elf_Word = typename ELFT::Word;

132 using Elf_Rel = typename ELFT::Rel;

133 using Elf_Rela = typename ELFT::Rela;

134 using Elf_Sym = typename ELFT::Sym;

135

136public:

145

147};

148

150private:

151 using Elf_Rel = typename ELFT::Rel;

152 using Elf_Rela = typename ELFT::Rela;

153 using Elf_Sym = typename ELFT::Sym;

154 using Elf_Word = typename ELFT::Word;

155 using Elf_Xword = typename ELFT::Xword;

156

157public:

169};

170

171#define MAKE_SEC_WRITER_FRIEND \

172 friend class SectionWriter; \

173 friend class IHexSectionWriterBase; \

174 friend class IHexSectionWriter; \

175 friend class SRECSectionWriter; \

176 friend class SRECSectionWriterBase; \

177 friend class SRECSizeCalculator; \

178 template friend class ELFSectionWriter; \

179 template friend class ELFSectionSizer;

180

196

198

200

202

204

206

207

208

213

214

218

219

220

223

224

225

227

228

229

230

232

234

235

237

238

239

241

242

243

244

245

246

247

249

250

251

252

254

255

256

257

259

260

261

263

265 };

266};

267

268

269

270

272

274

276

277

279

281

282protected:

283

285

288

289public:

292

299};

300

301

309

311protected:

313 std::unique_ptr Buf;

315

316public:

320

322};

323

325private:

326 using Elf_Addr = typename ELFT::Addr;

327 using Elf_Shdr = typename ELFT::Shdr;

328 using Elf_Phdr = typename ELFT::Phdr;

329 using Elf_Ehdr = typename ELFT::Ehdr;

330

331 void initEhdrSegment();

332

333 void writeEhdr();

334 void writePhdr(const Segment &Seg);

336

337 void writePhdrs();

338 void writeShdrs();

339 Error writeSectionData();

340 void writeSegmentData();

341

342 void assignOffsets();

343

344 std::unique_ptr<ELFSectionWriter> SecWriter;

345

346 size_t totalSize() const;

347

348public:

351

352

353

355

359};

360

362private:

365 std::unique_ptr SecWriter;

366

368

369public:

374 : Writer(Obj, Out), GapFill(Config.GapFill), PadTo(Config.PadTo) {}

375};

376

377

379public:

383

384protected:

387 std::vector<const SectionBase *> Sections;

388

392};

393

395public:

399

400private:

405};

406

408public:

412

413private:

418};

419

427

433

435

437

439

441

443

445

447

449

451

453

455 };

456};

457

459public:

464

466

474

475protected:

476

478

480

483

486};

487

488

489

491public:

494

495protected:

497};

498

500public:

504

505protected:

507};

508

510public:

515

520

533

536

538

541

549 virtual void

553

555

557};

558

560private:

561 struct SectionCompare {

563

564

565

569 }

570 };

571

572public:

581

586 std::set<const SectionBase *, SectionCompare> Sections;

587

590

594 return nullptr;

595 }

596

599

601};

602

605

608 bool HasSymTabLink = false;

609

610public:

612

616 bool AllowBrokenLinks,

624

626};

627

630

631 std::vector<uint8_t> Data;

632

633public:

635 : Data(std::begin(Data), std::end(Data)) {

638 Size = Data.size();

639 OriginalOffset = std::numeric_limits<uint64_t>::max();

640 }

641

646 Addr = SecAddr;

649 }

650

653 Size = Data.size();

654 }

655

661};

662

665

671

672public:

677

681

684

688};

689

705

706

707

708

709

710

711

712

713

716

718

719public:

723

729

735};

736

737

738

739

740

761

778

781

782private:

783 std::vector<uint32_t> Indexes;

785

786public:

790 Indexes.push_back(Index);

791 }

792

794 Indexes.reserve(NumSymbols);

795 Size = NumSymbols * 4;

796 }

802

804 Name = ".symtab_shndx";

808 }

809};

810

813

815 void assignIndices();

816

817protected:

818 std::vector<std::unique_ptr> Symbols;

822

823 using SymPtr = std::unique_ptr;

824

825public:

827

832

844

846 bool AllowBrokenLinks,

855

859};

860

867

868

869

870

871

872

873

874

875

876

878protected:

880

881public:

884

886

891};

892

893

894

895template

897 void setSymTab(SymTabType *SymTab) { Symbols = SymTab; }

898

899protected:

901

903

904public:

907};

908

912

913 std::vector Relocations;

915

916public:

922 bool AllowBrokenLinks,

929

935};

936

937

938

939

943 Symbol *Sym = nullptr;

946

947public:

948 template

951

952

954

956

961

966 bool AllowBrokenLinks,

973

977

981};

982

991

1000

1004

1005private:

1007

1008public:

1010

1014 bool AllowBrokenLinks,

1016

1019 return false;

1021 }

1022};

1023

1026

1027private:

1030

1032

1033public:

1034

1038};

1039

1045

1050

1052protected:

1053 std::unique_ptr Obj;

1054

1060

1061public:

1064};

1065

1068 uint8_t NewSymbolVisibility;

1070

1071public:

1073 : MemBuf(MB), NewSymbolVisibility(NewSymbolVisibility) {}

1074

1076};

1077

1079 const std::vector &Records;

1080

1081 void addDataSections();

1082

1083public:

1084 IHexELFBuilder(const std::vector &Records) : Records(Records) {}

1085

1087};

1088

1090private:

1091 using Elf_Addr = typename ELFT::Addr;

1092 using Elf_Shdr = typename ELFT::Shdr;

1093 using Elf_Word = typename ELFT::Word;

1094

1097 size_t EhdrOffset = 0;

1098 std::optional ExtractPartition;

1099

1100 void setParentSegment(Segment &Child);

1104 Error readSectionHeaders();

1105 Error readSections(bool EnsureSymtab);

1106 Error findEhdrOffset();

1108

1109public:

1111 std::optional ExtractPartition);

1112

1114};

1115

1118 uint8_t NewSymbolVisibility;

1119

1120public:

1122 : MemBuf(MB), NewSymbolVisibility(NewSymbolVisibility) {}

1124};

1125

1128

1130 Error parseError(size_t LineNo, Error E) const {

1131 return LineNo == -1U

1132 ? createFileError(MemBuf->getBufferIdentifier(), std::move(E))

1133 : createFileError(MemBuf->getBufferIdentifier(), LineNo,

1134 std::move(E));

1135 }

1136 template <typename... Ts>

1137 Error parseError(size_t LineNo, char const *Fmt, const Ts &...Vals) const {

1139 return parseError(LineNo, std::move(E));

1140 }

1141

1142public:

1144

1146};

1147

1150 std::optional ExtractPartition;

1151

1152public:

1155 : Bin(B), ExtractPartition(ExtractPartition) {}

1156};

1157

1159private:

1160 using SecPtr = std::unique_ptr;

1161 using SegPtr = std::unique_ptr;

1162

1163 std::vector Sections;

1164 std::vector Segments;

1165 std::vector RemovedSections;

1167

1168 static bool sectionIsAlloc(const SectionBase &Sec) {

1170 };

1171

1173

1174public:

1175 template

1178

1179

1180

1181

1182

1183

1184

1187

1197

1203

1205

1209 decltype(&sectionIsAlloc)>>

1213

1217

1219 auto SecIt =

1220 find_if(Sections, [&](const SecPtr &Sec) { return Sec->Name == Name; });

1221 return SecIt == Sections.end() ? nullptr : SecIt->get();

1222 }

1224

1226

1232 template <class T, class... Ts> T &addSection(Ts &&...Args) {

1233 auto Sec = std::make_unique(std::forward(Args)...);

1234 auto Ptr = Sec.get();

1236 Sections.emplace_back(std::move(Sec));

1237 Ptr->Index = Sections.size();

1238 return *Ptr;

1239 }

1242 Segments.emplace_back(std::make_unique(Data));

1243 return *Segments.back();

1244 }

1248};

1249

1250}

1251}

1252}

1253

1254#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

ReachingDefInfo InstSet & ToRemove

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

#define MAKE_SEC_WRITER_FRIEND

Definition ELFObject.h:171

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

This interface provides simple read-only access to a block of memory, and provides simple methods for...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

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

std::string str() const

str - Get the contents as an std::string.

Utility for building string tables with deduplicated suffixes.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

LLVM_ABI std::string str() const

Return the twine contents as a std::string.

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

LLVM Value Representation.

This class is an extension of MemoryBuffer, which allows copy-on-write access to the underlying conte...

An efficient, type-erasing, non-owning reference to a callable.

A range adaptor for a pair of iterators.

Error checkSection(const SectionBase &S) const

ASCIIHexWriter(Object &Obj, raw_ostream &OS, StringRef OutputFile)

Definition ELFObject.h:380

Error finalize() override

StringRef OutputFileName

Definition ELFObject.h:385

std::vector< const SectionBase * > Sections

Definition ELFObject.h:387

virtual Expected< size_t > getTotalSize(WritableMemoryBuffer &EmptyBuffer) const =0

size_t TotalSize

Definition ELFObject.h:386

StringTableSection * addStrTab()

SymbolTableSection * addSymTab(StringTableSection *StrTab)

std::unique_ptr< Object > Obj

Definition ELFObject.h:1053

BinaryELFBuilder(MemoryBuffer *MB, uint8_t NewSymbolVisibility)

Definition ELFObject.h:1072

Expected< std::unique_ptr< Object > > build()

BinaryReader(MemoryBuffer *MB, const uint8_t NewSymbolVisibility)

Definition ELFObject.h:1121

Expected< std::unique_ptr< Object > > create(bool EnsureSymtab) const override

Error visit(const SymbolTableSection &Sec) override

~BinarySectionWriter() override=default

BinarySectionWriter(WritableMemoryBuffer &Buf)

Definition ELFObject.h:193

Error finalize() override

BinaryWriter(Object &Obj, raw_ostream &Out, const CommonConfig &Config)

Definition ELFObject.h:373

~BinaryWriter() override=default

Definition ELFObject.h:663

Error accept(SectionVisitor &Visitor) const override

uint64_t getDecompressedSize() const

Definition ELFObject.h:678

uint64_t getChType() const

Definition ELFObject.h:680

uint64_t getDecompressedAlign() const

Definition ELFObject.h:679

CompressedSection(const SectionBase &Sec, DebugCompressionType CompressionType, bool Is64Bits)

static bool classof(const SectionBase *S)

Definition ELFObject.h:685

Definition ELFObject.h:690

Error accept(SectionVisitor &Visitor) const override

uint32_t ChType

Definition ELFObject.h:694

DecompressedSection(const CompressedSection &Sec)

Definition ELFObject.h:695

Definition ELFObject.h:1002

Error accept(SectionVisitor &) const override

DynamicRelocationSection(ArrayRef< uint8_t > Data)

Definition ELFObject.h:1009

static bool classof(const SectionBase *S)

Definition ELFObject.h:1017

Error removeSectionReferences(bool AllowBrokenLinks, function_ref< bool(const SectionBase *)> ToRemove) override

DynamicSection(ArrayRef< uint8_t > Data)

Definition ELFObject.h:994

static bool classof(const SectionBase *S)

Definition ELFObject.h:996

static bool classof(const SectionBase *S)

Definition ELFObject.h:987

DynamicSymbolTableSection(ArrayRef< uint8_t > Data)

Definition ELFObject.h:985

ELFBuilder(const ELFObjectFile< ELFT > &ElfObj, Object &Obj, std::optional< StringRef > ExtractPartition)

Error build(bool EnsureSymtab)

ELFReader(Binary *B, std::optional< StringRef > ExtractPartition)

Definition ELFObject.h:1154

Expected< std::unique_ptr< Object > > create(bool EnsureSymtab) const override

Definition ELFObject.h:149

Error visit(Section &Sec) override

ELFSectionWriter(WritableMemoryBuffer &Buf)

Definition ELFObject.h:146

~ELFSectionWriter() override=default

Error visit(const SymbolTableSection &Sec) override

bool WriteSectionHeaders

Definition ELFObject.h:350

bool OnlyKeepDebug

Definition ELFObject.h:354

Error finalize() override

~ELFWriter() override=default

ELFWriter(Object &Obj, raw_ostream &Out, bool WSH, bool OnlyKeepDebug)

Definition ELFObject.h:1024

Error accept(SectionVisitor &Visitor) const override

GnuDebugLinkSection(StringRef File, uint32_t PrecomputedCRC)

Definition ELFObject.h:940

GroupSection(ArrayRef< uint8_t > Data)

Definition ELFObject.h:955

ConstRange< SectionBase > members() const

Definition ELFObject.h:974

void setSymTab(const SymbolTableSection *SymTabSec)

Definition ELFObject.h:957

iterator_range< pointee_iterator< typename llvm::SmallVector< T *, 3 >::const_iterator > > ConstRange

Definition ELFObject.h:949

void setSymbol(Symbol *S)

Definition ELFObject.h:958

void replaceSectionReferences(const DenseMap< SectionBase *, SectionBase * > &FromTo) override

Error accept(SectionVisitor &) const override

static bool classof(const SectionBase *S)

Definition ELFObject.h:978

void markSymbols() override

ArrayRef< uint8_t > Contents

Definition ELFObject.h:953

void addMember(SectionBase *Sec)

Definition ELFObject.h:960

Error removeSectionReferences(bool AllowBrokenLinks, function_ref< bool(const SectionBase *)> ToRemove) override

void setFlagWord(ELF::Elf32_Word W)

Definition ELFObject.h:959

Error removeSymbols(function_ref< bool(const Symbol &)> ToRemove) override

IHexELFBuilder(const std::vector< IHexRecord > &Records)

Definition ELFObject.h:1084

Expected< std::unique_ptr< Object > > build()

IHexReader(MemoryBuffer *MB)

Definition ELFObject.h:1143

Expected< std::unique_ptr< Object > > create(bool EnsureSymtab) const override

uint64_t getBufferOffset() const

Definition ELFObject.h:293

IHexSectionWriterBase(WritableMemoryBuffer &Buf)

Definition ELFObject.h:290

void writeSection(const SectionBase *Sec, ArrayRef< uint8_t > Data)

Error visit(const Section &Sec) final

uint64_t Offset

Definition ELFObject.h:284

virtual void writeData(uint8_t Type, uint16_t Addr, ArrayRef< uint8_t > Data)

IHexSectionWriter(WritableMemoryBuffer &Buf)

Definition ELFObject.h:304

void writeData(uint8_t Type, uint16_t Addr, ArrayRef< uint8_t > Data) override

Error visit(const StringTableSection &Sec) override

IHexWriter(Object &Obj, raw_ostream &Out, StringRef OutputFile)

Definition ELFObject.h:397

Definition ELFObject.h:90

virtual Error visit(OwnedDataSection &Sec)=0

virtual Error visit(SymbolTableSection &Sec)=0

virtual Error visit(DecompressedSection &Sec)=0

virtual Error visit(StringTableSection &Sec)=0

virtual Error visit(GnuDebugLinkSection &Sec)=0

virtual ~MutableSectionVisitor()=default

virtual Error visit(SectionIndexSection &Sec)=0

virtual Error visit(DynamicRelocationSection &Sec)=0

virtual Error visit(Section &Sec)=0

virtual Error visit(GroupSection &Sec)=0

virtual Error visit(CompressedSection &Sec)=0

virtual Error visit(RelocationSection &Sec)=0

Definition ELFObject.h:1158

uint32_t Flags

Definition ELFObject.h:1196

iterator_range< pointee_iterator< typename std::vector< std::unique_ptr< T > >::const_iterator > > ConstRange

Definition ELFObject.h:1176

SectionTableRef sections() const

Definition ELFObject.h:1206

uint32_t Version

Definition ELFObject.h:1195

StringTableSection * SectionNames

Definition ELFObject.h:1200

SectionTableRef removedSections()

Definition ELFObject.h:1223

bool isRelocatable() const

Definition ELFObject.h:1245

uint32_t Type

Definition ELFObject.h:1193

iterator_range< filter_iterator< pointee_iterator< std::vector< SecPtr >::const_iterator >, decltype(&sectionIsAlloc)> > allocSections() const

Definition ELFObject.h:1210

uint8_t ABIVersion

Definition ELFObject.h:1190

bool Is64Bits

Definition ELFObject.h:1188

uint64_t SHOff

Definition ELFObject.h:1192

Error updateSection(StringRef Name, ArrayRef< uint8_t > Data)

SectionIndexSection * SectionIndexTable

Definition ELFObject.h:1202

bool MustBeRelocatable

Definition ELFObject.h:1199

Error removeSymbols(function_ref< bool(const Symbol &)> ToRemove)

bool IsMips64EL

Definition ELFObject.h:1204

T & addSection(Ts &&...Args)

Definition ELFObject.h:1232

bool HadShdrs

Definition ELFObject.h:1198

Error removeSections(bool AllowBrokenLinks, std::function< bool(const SectionBase &)> ToRemove)

Segment & addSegment(ArrayRef< uint8_t > Data)

Definition ELFObject.h:1241

ConstRange< Segment > segments() const

Definition ELFObject.h:1225

SymbolTableSection * SymbolTable

Definition ELFObject.h:1201

Segment ProgramHdrSegment

Definition ELFObject.h:1186

Error compressOrDecompressSections(const CommonConfig &Config)

uint32_t Machine

Definition ELFObject.h:1194

Segment ElfHdrSegment

Definition ELFObject.h:1185

const auto & getUpdatedSections() const

Definition ELFObject.h:1214

SectionBase * findSection(StringRef Name)

Definition ELFObject.h:1218

uint8_t OSABI

Definition ELFObject.h:1189

Error addNewSymbolTable()

uint64_t Entry

Definition ELFObject.h:1191

Error replaceSections(const DenseMap< SectionBase *, SectionBase * > &FromTo)

Definition ELFObject.h:628

void appendHexData(StringRef HexData)

ArrayRef< uint8_t > getContents() const override

Definition ELFObject.h:660

OwnedDataSection(const Twine &SecName, uint64_t SecAddr, uint64_t SecFlags, uint64_t SecOff)

Definition ELFObject.h:642

Error accept(SectionVisitor &Sec) const override

OwnedDataSection(StringRef SecName, ArrayRef< uint8_t > Data)

Definition ELFObject.h:634

OwnedDataSection(SectionBase &S, ArrayRef< uint8_t > Data)

Definition ELFObject.h:651

bool hasContents() const override

Definition ELFObject.h:659

Definition ELFObject.h:1040

virtual Expected< std::unique_ptr< Object > > create(bool EnsureSymtab) const =0

RelocSectionWithSymtabBase()=default

Error initialize(SectionTableRef SecTable) override

SymTabType * Symbols

Definition ELFObject.h:902

Definition ELFObject.h:877

const SectionBase * getSection() const

Definition ELFObject.h:882

SectionBase * SecToApplyRel

Definition ELFObject.h:879

StringRef getNamePrefix() const

void setSection(SectionBase *Sec)

Definition ELFObject.h:883

static bool classof(const SectionBase *S)

Definition ELFObject.h:887

Definition ELFObject.h:910

void markSymbols() override

const Object & getObject() const

Definition ELFObject.h:928

void addRelocation(const Relocation &Rel)

Definition ELFObject.h:918

Error accept(SectionVisitor &Visitor) const override

RelocationSection(const Object &O)

Definition ELFObject.h:917

Error removeSymbols(function_ref< bool(const Symbol &)> ToRemove) override

void replaceSectionReferences(const DenseMap< SectionBase *, SectionBase * > &FromTo) override

static bool classof(const SectionBase *S)

Definition ELFObject.h:930

Error removeSectionReferences(bool AllowBrokenLinks, function_ref< bool(const SectionBase *)> ToRemove) override

uint8_t Type

Definition ELFObject.h:481

uint64_t HeaderSize

Definition ELFObject.h:479

uint64_t getBufferOffset() const

Definition ELFObject.h:468

std::vector< SRecord > Records

Definition ELFObject.h:482

virtual void writeRecord(SRecord &Record, uint64_t Off)=0

uint64_t Offset

Definition ELFObject.h:477

void writeSection(const SectionBase &S, ArrayRef< uint8_t > Data)

Error visit(const Section &S) override

void writeRecords(uint32_t Entry)

SRECSectionWriterBase(WritableMemoryBuffer &Buf, uint64_t StartOffset)

Definition ELFObject.h:460

uint8_t getType() const

Definition ELFObject.h:473

Error visit(const StringTableSection &Sec) override

void writeRecord(SRecord &Record, uint64_t Off) override

SRECSectionWriter(WritableMemoryBuffer &Buf, uint64_t Offset)

Definition ELFObject.h:501

SRECSizeCalculator(WritableMemoryBuffer &EmptyBuffer, uint64_t Offset)

Definition ELFObject.h:492

void writeRecord(SRecord &Record, uint64_t Off) override

Definition ELFObject.h:496

SRECWriter(Object &Obj, raw_ostream &OS, StringRef OutputFile)

Definition ELFObject.h:409

Definition ELFObject.h:509

virtual void markSymbols()

uint64_t OriginalOffset

Definition ELFObject.h:519

ArrayRef< uint8_t > OriginalData

Definition ELFObject.h:531

bool HasSymbol

Definition ELFObject.h:532

uint32_t OriginalIndex

Definition ELFObject.h:516

virtual Error initialize(SectionTableRef SecTable)

virtual Error removeSectionReferences(bool AllowBrokenLinks, function_ref< bool(const SectionBase *)> ToRemove)

virtual void restoreSymTabLink(SymbolTableSection &)

Definition ELFObject.h:556

virtual ArrayRef< uint8_t > getContents() const

Definition ELFObject.h:552

uint64_t Type

Definition ELFObject.h:530

virtual void replaceSectionReferences(const DenseMap< SectionBase *, SectionBase * > &)

uint64_t HeaderOffset

Definition ELFObject.h:513

Segment * ParentSegment

Definition ELFObject.h:512

uint64_t Flags

Definition ELFObject.h:524

virtual Error accept(MutableSectionVisitor &Visitor)=0

std::string Name

Definition ELFObject.h:511

uint64_t Link

Definition ELFObject.h:526

uint64_t Size

Definition ELFObject.h:529

uint64_t OriginalType

Definition ELFObject.h:518

virtual ~SectionBase()=default

uint64_t Align

Definition ELFObject.h:522

uint32_t EntrySize

Definition ELFObject.h:523

uint64_t Offset

Definition ELFObject.h:528

uint64_t Info

Definition ELFObject.h:525

uint64_t OriginalFlags

Definition ELFObject.h:517

uint64_t Addr

Definition ELFObject.h:521

virtual bool hasContents() const

Definition ELFObject.h:551

SectionBase(const SectionBase &)=default

uint64_t NameIndex

Definition ELFObject.h:527

uint32_t Index

Definition ELFObject.h:514

virtual Error removeSymbols(function_ref< bool(const Symbol &)> ToRemove)

virtual Error accept(SectionVisitor &Visitor) const =0

Definition ELFObject.h:779

void addIndex(uint32_t Index)

Definition ELFObject.h:788

~SectionIndexSection() override=default

void setSymTab(SymbolTableSection *SymTab)

Definition ELFObject.h:797

Error accept(SectionVisitor &Visitor) const override

SectionIndexSection()

Definition ELFObject.h:803

void reserve(size_t NumSymbols)

Definition ELFObject.h:793

Error initialize(SectionTableRef SecTable) override

Definition ELFObject.h:50

pointee_iterator< const std::unique_ptr< SectionBase > * > iterator

Definition ELFObject.h:54

Expected< T * > getSectionOfType(uint32_t Index, Twine IndexErrMsg, Twine TypeErrMsg)

iterator begin() const

Definition ELFObject.h:60

SectionTableRef(ArrayRef< std::unique_ptr< SectionBase > > Secs)

Definition ELFObject.h:56

SectionTableRef(const SectionTableRef &)=default

iterator end() const

Definition ELFObject.h:61

Expected< SectionBase * > getSection(uint32_t Index, Twine ErrMsg)

size_t size() const

Definition ELFObject.h:62

Definition ELFObject.h:73

virtual Error visit(const CompressedSection &Sec)=0

virtual Error visit(const Section &Sec)=0

virtual Error visit(const DecompressedSection &Sec)=0

virtual ~SectionVisitor()=default

virtual Error visit(const GroupSection &Sec)=0

virtual Error visit(const SymbolTableSection &Sec)=0

virtual Error visit(const RelocationSection &Sec)=0

virtual Error visit(const SectionIndexSection &Sec)=0

virtual Error visit(const DynamicRelocationSection &Sec)=0

virtual Error visit(const GnuDebugLinkSection &Sec)=0

virtual Error visit(const StringTableSection &Sec)=0

virtual Error visit(const OwnedDataSection &Sec)=0

Error visit(const GroupSection &Sec) override=0

Error visit(const RelocationSection &Sec) override=0

Error visit(const SectionIndexSection &Sec) override=0

Error visit(const CompressedSection &Sec) override=0

Error visit(const Section &Sec) override

Error visit(const GnuDebugLinkSection &Sec) override=0

Error visit(const SymbolTableSection &Sec) override=0

~SectionWriter() override=default

WritableMemoryBuffer & Out

Definition ELFObject.h:109

Error visit(const DecompressedSection &Sec) override=0

SectionWriter(WritableMemoryBuffer &Buf)

Definition ELFObject.h:126

Definition ELFObject.h:603

Error removeSectionReferences(bool AllowBrokenLinks, function_ref< bool(const SectionBase *)> ToRemove) override

Error initialize(SectionTableRef SecTable) override

ArrayRef< uint8_t > getContents() const override

Definition ELFObject.h:623

Section(ArrayRef< uint8_t > Data)

Definition ELFObject.h:611

void restoreSymTabLink(SymbolTableSection &SymTab) override

bool hasContents() const override

Definition ELFObject.h:620

Error accept(SectionVisitor &Visitor) const override

Definition ELFObject.h:559

void addSection(const SectionBase *Sec)

Definition ELFObject.h:598

Segment(ArrayRef< uint8_t > Data)

Definition ELFObject.h:588

uint64_t PAddr

Definition ELFObject.h:577

Segment * ParentSegment

Definition ELFObject.h:584

ArrayRef< uint8_t > Contents

Definition ELFObject.h:585

uint32_t Type

Definition ELFObject.h:573

uint64_t FileSize

Definition ELFObject.h:578

uint32_t Index

Definition ELFObject.h:582

void removeSection(const SectionBase *Sec)

Definition ELFObject.h:597

const SectionBase * firstSection() const

Definition ELFObject.h:591

uint64_t Align

Definition ELFObject.h:580

uint64_t OriginalOffset

Definition ELFObject.h:583

uint64_t VAddr

Definition ELFObject.h:576

uint64_t MemSize

Definition ELFObject.h:579

uint64_t Offset

Definition ELFObject.h:575

ArrayRef< uint8_t > getContents() const

Definition ELFObject.h:600

uint32_t Flags

Definition ELFObject.h:574

std::set< const SectionBase *, SectionCompare > Sections

Definition ELFObject.h:586

Definition ELFObject.h:714

void addString(StringRef Name)

static bool classof(const SectionBase *S)

Definition ELFObject.h:730

StringTableSection()

Definition ELFObject.h:720

uint32_t findIndex(StringRef Name) const

Error accept(SectionVisitor &Visitor) const override

Definition ELFObject.h:811

const SectionBase * getStrTab() const

Definition ELFObject.h:840

Error removeSectionReferences(bool AllowBrokenLinks, function_ref< bool(const SectionBase *)> ToRemove) override

const SectionIndexSection * getShndxTable() const

Definition ELFObject.h:838

std::vector< std::unique_ptr< Symbol > > Symbols

Definition ELFObject.h:818

SectionIndexSection * SectionIndexTable

Definition ELFObject.h:820

Error accept(SectionVisitor &Visitor) const override

bool empty() const

Definition ELFObject.h:833

void addSymbol(Twine Name, uint8_t Bind, uint8_t Type, SectionBase *DefinedIn, uint64_t Value, uint8_t Visibility, uint16_t Shndx, uint64_t SymbolSize)

void updateSymbols(function_ref< void(Symbol &)> Callable)

static bool classof(const SectionBase *S)

Definition ELFObject.h:856

bool indicesChanged() const

Definition ELFObject.h:834

Expected< const Symbol * > getSymbolByIndex(uint32_t Index) const

Error removeSymbols(function_ref< bool(const Symbol &)> ToRemove) override

bool IndicesChanged

Definition ELFObject.h:821

Error initialize(SectionTableRef SecTable) override

void replaceSectionReferences(const DenseMap< SectionBase *, SectionBase * > &FromTo) override

std::unique_ptr< Symbol > SymPtr

Definition ELFObject.h:823

void setShndxTable(SectionIndexSection *ShndxTable)

Definition ELFObject.h:835

SymbolTableSection()

Definition ELFObject.h:826

StringTableSection * SymbolNames

Definition ELFObject.h:819

virtual Error finalize()=0

raw_ostream & Out

Definition ELFObject.h:314

Object & Obj

Definition ELFObject.h:312

std::unique_ptr< WritableMemoryBuffer > Buf

Definition ELFObject.h:313

Writer(Object &O, raw_ostream &Out)

Definition ELFObject.h:321

This class implements an extremely fast bulk output stream that can only output to a stream.

ElfType

Definition ELFObject.h:71

@ ELFT_ELF64BE

Definition ELFObject.h:71

@ ELFT_ELF32BE

Definition ELFObject.h:71

@ ELFT_ELF64LE

Definition ELFObject.h:71

@ ELFT_ELF32LE

Definition ELFObject.h:71

SmallVector< char, 64 > IHexLineData

Definition ELFObject.h:197

SmallVector< char, 64 > SRecLineData

Definition ELFObject.h:420

SymbolShndxType

Definition ELFObject.h:741

@ SYMBOL_HEXAGON_SCOMMON_8

Definition ELFObject.h:750

@ SYMBOL_XINDEX

Definition ELFObject.h:759

@ SYMBOL_MIPS_ACOMMON

Definition ELFObject.h:751

@ SYMBOL_HEXAGON_SCOMMON_4

Definition ELFObject.h:749

@ SYMBOL_LOOS

Definition ELFObject.h:757

@ SYMBOL_MIPS_SUNDEFINED

Definition ELFObject.h:755

@ SYMBOL_MIPS_DATA

Definition ELFObject.h:753

@ SYMBOL_MIPS_SCOMMON

Definition ELFObject.h:754

@ SYMBOL_LOPROC

Definition ELFObject.h:745

@ SYMBOL_AMDGPU_LDS

Definition ELFObject.h:746

@ SYMBOL_COMMON

Definition ELFObject.h:744

@ SYMBOL_HEXAGON_SCOMMON

Definition ELFObject.h:747

@ SYMBOL_SIMPLE_INDEX

Definition ELFObject.h:742

@ SYMBOL_HEXAGON_SCOMMON_2

Definition ELFObject.h:748

@ SYMBOL_ABS

Definition ELFObject.h:743

@ SYMBOL_HIPROC

Definition ELFObject.h:756

@ SYMBOL_HIOS

Definition ELFObject.h:758

@ SYMBOL_MIPS_TEXT

Definition ELFObject.h:752

This is an optimization pass for GlobalISel generic memory operations.

Error createFileError(const Twine &F, Error E)

Concatenate a source file path and/or name with an Error.

FunctionAddr VTableAddr uintptr_t uintptr_t DataSize

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

iterator_range< pointee_iterator< WrappedIteratorT > > make_pointee_range(RangeT &&Range)

iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)

Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

FunctionAddr VTableAddr uintptr_t uintptr_t Data

auto find_if(R &&Range, UnaryPredicate P)

Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.

bool is_contained(R &&Range, const E &Element)

Returns true if Element is found in Range.

filter_iterator_impl< WrappedIteratorT, PredicateT, detail::fwd_or_bidi_tag< WrappedIteratorT > > filter_iterator

Defines filter_iterator to a suitable specialization of filter_iterator_impl, based on the underlying...

Implement std::hash so that hash_code can be used in STL containers.

Definition ELFObject.h:199

Type

Definition ELFObject.h:233

@ StartAddr

Definition ELFObject.h:262

@ InvalidType

Definition ELFObject.h:264

@ StartAddr80x86

Definition ELFObject.h:253

@ EndOfFile

Definition ELFObject.h:240

@ Data

Definition ELFObject.h:236

@ SegmentAddr

Definition ELFObject.h:248

@ ExtendedAddr

Definition ELFObject.h:258

uint16_t Addr

Definition ELFObject.h:201

static IHexLineData getLine(uint8_t Type, uint16_t Addr, ArrayRef< uint8_t > Data)

static uint8_t getChecksum(StringRef S)

static Expected< IHexRecord > parse(StringRef Line)

static size_t getLength(size_t DataSize)

Definition ELFObject.h:209

static size_t getLineLength(size_t DataSize)

Definition ELFObject.h:215

StringRef HexData

Definition ELFObject.h:205

Definition ELFObject.h:861

uint64_t Addend

Definition ELFObject.h:864

Symbol * RelocSymbol

Definition ELFObject.h:862

uint32_t Type

Definition ELFObject.h:865

uint64_t Offset

Definition ELFObject.h:863

Definition ELFObject.h:421

uint32_t Address

Definition ELFObject.h:423

uint8_t getAddressSize() const

Type

Definition ELFObject.h:434

@ S8

Definition ELFObject.h:452

@ S1

Definition ELFObject.h:438

@ S5

Definition ELFObject.h:446

@ S2

Definition ELFObject.h:440

@ S4

Definition ELFObject.h:444

@ S3

Definition ELFObject.h:442

@ S7

Definition ELFObject.h:450

@ S6

Definition ELFObject.h:448

@ S0

Definition ELFObject.h:436

@ S9

Definition ELFObject.h:454

static SRecord getHeader(StringRef FileName)

uint8_t getChecksum() const

SRecLineData toString() const

static uint8_t getType(uint32_t Address)

ArrayRef< uint8_t > Data

Definition ELFObject.h:424

Definition ELFObject.h:762

uint8_t Type

Definition ELFObject.h:770

uint64_t Size

Definition ELFObject.h:769

uint16_t getShndx() const

std::string Name

Definition ELFObject.h:767

uint8_t Visibility

Definition ELFObject.h:772

uint32_t NameIndex

Definition ELFObject.h:768

SectionBase * DefinedIn

Definition ELFObject.h:764

uint8_t Binding

Definition ELFObject.h:763

uint64_t Value

Definition ELFObject.h:771

SymbolShndxType ShndxType

Definition ELFObject.h:765

bool Referenced

Definition ELFObject.h:773

uint32_t Index

Definition ELFObject.h:766

An iterator type that allows iterating over the pointees via some other iterator.