Lines Matching defs:Obj

57 static bool onlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) {
59 if (&Sec == Obj.SectionNames)
153 Object &Obj, raw_ostream &Out,
158 return std::make_unique<ELFWriter<ELF32LE>>(Obj, Out, !Config.StripSections,
161 return std::make_unique<ELFWriter<ELF64LE>>(Obj, Out, !Config.StripSections,
164 return std::make_unique<ELFWriter<ELF32BE>>(Obj, Out, !Config.StripSections,
167 return std::make_unique<ELFWriter<ELF64BE>>(Obj, Out, !Config.StripSections,
174 Object &Obj, raw_ostream &Out,
178 return std::make_unique<BinaryWriter>(Obj, Out, Config);
180 return std::make_unique<IHexWriter>(Obj, Out, Config.OutputFilename);
182 return std::make_unique<SRECWriter>(Obj, Out, Config.OutputFilename);
184 return createELFWriter(Config, Obj, Out, OutputElfType);
189 Object &Obj) {
190 for (auto &Sec : Obj.sections()) {
280 static bool isRequiredByABISymbol(const Object &Obj, const Symbol &Sym) {
281 switch (Obj.Machine) {
284 return Obj.isRelocatable() && isAArch64MappingSymbol(Sym);
287 return Obj.isRelocatable() && isArmMappingSymbol(Sym);
300 const ELFConfig &ELFConfig, Object &Obj) {
303 if (!Obj.SymbolTable)
306 Obj.SymbolTable->updateSymbols([&](Symbol &Sym) {
367 for (SectionBase &Sec : Obj.sections())
382 if (isRequiredByABISymbol(Obj, Sym))
397 (!Obj.isRelocatable() || isUnneededSymbol(Sym)))
408 return Obj.removeSymbols(RemoveSymbolsPred);
412 const ELFConfig &ELFConfig, Object &Obj) {
428 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) {
429 return onlyKeepDWOPred(Obj, Sec) || RemovePred(Sec);
433 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) {
438 if (&Sec == Obj.SectionNames)
463 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) {
466 if (&Sec == Obj.SectionNames)
472 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) {
475 if (&Sec == Obj.SectionNames)
504 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) {
514 if (Obj.SectionNames == &Sec)
516 if (Obj.SymbolTable == &Sec ||
517 (Obj.SymbolTable && Obj.SymbolTable->getStrTab() == &Sec))
541 Obj.SymbolTable && !Obj.SymbolTable->empty()) {
542 RemovePred = [&Obj, RemovePred](const SectionBase &Sec) {
543 if (&Sec == Obj.SymbolTable || &Sec == Obj.SymbolTable->getStrTab())
549 if (Error E = Obj.removeSections(ELFConfig.AllowBrokenLinks, RemovePred))
552 if (Error E = Obj.compressOrDecompressSections(Config))
559 static void addSymbol(Object &Obj, const NewSymbolInfo &SymInfo,
561 SectionBase *Sec = Obj.findSection(SymInfo.SectionName);
607 Obj.SymbolTable->addSymbol(
674 static Error removeNotes(Object &Obj, endianness Endianness,
679 for (Segment &Seg : Obj.segments()) {
688 for (auto &Sec : Obj.sections()) {
711 if (Error E = Obj.updateSectionData(
784 ElfType OutputElfType, Object &Obj) {
786 Obj.Machine = Config.OutputArch->EMachine;
787 Obj.OSABI = Config.OutputArch->OSABI;
791 return Obj.removeSections(
793 [&Obj](const SectionBase &Sec) { return onlyKeepDWOPred(Obj, Sec); });
801 if (Error E = dumpSectionToFile(SectionName, FileName, Obj))
809 if (Error E = replaceAndRemoveSections(Config, ELFConfig, Obj))
812 if (Error E = updateAndRemoveSymbols(Config, ELFConfig, Obj))
816 for (SectionBase &Sec : Obj.sections()) {
824 for (Segment &Seg : Obj.segments()) {
851 if (Obj.Type != ELF::ET_REL)
860 for (SectionBase &Sec : Obj.sections()) {
901 for (auto &Sec : Obj.sections())
911 removeNotes(Obj, E, ELFConfig.NotesToRemove, Config.ErrorCallback))
918 Obj.addSection<OwnedDataSection>(Name, Data);
932 return Obj.updateSection(Name, Data);
939 Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink,
944 if (!Obj.SymbolTable && !Config.SymbolsToAdd.empty())
945 if (Error E = Obj.addNewSymbolTable())
949 addSymbol(Obj, SI, ELFConfig.NewSymbolVisibility);
953 for (auto &Sec : Obj.sections()) {
957 if (Error E = setSectionFlagsAndType(Sec, SFU.NewFlags, Obj.Machine))
969 for (SectionBase &Sec : Obj.sections()) {
976 if (Error E = setSectionFlagsAndType(Sec, *SR.NewFlags, Obj.Machine))
1003 for (SectionBase &Sec : Obj.sections()) {
1033 Obj.Entry = ELFConfig.EntryExpr(Obj.Entry);
1037 static Error writeOutput(const CommonConfig &Config, Object &Obj,
1040 createWriter(Config, Obj, Out, OutputElfType);
1050 Expected<std::unique_ptr<Object>> Obj = Reader.create(true);
1051 if (!Obj)
1052 return Obj.takeError();
1056 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
1058 return writeOutput(Config, **Obj, Out, OutputElfType);
1066 Expected<std::unique_ptr<Object>> Obj = Reader.create(true);
1067 if (!Obj)
1068 return Obj.takeError();
1074 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
1076 return writeOutput(Config, **Obj, Out, OutputElfType);
1084 Expected<std::unique_ptr<Object>> Obj =
1086 if (!Obj)
1087 return Obj.takeError();
1093 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
1096 if (Error E = writeOutput(Config, **Obj, Out, OutputElfType))