1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40

build / chromeos / embed_sections.gni [blame]

# Copyright 2024 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/toolchain/toolchain.gni")

# Embed elf section information of a binary into the binary's predefined
# symbols.
#
# Args:
#   binary_input: Path to the chrome binary, e.g.:
#       "$root_out_dir/chrome"
#   sections_embedded_binary_output: Desired output file for embedded binary,
#       e.g.: "$root_out_dir/chrome.sections_embedded"
template("embed_sections") {
  forward_variables_from(invoker,
                         [
                           "deps",
                           "testonly",
                         ])
  action("${target_name}") {
    script = "//build/chromeos/embed_sections.py"

    if (defined(invoker.sections_embedded_binary_output)) {
      sections_embedded_binary_output = invoker.sections_embedded_binary_output
    } else {
      sections_embedded_binary_output =
          invoker.binary_input + ".sections_embedded"
    }

    inputs = [ invoker.binary_input ]
    outputs = [ sections_embedded_binary_output ]
    args = [
      "--binary-input",
      rebase_path(invoker.binary_input, root_build_dir),
      "--binary-output",
      rebase_path(sections_embedded_binary_output, root_build_dir),
    ]
  }
}