[llvm] [llvm-objcopy][ELF] Add an option to remove notes (PR #118739)

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 18:22:46 PST 2025


================
@@ -2154,25 +2154,20 @@ ELFWriter<ELFT>::ELFWriter(Object &Obj, raw_ostream &Buf, bool WSH,
     : Writer(Obj, Buf), WriteSectionHeaders(WSH && Obj.HadShdrs),
       OnlyKeepDebug(OnlyKeepDebug) {}
 
-Error Object::updateSection(StringRef Name, ArrayRef<uint8_t> Data) {
-  auto It = llvm::find_if(Sections,
-                          [&](const SecPtr &Sec) { return Sec->Name == Name; });
-  if (It == Sections.end())
-    return createStringError(errc::invalid_argument, "section '%s' not found",
-                             Name.str().c_str());
-
+Error Object::updateSectionData(std::vector<SecPtr>::iterator It,
----------------
igorkudrin wrote:

This is a private method to extract the common parts of the public methods `Object::updateSection()` and `Object::updateSectionData()`. It updates the container using the passed iterator (line 2173). If we pass a section reference instead of an iterator, it will have to scan the container again.

https://github.com/llvm/llvm-project/pull/118739


More information about the llvm-commits mailing list