[clang-tools-extra] [clang] [llvm] [llvm-objcopy] Add --gap-fill and --pad-to options (PR #65815)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 12 10:47:12 PST 2023


================
@@ -738,6 +739,36 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
   if (auto Arg = InputArgs.getLastArg(OBJCOPY_extract_partition))
     Config.ExtractPartition = Arg->getValue();
 
+  if (const auto *A = InputArgs.getLastArg(OBJCOPY_gap_fill)) {
+    if (Config.OutputFormat != FileFormat::Binary)
+      return createStringError(
+          errc::invalid_argument,
+          "'--gap-fill' is only supported for binary output");
+    ErrorOr<uint64_t> Val = getAsInteger<uint64_t>(A->getValue());
+    if (!Val)
+      return createStringError(Val.getError(), "--gap-fill: bad number: %s",
+                               A->getValue());
+    uint8_t ByteVal = Val.get();
+    if (ByteVal != Val.get())
+      if (Error E = reportWarning(llvm::createStringError(
----------------
MaskRay wrote:

> jh7370: I think you should undo the reportWarning changes: there's no guarantee anybody will need it in the future, so you shouldn't change it now.

Agreed. We should remove the `reportWarning` definition.

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


More information about the cfe-commits mailing list