[PATCH] D118189: [llvm-objcopy][COFF] Implement --update-section

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 27 20:07:51 PST 2022


MaskRay added inline comments.


================
Comment at: llvm/test/tools/llvm-objcopy/COFF/update-section.test:16
+# RUN: llvm-objcopy --update-section=.text=%t.smaller %t - | llvm-readobj -S -x .text - | FileCheck %s --check-prefix=SMALLER
+# SMALLER: Section {
+# SMALLER-NEXT: Number: 1
----------------
Align the values, i.e.

```
# SMALLER:      Section {
# SMALLER-NEXT:   Number: 1
# SMALLER-NEXT:   Name: .text
# SMALLER-NOT:  }
# SMALLER:        RawDataSize: 4
```

And use `NOT: }` to ensure RawDataSize is in the same `Section`.


================
Comment at: llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp:258
+    StringRef SecName, FileName;
+    std::tie(SecName, FileName) = Flag.split("=");
+
----------------



================
Comment at: llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp:266
+    auto MutableSections = Obj.getMutableSections();
+    auto It = llvm::find_if(MutableSections, [SecName](auto &Sec) {
+      return Sec.Name == SecName;
----------------



================
Comment at: llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp:269
+    });
+    if (It == MutableSections.end())
+      return createStringError(
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118189/new/

https://reviews.llvm.org/D118189



More information about the llvm-commits mailing list