1# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15package(
16    default_visibility = ["//visibility:public"],
17)
18
19cc_library(
20    name = "relocation",
21    srcs = ["relocation.cpp"],
22    hdrs = ["public/elf/relocation.h"],
23    copts = select({
24        "@gbl//toolchain:gbl_rust_elf_riscv64": [],
25        # For the `elf_static_relocation_checker` host tool, enable
26        # print and panics as exit().
27        "//conditions:default": ["-DHOST_TOOLING"],
28    }),
29    includes = ["public"],
30    deps = ["@elfutils//:elf_type_header"],
31)
32
33cc_test(
34    name = "relocation_test",
35    size = "small",
36    srcs = ["relocation_test.cpp"],
37    target_compatible_with = [
38        "@platforms//os:linux",
39    ],
40    deps = [
41        ":relocation",
42        "@elfutils//:elf_type_header",
43        "@googletest//:gtest_main",
44    ],
45)
46
47cc_binary(
48    name = "elf_static_relocation_checker",
49    srcs = ["elf_static_relocation_checker.cpp"],
50    copts = [
51        "-std=c++17",
52        "-Wall",
53        "-Werror",
54    ],
55    deps = [
56        ":relocation",
57        "@elfutils//:elf_type_header",
58    ],
59)
60