1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 import("//testing/test.gni")
8 assert(relocation_packing_supported)
10 if (target_cpu == "arm") {
11 target_define = "TARGET_ARM"
12 } else if (target_cpu == "arm64") {
13 target_define = "TARGET_ARM64"
16 if (current_toolchain == host_toolchain) {
17 # GYP: //tools/relocation_packer/relocation_packer.gyp:lib_relocation_packer
18 source_set("lib_relocation_packer") {
19 defines = [ target_define ]
21 "//third_party/elfutils:libelf",
23 configs -= [ "//build/config/compiler:chromium_code" ]
24 configs += [ "//build/config/compiler:no_chromium_code" ]
27 "src/delta_encoder.cc",
31 "src/run_length_encoder.cc",
36 # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer
37 executable("relocation_packer") {
38 defines = [ target_define ]
40 ":lib_relocation_packer",
41 "//third_party/elfutils:libelf",
48 # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_unittests
49 test("relocation_packer_unittests") {
51 "src/debug_unittest.cc",
52 "src/delta_encoder_unittest.cc",
53 "src/elf_file_unittest.cc",
54 "src/leb128_unittest.cc",
55 "src/packer_unittest.cc",
56 "src/run_all_unittests.cc",
57 "src/run_length_encoder_unittest.cc",
58 "src/sleb128_unittest.cc",
60 rebased_test_data = rebase_path("test_data", root_build_dir)
62 "test_data/elf_file_unittest_relocs_arm32.so",
63 "test_data/elf_file_unittest_relocs_arm32_packed.so",
64 "test_data/elf_file_unittest_relocs_arm64.so",
65 "test_data/elf_file_unittest_relocs_arm64_packed.so",
69 "INTERMEDIATE_DIR=\"$rebased_test_data\"",
71 include_dirs = [ "//" ]
73 ":lib_relocation_packer",
74 ":relocation_packer_test_data",
80 if (current_toolchain == default_toolchain &&
81 (target_cpu == "arm" || target_cpu == "arm64")) {
82 # Targets to build test data. These participate only in building test
83 # data for use with elf_file_unittest.cc, and are not part of the main
84 # relocation packer build. Unit test data files are checked in to the
85 # source tree as 'golden' data, and are not generated 'on the fly' by
88 # See test_data/generate_elf_file_unittest_relocs.sh for instructions.
90 # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_test_data
91 shared_library("relocation_packer_test_data") {
97 "test_data/elf_file_unittest_relocs.cc",
101 # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_unittests_test_data
102 action("relocation_packer_unittests_test_data") {
103 script = "test_data/generate_elf_file_unittest_relocs.py"
104 test_file = "$root_build_dir/librelocation_packer_test_data.so"
105 if (target_cpu == "arm") {
106 added_section = ".android.rel.dyn"
107 packed_output = "elf_file_unittest_relocs_arm32_packed.so"
108 unpacked_output = "elf_file_unittest_relocs_arm32.so"
109 } else if (target_cpu == "arm64") {
110 added_section = ".android.rela.dyn"
111 packed_output = "elf_file_unittest_relocs_arm64_packed.so"
112 unpacked_output = "elf_file_unittest_relocs_arm64.so"
114 assert(false, "Unsupported target arch for relocation packer")
117 packed_output = "$root_build_dir/$packed_output"
118 unpacked_output = "$root_build_dir/$unpacked_output"
125 ":relocation_packer_test_data",
126 ":relocation_packer($host_toolchain)",
135 "--android-pack-relocations",
136 rebase_path(relocation_packer_exe, root_build_dir),
138 rebase_path(android_objcopy, root_build_dir),
139 "--added-section=$added_section",
141 rebase_path(test_file, root_build_dir),
143 rebase_path(packed_output, root_build_dir),
145 rebase_path(unpacked_output, root_build_dir),