LLVM: lib/ObjCopy/wasm/WasmObjcopy.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

16

17namespace llvm {

19namespace wasm {

20

21using namespace object;

23

27

31

33

34

35

37 return Sec.Name == "producers";

38}

39

42 for (const Section &Sec : Obj.Sections) {

43 if (Sec.Name == SecName) {

47 if (!BufferOrErr)

49 std::unique_ptr Buf = std::move(*BufferOrErr);

50 llvm::copy(Contents, Buf->getBufferStart());

51 if (Error E = Buf->commit())

54 }

55 }

57 "section '%s' not found", SecName.str().c_str());

58}

59

62

63

65 RemovePred = [&Config](const Section &Sec) {

67 };

68 }

69

71 RemovePred = [RemovePred](const Section &Sec) {

73 };

74 }

75

77 RemovePred = [RemovePred](const Section &Sec) {

80 };

81 }

82

84 RemovePred = [&Config](const Section &Sec) {

85

86

88 };

89 }

90

92 RemovePred = [&Config](const Section &Sec) {

93

94

96 };

97 }

98

100 RemovePred = [&Config, RemovePred](const Section &Sec) {

101

103 return false;

104

105 return RemovePred(Sec);

106 };

107 }

108

109 Obj.removeSections(RemovePred);

110}

111

113

117 std::tie(SecName, FileName) = Flag.split("=");

120 return E;

121 }

122

124

129

132 NewSection.SectionData->getBufferSize());

134 InputData, NewSection.SectionData->getBufferIdentifier());

136 reinterpret_cast<const uint8_t *>(BufferCopy->getBufferStart()),

137 BufferCopy->getBufferSize());

138

139 Obj.addSectionWithOwnedContents(Sec, std::move(BufferCopy));

140 }

141

143}

144

147 Reader TheReader(In);

149 if (!ObjOrErr)

152 assert(Obj && "Unable to deserialize Wasm object");

154 return E;

155 Writer TheWriter(*Obj, Out);

159}

160

161}

162}

163}

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

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

static cl::opt< std::string > InputFilename(cl::Positional, cl::desc(""), cl::init("-"))

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

size_t size() const

size - Get the array size.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

reference get()

Returns a reference to the stored T value.

static LLVM_ABI Expected< std::unique_ptr< FileOutputBuffer > > create(StringRef FilePath, size_t Size, unsigned Flags=0)

Factory method to create an OutputBuffer object which manages a read/write buffer of the specified si...

static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")

Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.

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

std::string str() const

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

bool starts_with(StringRef Prefix) const

Check if this string starts with the given Prefix.

bool matches(StringRef S) const

Expected< std::unique_ptr< Object > > create() const

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

static bool isCommentSection(const Section &Sec)

Definition WasmObjcopy.cpp:36

static void removeSections(const CommonConfig &Config, Object &Obj)

Definition WasmObjcopy.cpp:60

static Error handleArgs(const CommonConfig &Config, Object &Obj)

Definition WasmObjcopy.cpp:112

static bool isDebugSection(const Section &Sec)

Definition WasmObjcopy.cpp:24

static Error dumpSectionToFile(StringRef SecName, StringRef Filename, StringRef InputFilename, Object &Obj)

Definition WasmObjcopy.cpp:40

static bool isNameSection(const Section &Sec)

Definition WasmObjcopy.cpp:32

static bool isLinkerSection(const Section &Sec)

Definition WasmObjcopy.cpp:28

LLVM_ABI Error executeObjcopyOnBinary(const CommonConfig &Config, const WasmConfig &, object::WasmObjectFile &In, raw_ostream &Out)

Apply the transformations described by Config and WasmConfig to In and writes the result into Out.

Definition WasmObjcopy.cpp:145

std::function< bool(const Section &Sec)> SectionPred

Definition WasmObjcopy.cpp:22

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.

OutputIt copy(R &&Range, OutputIt Out)

SmallVector< StringRef, 0 > DumpSection

SmallVector< NewSectionInfo, 0 > AddSection

std::shared_ptr< MemoryBuffer > SectionData

ArrayRef< uint8_t > Contents