LLVM: lib/ObjCopy/MachO/MachOObject.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_LIB_OBJCOPY_MACHO_MACHOOBJECT_H

10#define LLVM_LIB_OBJCOPY_MACHO_MACHOOBJECT_H

11

18#include

19#include

20#include

21

22namespace llvm {

25

36

42

46

58

60

62

66

72

76};

77

79

80

81

83

84

85

86

88

89

90

91

92

93 std::vector<std::unique_ptr

> Sections;

94

95

97

98

100};

101

102

103

112

114

116

120

125

126 std::optional<uint32_t> section() const {

128 : std::optional<uint32_t>(n_sect);

129 }

130};

131

132

133

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

136

139

142

148};

149

151

152

154

155

156 std::optional<SymbolEntry *> Symbol;

157

159 std::optional<SymbolEntry *> Symbol)

161};

162

164 std::vector Symbols;

165};

166

167

168

172

174

175 std::optional<const SymbolEntry *> Symbol;

176

177 std::optional<const Section *> Sec;

178

180

181

183

186

188 if (IsLittleEndian)

189 return Info.r_word1 & 0xffffff;

190 return Info.r_word1 >> 8;

191 }

192

194 assert(SymbolNum < (1 << 24) && "SymbolNum out of range");

195 if (IsLittleEndian)

196 Info.r_word1 = (Info.r_word1 & ~0x00ffffff) | SymbolNum;

197 else

198 Info.r_word1 = (Info.r_word1 & ~0xffffff00) | (SymbolNum << 8);

199 }

200};

201

202

203

204

205

206

207

208

209

210

211

217

218

219

220

221

222

223

224

225

226

227

233

234

235

236

237

238

239

240

241

242

243

244

245

251

252

253

254

255

256

257

258

259

260

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

294

298

302

305

318

320

321

323

325

327

329

331

333

335

337

339

341

342

344

347

349

352

354

356

357

358

359

361

366

368};

369

370}

371}

372}

373

374#endif

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

ReachingDefInfo InstSet & ToRemove

This file declares classes for handling the YAML representation of DWARF Debug Info.

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

Lightweight error class with error context and mandatory checking.

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

bool starts_with(StringRef Prefix) const

Check if this string starts with the given Prefix.

Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.

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

SectionType

These are the section type and attributes fields.

@ S_GB_ZEROFILL

S_GB_ZEROFILL - Zero fill on demand section (that can be larger than 4 gigabytes).

@ S_THREAD_LOCAL_ZEROFILL

S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section.

@ S_ZEROFILL

S_ZEROFILL - Zero fill on demand section.

This is an optimization pass for GlobalISel generic memory operations.

BumpPtrAllocatorImpl<> BumpPtrAllocator

The standard BumpPtrAllocator which just uses the default template parameters.

The location of the bind info inside the binary is described by LC_DYLD_INFO load command.

Definition MachOObject.h:228

ArrayRef< uint8_t > Opcodes

Definition MachOObject.h:231

The location of the export info inside the binary is described by LC_DYLD_INFO load command.

Definition MachOObject.h:291

ArrayRef< uint8_t > Trie

Definition MachOObject.h:292

std::optional< SymbolEntry * > Symbol

The Symbol referenced by this entry.

Definition MachOObject.h:156

IndirectSymbolEntry(uint32_t OriginalIndex, std::optional< SymbolEntry * > Symbol)

Definition MachOObject.h:158

uint32_t OriginalIndex

Definition MachOObject.h:153

Definition MachOObject.h:163

std::vector< IndirectSymbolEntry > Symbols

Definition MachOObject.h:164

The location of the lazy bind info inside the binary is described by LC_DYLD_INFO load command.

Definition MachOObject.h:261

ArrayRef< uint8_t > Opcodes

Definition MachOObject.h:262

Definition MachOObject.h:295

ArrayRef< uint8_t > Data

Definition MachOObject.h:296

Definition MachOObject.h:78

MachO::macho_load_command MachOLoadCommand

Definition MachOObject.h:82

std::optional< StringRef > getSegmentName() const

std::vector< std::unique_ptr< Section > > Sections

Definition MachOObject.h:93

std::optional< uint64_t > getSegmentVMAddr() const

std::vector< uint8_t > Payload

Definition MachOObject.h:87

std::optional< size_t > FunctionStartsCommandIndex

The index LC_FUNCTION_STARTS load command if present.

Definition MachOObject.h:336

StringTable StrTable

Definition MachOObject.h:304

void updateLoadCommandIndexes()

StringSaver NewSectionsContents

Definition MachOObject.h:346

Error removeLoadCommands(function_ref< bool(const LoadCommand &)> ToRemove)

std::optional< size_t > ChainedFixupsCommandIndex

The index LC_DYLD_CHAINED_FIXUPS load command if present.

Definition MachOObject.h:338

BumpPtrAllocator Alloc

Definition MachOObject.h:345

std::optional< size_t > ExportsTrieCommandIndex

The index LC_DYLD_EXPORTS_TRIE load command if present.

Definition MachOObject.h:340

RebaseInfo Rebases

Definition MachOObject.h:306

Error removeSections(function_ref< bool(const std::unique_ptr< Section > &)> ToRemove)

std::optional< size_t > DylibCodeSignDRsIndex

The index of LC_DYLIB_CODE_SIGN_DRS load command if present.

Definition MachOObject.h:324

std::optional< size_t > SymTabCommandIndex

The index of LC_SYMTAB load command if present.

Definition MachOObject.h:326

std::optional< size_t > DyLdInfoCommandIndex

The index of LC_DYLD_INFO or LC_DYLD_INFO_ONLY load command if present.

Definition MachOObject.h:328

Object()

Definition MachOObject.h:348

SymbolTable SymTable

Definition MachOObject.h:303

std::vector< LoadCommand > LoadCommands

Definition MachOObject.h:301

std::optional< size_t > DataInCodeCommandIndex

The index LC_DATA_IN_CODE load command if present.

Definition MachOObject.h:332

bool is64Bit() const

Definition MachOObject.h:362

std::optional< uint32_t > SwiftVersion

Definition MachOObject.h:319

BindInfo Binds

Definition MachOObject.h:307

std::optional< size_t > DySymTabCommandIndex

The index LC_DYSYMTAB load command if present.

Definition MachOObject.h:330

LinkData LinkerOptimizationHint

Definition MachOObject.h:313

std::optional< size_t > TextSegmentCommandIndex

The index of the LC_SEGMENT or LC_SEGMENT_64 load command corresponding to the __TEXT segment.

Definition MachOObject.h:343

LinkData ExportsTrie

Definition MachOObject.h:315

ExportInfo Exports

Definition MachOObject.h:310

LinkData FunctionStarts

Definition MachOObject.h:314

LazyBindInfo LazyBinds

Definition MachOObject.h:309

MachHeader Header

Definition MachOObject.h:300

IndirectSymbolTable IndirectSymTable

Definition MachOObject.h:311

LinkData ChainedFixups

Definition MachOObject.h:316

uint64_t nextAvailableSegmentAddress() const

LinkData DylibCodeSignDRs

Definition MachOObject.h:317

std::optional< size_t > CodeSignatureCommandIndex

The index of LC_CODE_SIGNATURE load command if present.

Definition MachOObject.h:322

WeakBindInfo WeakBinds

Definition MachOObject.h:308

LoadCommand & addSegment(StringRef SegName, uint64_t SegVMSize)

Creates a new segment load command in the object and returns a reference to the newly created load co...

std::optional< size_t > LinkerOptimizationHintCommandIndex

The index of LC_LINKER_OPTIMIZATIN_HINT load command if present.

Definition MachOObject.h:334

LinkData DataInCode

Definition MachOObject.h:312

The location of the rebase info inside the binary is described by LC_DYLD_INFO load command.

Definition MachOObject.h:212

ArrayRef< uint8_t > Opcodes

Definition MachOObject.h:215

Definition MachOObject.h:173

MachO::any_relocation_info Info

Definition MachOObject.h:185

std::optional< const SymbolEntry * > Symbol

Definition MachOObject.h:175

bool Scattered

Definition MachOObject.h:179

std::optional< const Section * > Sec

Definition MachOObject.h:177

bool IsAddend

Definition MachOObject.h:182

unsigned getPlainRelocationSymbolNum(bool IsLittleEndian)

Definition MachOObject.h:187

void setPlainRelocationSymbolNum(unsigned SymbolNum, bool IsLittleEndian)

Definition MachOObject.h:193

bool Extern

Definition MachOObject.h:184

uint32_t Flags

Definition MachOObject.h:52

uint32_t NReloc

Definition MachOObject.h:51

uint32_t Align

Definition MachOObject.h:49

uint64_t Addr

Definition MachOObject.h:44

std::string Segname

Definition MachOObject.h:40

uint32_t Reserved3

Definition MachOObject.h:55

StringRef Content

Definition MachOObject.h:56

Section(StringRef SegName, StringRef SectName)

std::optional< uint32_t > OriginalOffset

Definition MachOObject.h:47

uint32_t RelOff

Definition MachOObject.h:50

bool isBssSection() const

Definition MachOObject.h:67

bool hasValidOffset() const

Definition MachOObject.h:73

uint32_t Reserved2

Definition MachOObject.h:54

std::vector< RelocationInfo > Relocations

Definition MachOObject.h:57

std::string CanonicalName

Definition MachOObject.h:43

uint32_t Index

Definition MachOObject.h:39

uint32_t Offset

Definition MachOObject.h:48

MachO::SectionType getType() const

Definition MachOObject.h:63

std::string Sectname

Definition MachOObject.h:41

uint32_t Reserved1

Definition MachOObject.h:53

uint64_t Size

Definition MachOObject.h:45

The location of the string table inside the binary is described by LC_SYMTAB load command.

Definition MachOObject.h:169

std::vector< std::string > Strings

Definition MachOObject.h:170

Definition MachOObject.h:104

uint8_t n_type

Definition MachOObject.h:108

bool isExternalSymbol() const

Definition MachOObject.h:113

std::optional< uint32_t > section() const

Definition MachOObject.h:126

bool isUndefinedSymbol() const

Definition MachOObject.h:117

bool Referenced

Definition MachOObject.h:106

bool isSwiftSymbol() const

Definition MachOObject.h:121

std::string Name

Definition MachOObject.h:105

uint32_t Index

Definition MachOObject.h:107

uint8_t n_sect

Definition MachOObject.h:109

uint64_t n_value

Definition MachOObject.h:111

bool isLocalSymbol() const

Definition MachOObject.h:115

uint16_t n_desc

Definition MachOObject.h:110

The location of the symbol table inside the binary is described by LC_SYMTAB load command.

Definition MachOObject.h:134

iterator end() const

Definition MachOObject.h:141

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

const SymbolEntry * getSymbolByIndex(uint32_t Index) const

std::vector< std::unique_ptr< SymbolEntry > > Symbols

Definition MachOObject.h:135

void removeSymbols(function_ref< bool(const std::unique_ptr< SymbolEntry > &)> ToRemove)

pointee_iterator< std::vector< std::unique_ptr< SymbolEntry > >::const_iterator > iterator

Definition MachOObject.h:137

iterator begin() const

Definition MachOObject.h:140

The location of the weak bind info inside the binary is described by LC_DYLD_INFO load command.

Definition MachOObject.h:246

ArrayRef< uint8_t > Opcodes

Definition MachOObject.h:249

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