Lines Matching defs:Obj
62 static bool onlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) {
64 if (&Sec == Obj.SectionNames)
158 Object &Obj, raw_ostream &Out,
163 return std::make_unique<ELFWriter<ELF32LE>>(Obj, Out, !Config.StripSections,
166 return std::make_unique<ELFWriter<ELF64LE>>(Obj, Out, !Config.StripSections,
169 return std::make_unique<ELFWriter<ELF32BE>>(Obj, Out, !Config.StripSections,
172 return std::make_unique<ELFWriter<ELF64BE>>(Obj, Out, !Config.StripSections,
179 Object &Obj, raw_ostream &Out,
183 return std::make_unique<BinaryWriter>(Obj, Out, Config);
185 return std::make_unique<IHexWriter>(Obj, Out, Config.OutputFilename);
187 return std::make_unique<SRECWriter>(Obj, Out, Config.OutputFilename);
189 return createELFWriter(Config, Obj, Out, OutputElfType);
194 Object &Obj) {
195 for (auto &Sec : Obj.sections()) {
285 static bool isRequiredByABISymbol(const Object &Obj, const Symbol &Sym) {
286 switch (Obj.Machine) {
289 return Obj.isRelocatable() && isAArch64MappingSymbol(Sym);
292 return Obj.isRelocatable() && isArmMappingSymbol(Sym);
305 const ELFConfig &ELFConfig, Object &Obj) {
308 if (!Obj.SymbolTable)
311 Obj.SymbolTable->updateSymbols([&](Symbol &Sym) {
372 for (SectionBase &Sec : Obj.sections())
387 if (isRequiredByABISymbol(Obj, Sym))
402 (!Obj.isRelocatable() || isUnneededSymbol(Sym)))
413 return Obj.removeSymbols(RemoveSymbolsPred);
417 const ELFConfig &ELFConfig, Object &Obj) {
433 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) {
434 return onlyKeepDWOPred(Obj, Sec) || RemovePred(Sec);
438 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) {
443 if (&Sec == Obj.SectionNames)
468 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) {
471 if (&Sec == Obj.SectionNames)
477 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) {
480 if (&Sec == Obj.SectionNames)
509 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) {
519 if (Obj.SectionNames == &Sec)
521 if (Obj.SymbolTable == &Sec ||
522 (Obj.SymbolTable && Obj.SymbolTable->getStrTab() == &Sec))
546 Obj.SymbolTable && !Obj.SymbolTable->empty()) {
547 RemovePred = [&Obj, RemovePred](const SectionBase &Sec) {
548 if (&Sec == Obj.SymbolTable || &Sec == Obj.SymbolTable->getStrTab())
554 if (Error E = Obj.removeSections(ELFConfig.AllowBrokenLinks, RemovePred))
557 if (Error E = Obj.compressOrDecompressSections(Config))
564 static void addSymbol(Object &Obj, const NewSymbolInfo &SymInfo,
566 SectionBase *Sec = Obj.findSection(SymInfo.SectionName);
612 Obj.SymbolTable->addSymbol(
682 ElfType OutputElfType, Object &Obj) {
684 Obj.Machine = Config.OutputArch->EMachine;
685 Obj.OSABI = Config.OutputArch->OSABI;
689 return Obj.removeSections(
691 [&Obj](const SectionBase &Sec) { return onlyKeepDWOPred(Obj, Sec); });
699 if (Error E = dumpSectionToFile(SectionName, FileName, Obj))
707 if (Error E = replaceAndRemoveSections(Config, ELFConfig, Obj))
710 if (Error E = updateAndRemoveSymbols(Config, ELFConfig, Obj))
714 for (SectionBase &Sec : Obj.sections()) {
722 for (Segment &Seg : Obj.segments()) {
749 for (auto &Sec : Obj.sections())
760 Obj.addSection<OwnedDataSection>(Name, Data);
774 return Obj.updateSection(Name, Data);
781 Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink,
786 if (!Obj.SymbolTable && !Config.SymbolsToAdd.empty())
787 if (Error E = Obj.addNewSymbolTable())
791 addSymbol(Obj, SI, ELFConfig.NewSymbolVisibility);
795 for (auto &Sec : Obj.sections()) {
799 if (Error E = setSectionFlagsAndType(Sec, SFU.NewFlags, Obj.Machine))
811 for (SectionBase &Sec : Obj.sections()) {
818 if (Error E = setSectionFlagsAndType(Sec, *SR.NewFlags, Obj.Machine))
845 for (SectionBase &Sec : Obj.sections()) {
875 Obj.Entry = ELFConfig.EntryExpr(Obj.Entry);
879 static Error writeOutput(const CommonConfig &Config, Object &Obj,
882 createWriter(Config, Obj, Out, OutputElfType);
892 Expected<std::unique_ptr<Object>> Obj = Reader.create(true);
893 if (!Obj)
894 return Obj.takeError();
898 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
900 return writeOutput(Config, **Obj, Out, OutputElfType);
908 Expected<std::unique_ptr<Object>> Obj = Reader.create(true);
909 if (!Obj)
910 return Obj.takeError();
916 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
918 return writeOutput(Config, **Obj, Out, OutputElfType);
926 Expected<std::unique_ptr<Object>> Obj =
928 if (!Obj)
929 return Obj.takeError();
935 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
938 if (Error E = writeOutput(Config, **Obj, Out, OutputElfType))