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.
7 assert(relocation_packing_supported)
9 if (target_arch == "arm") {
10 target_define = "TARGET_ARM"
11 } else if (target_arch == "arm64") {
12 target_define = "TARGET_ARM64"
15 if (current_toolchain == host_toolchain) {
16 # GYP: //tools/relocation_packer/relocation_packer.gyp:lib_relocation_packer
17 source_set("lib_relocation_packer") {
18 defines = [ target_define ]
19 deps = [ "//third_party/elfutils:libelf" ]
20 configs -= [ "//build/config/compiler:chromium_code" ]
21 configs += [ "//build/config/compiler:no_chromium_code" ]
24 "src/delta_encoder.cc",
29 "src/run_length_encoder.cc",
33 # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer
34 executable("relocation_packer") {
35 defines = [ target_define ]
37 ":lib_relocation_packer",
38 "//third_party/elfutils:libelf",
40 sources = [ "src/main.cc" ]
43 # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_unittests
44 test("relocation_packer_unittests") {
46 "src/debug_unittest.cc",
47 "src/delta_encoder_unittest.cc",
48 "src/elf_file_unittest.cc",
49 "src/leb128_unittest.cc",
50 "src/packer_unittest.cc",
51 "src/sleb128_unittest.cc",
52 "src/run_length_encoder_unittest.cc",
53 "src/run_all_unittests.cc",
55 rebased_test_data = rebase_path("test_data", root_build_dir)
57 "test_data/elf_file_unittest_relocs_arm32.so",
58 "test_data/elf_file_unittest_relocs_arm32_packed.so",
59 "test_data/elf_file_unittest_relocs_arm64.so",
60 "test_data/elf_file_unittest_relocs_arm64_packed.so",
64 "INTERMEDIATE_DIR=\"$rebased_test_data\""
66 include_dirs = [ "//" ]
68 ":lib_relocation_packer",
69 ":relocation_packer_test_data",
75 if (current_toolchain == default_toolchain &&
76 (target_arch == "arm" || target_arch == "arm64")) {
77 # Targets to build test data. These participate only in building test
78 # data for use with elf_file_unittest.cc, and are not part of the main
79 # relocation packer build. Unit test data files are checked in to the
80 # source tree as 'golden' data, and are not generated 'on the fly' by
83 # See test_data/generate_elf_file_unittest_relocs.sh for instructions.
85 # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_test_data
86 shared_library("relocation_packer_test_data") {
87 cflags = [ "-O0", "-g0" ]
89 "test_data/elf_file_unittest_relocs.cc"
93 # GYP: //tools/relocation_packer/relocation_packer.gyp:relocation_packer_unittests_test_data
94 action("relocation_packer_unittests_test_data") {
95 script = "test_data/generate_elf_file_unittest_relocs.py"
96 test_file = "$root_build_dir/librelocation_packer_test_data.so"
97 if (target_arch == "arm") {
98 added_section = ".android.rel.dyn"
99 packed_output = "elf_file_unittest_relocs_arm32_packed.so"
100 unpacked_output = "elf_file_unittest_relocs_arm32.so"
101 } else if (target_arch == "arm64") {
102 added_section = ".android.rela.dyn"
103 packed_output = "elf_file_unittest_relocs_arm64_packed.so"
104 unpacked_output = "elf_file_unittest_relocs_arm64.so"
106 assert(false, "Unsupported target arch for relocation packer")
109 packed_output = "$root_build_dir/$packed_output"
110 unpacked_output = "$root_build_dir/$unpacked_output"
117 ":relocation_packer_test_data",
118 ":relocation_packer($host_toolchain)",
127 "--android-pack-relocations", rebase_path(relocation_packer_exe, root_build_dir),
128 "--android-objcopy", rebase_path(android_objcopy, root_build_dir),
129 "--added-section=$added_section",
130 "--test-file", rebase_path(test_file, root_build_dir),
131 "--packed-output", rebase_path(packed_output, root_build_dir),
132 "--unpacked-output", rebase_path(unpacked_output, root_build_dir),