pw_toolchain: Add missing objcopy tool to bazel toolchains

Bug: b/301004620
Change-Id: I4625e2a32e5baf9e9d8ab1d633ee807871f28a37
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/171697
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Austin Foxley <afoxley@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/pw_toolchain/arm_gcc/BUILD.bazel b/pw_toolchain/arm_gcc/BUILD.bazel
index ea435f9..f8e7537 100644
--- a/pw_toolchain/arm_gcc/BUILD.bazel
+++ b/pw_toolchain/arm_gcc/BUILD.bazel
@@ -199,6 +199,7 @@
     host_system_name = "unknown",
     ld = "@gcc_arm_none_eabi_toolchain//:bin/arm-none-eabi-ld",
     linker_files = "@gcc_arm_none_eabi_toolchain//:all",
+    objcopy = "@gcc_arm_none_eabi_toolchain//:bin/arm-none-eabi-objcopy",
     objcopy_files = "@gcc_arm_none_eabi_toolchain//:all",
     strip = "@gcc_arm_none_eabi_toolchain//:bin/arm-none-eabi-strip",
     strip_files = "@gcc_arm_none_eabi_toolchain//:all",
diff --git a/pw_toolchain/host_clang/BUILD.bazel b/pw_toolchain/host_clang/BUILD.bazel
index 90ef60f..b114517 100644
--- a/pw_toolchain/host_clang/BUILD.bazel
+++ b/pw_toolchain/host_clang/BUILD.bazel
@@ -89,6 +89,7 @@
     host_system_name = "unknown",
     ld = "@llvm_toolchain//:bin/clang++",
     linker_files = "@llvm_toolchain//:all",
+    objcopy = "@llvm_toolchain//:bin/llvm-objcopy",
     objcopy_files = "@llvm_toolchain//:all",
     strip = "@llvm_toolchain//:bin/llvm-strip",
     strip_files = "@llvm_toolchain//:all",
@@ -140,6 +141,7 @@
     host_system_name = "unknown",
     ld = "@llvm_toolchain//:bin/clang++",
     linker_files = ":all_linux_files",
+    objcopy = "@llvm_toolchain//:bin/llvm-objcopy",
     objcopy_files = ":all_linux_files",
     strip = "@llvm_toolchain//:bin/llvm-strip",
     strip_files = ":all_linux_files",
diff --git a/pw_toolchain_bazel/cc_toolchain/defs.bzl b/pw_toolchain_bazel/cc_toolchain/defs.bzl
index ec0c58a..87243e5 100644
--- a/pw_toolchain_bazel/cc_toolchain/defs.bzl
+++ b/pw_toolchain_bazel/cc_toolchain/defs.bzl
@@ -15,6 +15,7 @@
 
 load(
     "//cc_toolchain/private:cc_toolchain.bzl",
+    _OBJ_COPY_ACTION_NAME = "OBJ_COPY_ACTION_NAME",
     _pw_cc_toolchain = "pw_cc_toolchain",
 )
 load(
@@ -22,6 +23,10 @@
     _pw_cc_toolchain_feature = "pw_cc_toolchain_feature",
 )
 
+# TODO(b/301004620): Remove when bazel 7 is released and this constant exists in
+# ACTION_NAMES
+OBJ_COPY_ACTION_NAME = _OBJ_COPY_ACTION_NAME
+
 pw_cc_toolchain = _pw_cc_toolchain
 
 pw_cc_toolchain_feature = _pw_cc_toolchain_feature
diff --git a/pw_toolchain_bazel/cc_toolchain/private/cc_toolchain.bzl b/pw_toolchain_bazel/cc_toolchain/private/cc_toolchain.bzl
index c08c112..94df446 100644
--- a/pw_toolchain_bazel/cc_toolchain/private/cc_toolchain.bzl
+++ b/pw_toolchain_bazel/cc_toolchain/private/cc_toolchain.bzl
@@ -36,6 +36,10 @@
     "check_deps",
 )
 
+# TODO(b/301004620): Remove when bazel 7 is released and this constant exists in
+# ACTION_NAMES
+OBJ_COPY_ACTION_NAME = "objcopy_embed_data"
+
 PW_CC_TOOLCHAIN_CONFIG_ATTRS = {
     "feature_deps": "pw_cc_toolchain_feature labels that provide features for this toolchain",
     "ar": "Path to the tool to use for ar (static link) actions",
@@ -44,6 +48,7 @@
     "gcov": "Pah to the tool to use for generating code coverag data",
     "ld": "Path to the tool to use for link actions",
     "strip": "Path to the tool to use for strip actions",
+    "objcopy": "Path to the tool to use for objcopy actions",
 
     # Attributes originally part of create_cc_toolchain_config_info.
     "toolchain_identifier": "See documentation for cc_common.create_cc_toolchain_config_info()",
@@ -208,6 +213,14 @@
             ],
         ),
         action_config(
+            action_name = OBJ_COPY_ACTION_NAME,
+            tools = [
+                tool(
+                    tool = ctx.executable.objcopy,
+                ),
+            ],
+        ),
+        action_config(
             action_name = ACTION_NAMES.strip,
             tools = [
                 tool(
@@ -258,6 +271,7 @@
         "ar": attr.label(allow_single_file = True, executable = True, cfg = "exec"),
         "cpp": attr.label(allow_single_file = True, executable = True, cfg = "exec"),
         "gcov": attr.label(allow_single_file = True, executable = True, cfg = "exec"),
+        "objcopy": attr.label(allow_single_file = True, executable = True, cfg = "exec"),
         "strip": attr.label(allow_single_file = True, executable = True, cfg = "exec"),
 
         # Attributes from create_cc_toolchain_config_info.