llvm.org GIT mirror llvm / 47812d8
[llvm-objcopy] Reformat everything using clang-format -i Overtime some non-clang formatted code has creeped into llvm-objcopy. This patch fixes all of that. Differential Revision: https://reviews.llvm.org/D41262 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320856 91177308-0d34-0410-b5e6-96231b3b80d8 Jake Ehrlich 2 years ago
2 changed file(s) with 22 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
226226 void RelocSectionWithSymtabBase::removeSectionReferences(
227227 const SectionBase *Sec) {
228228 if (Symbols == Sec) {
229 error("Symbol table " + Symbols->Name +
230 " cannot be removed because it is "
231 "referenced by the relocation "
232 "section " +
229 error("Symbol table " + Symbols->Name + " cannot be removed because it is "
230 "referenced by the relocation "
231 "section " +
233232 this->Name);
234233 }
235234 }
244243 " is not a symbol table"));
245244
246245 if (Info != SHN_UNDEF)
247 setSection(SecTable.getSection(Info, "Info field value " + Twine(Info) +
248 " in section " + Name +
249 " is invalid"));
246 setSection(SecTable.getSection(Info,
247 "Info field value " + Twine(Info) +
248 " in section " + Name + " is invalid"));
250249 else
251250 setSection(nullptr);
252251 }
293292
294293 void SectionWithStrTab::removeSectionReferences(const SectionBase *Sec) {
295294 if (StrTab == Sec) {
296 error("String table " + StrTab->Name +
297 " cannot be removed because it is "
298 "referenced by the section " +
295 error("String table " + StrTab->Name + " cannot be removed because it is "
296 "referenced by the section " +
299297 this->Name);
300298 }
301299 }
305303 }
306304
307305 void SectionWithStrTab::initialize(SectionTableRef SecTable) {
308 auto StrTab =
309 SecTable.getSection(Link, "Link field value " + Twine(Link) +
310 " in section " + Name + " is invalid");
306 auto StrTab = SecTable.getSection(Link,
307 "Link field value " + Twine(Link) +
308 " in section " + Name + " is invalid");
311309 if (StrTab->Type != SHT_STRTAB) {
312310 error("Link field value " + Twine(Link) + " in section " + Name +
313311 " is not a string table");
415413 }
416414 } else if (Sym.st_shndx != SHN_UNDEF) {
417415 DefSection = SecTable.getSection(
418 Sym.st_shndx, "Symbol '" + Name +
419 "' is defined in invalid section with index " +
420 Twine(Sym.st_shndx));
416 Sym.st_shndx,
417 "Symbol '" + Name + "' is defined in invalid section with index " +
418 Twine(Sym.st_shndx));
421419 }
422420
423421 SymTab->addSymbol(Name, Sym.getBinding(), Sym.getType(), DefSection,
7272
7373 static cl::opt InputFilename(cl::Positional, cl::desc(""));
7474 static cl::opt OutputFilename(cl::Positional, cl::desc(""),
75 cl::init("-"));
75 cl::init("-"));
7676 static cl::opt
7777 OutputFormat("O", cl::desc("Set output format to one of the following:"
7878 "\n\tbinary"));
9999 cl::desc("Removes all debug information"));
100100 static cl::opt StripSections("strip-sections",
101101 cl::desc("Remove all section headers"));
102 static cl::opt StripNonAlloc("strip-non-alloc",
103 cl::desc("Remove all non-allocated sections"));
102 static cl::opt
103 StripNonAlloc("strip-non-alloc",
104 cl::desc("Remove all non-allocated sections"));
104105 static cl::opt
105106 StripDWO("strip-dwo", cl::desc("Remove all DWARF .dwo sections from file"));
106107 static cl::opt ExtractDWO(
114115
115116 using SectionPred = std::function;
116117
117 bool IsDWOSection(const SectionBase &Sec) {
118 return Sec.Name.endswith(".dwo");
119 }
118 bool IsDWOSection(const SectionBase &Sec) { return Sec.Name.endswith(".dwo"); }
120119
121120 template
122121 bool OnlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) {
163162 // any previous removals. Lastly whether or not something is removed shouldn't
164163 // depend a) on the order the options occur in or b) on some opaque priority
165164 // system. The only priority is that keeps/copies overrule removes.
166 template
167 void CopyBinary(const ELFObjectFile &ObjFile) {
165 template void CopyBinary(const ELFObjectFile &ObjFile) {
168166 std::unique_ptr> Obj;
169167
170168 if (!OutputFormat.empty() && OutputFormat != "binary")
175173 Obj = llvm::make_unique>(ObjFile);
176174
177175 if (!SplitDWO.empty())
178 SplitDWOToFile(ObjFile, SplitDWO.getValue());
176 SplitDWOToFile(ObjFile, SplitDWO.getValue());
179177
180178 SectionPred RemovePred = [](const SectionBase &) { return false; };
181179
206204 return false;
207205 if (&Sec == Obj->getSectionHeaderStrTab())
208206 return false;
209 switch(Sec.Type) {
207 switch (Sec.Type) {
210208 case SHT_SYMTAB:
211209 case SHT_REL:
212210 case SHT_RELA: