Lines Matching +full:static +full:- +full:config
1 //===- WasmObjcopy.cpp ----------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
24 static bool isDebugSection(const Section &Sec) {
28 static bool isLinkerSection(const Section &Sec) {
32 static bool isNameSection(const Section &Sec) { return Sec.Name == "name"; }
36 static bool isCommentSection(const Section &Sec) {
40 static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
50 std::copy(Contents.begin(), Contents.end(), Buf->getBufferStart());
51 if (Error E = Buf->commit())
60 static void removeSections(const CommonConfig &Config, Object &Obj) {
63 // Explicitly-requested sections.
64 if (!Config.ToRemove.empty()) {
65 RemovePred = [&Config](const Section &Sec) {
66 return Config.ToRemove.matches(Sec.Name);
70 if (Config.StripDebug) {
76 if (Config.StripAll) {
83 if (Config.OnlyKeepDebug) {
84 RemovePred = [&Config](const Section &Sec) {
87 return Config.ToRemove.matches(Sec.Name) || !isDebugSection(Sec);
91 if (!Config.OnlySection.empty()) {
92 RemovePred = [&Config](const Section &Sec) {
95 return !Config.OnlySection.matches(Sec.Name);
99 if (!Config.KeepSection.empty()) {
100 RemovePred = [&Config, RemovePred](const Section &Sec) {
102 if (Config.KeepSection.matches(Sec.Name))
112 static Error handleArgs(const CommonConfig &Config, Object &Obj) {
114 for (StringRef Flag : Config.DumpSection) {
122 removeSections(Config, Obj);
124 for (const NewSectionInfo &NewSection : Config.AddSection) {
130 llvm::StringRef(NewSection.SectionData->getBufferStart(),
131 NewSection.SectionData->getBufferSize());
133 InputData, NewSection.SectionData->getBufferIdentifier());
135 reinterpret_cast<const uint8_t *>(BufferCopy->getBufferStart()),
136 BufferCopy->getBufferSize());
144 Error executeObjcopyOnBinary(const CommonConfig &Config, const WasmConfig &,
149 return createFileError(Config.InputFilename, ObjOrErr.takeError());
150 Object *Obj = ObjOrErr->get();
152 if (Error E = handleArgs(Config, *Obj))
156 return createFileError(Config.OutputFilename, std::move(E));