|  | # Copyright 2018 The Fuchsia Authors. All rights reserved. | 
|  | # Use of this source code is governed by a BSD-style license that can be | 
|  | # found in the LICENSE file. | 
|  |  | 
|  | import("//build/fuzzing/fuzzer.gni") | 
|  | import("//build/test.gni") | 
|  | import("//build/test/test_package.gni") | 
|  |  | 
|  | # A collection of utilities useful to debuggers and similar programs. | 
|  |  | 
|  | static_library("elflib") { | 
|  | sources = [ "elflib.cc" ] | 
|  |  | 
|  | deps = [ "//zircon/system/public" ] | 
|  |  | 
|  | public_deps = [ "//zircon/public/lib/fbl" ] | 
|  |  | 
|  | # TODO(fxb/58162): delete the below and fix compiler warnings | 
|  | configs += [ "//build/config:Wno-conversion" ] | 
|  | } | 
|  |  | 
|  | # An example stripped binary. Originally copied from out/x64/cowsay. | 
|  | # ARM64 binary generated with: | 
|  | # fx set core.arm64 --with //examples/cowsay | 
|  | # fx build | 
|  | # cp out/default/exe.unstripped/cowsay \ | 
|  | #   src/lib/elflib/test_data/unstripped_example.arm64.elf | 
|  | # ./prebuilt/third_party/clang/linux-x64/bin/llvm-objcopy \ | 
|  | #     --strip-sections out/default/exe.unstripped/cowsay \ | 
|  | #     src/lib/elflib/test_data/unstripped_example_stripped.arm64.elf | 
|  | test("elflib_unittest") { | 
|  | sources = [ "elflib_unittest.cc" ] | 
|  |  | 
|  | deps = [ | 
|  | ":elflib", | 
|  | "//src/lib/fxl/test:gtest_main", | 
|  | "//third_party/googletest:gtest", | 
|  | ] | 
|  |  | 
|  | # TODO(fxbug.dev/58160): delete the below and fix compiler warnings | 
|  | configs += [ "//build/config:Wno-reorder-init-list" ] | 
|  |  | 
|  | # TODO(fxbug.dev/46795): UBSan has found an instance of undefined behavior in this target. | 
|  | # Disable UBSan for this target temporarily until it is migrated into CI/CQ. | 
|  | configs += [ "//build/config:temporarily_disable_ubsan_do_not_use" ] | 
|  |  | 
|  | # TODO(fxb/58162): delete the below and fix compiler warnings | 
|  | configs += [ "//build/config:Wno-conversion" ] | 
|  | } | 
|  |  | 
|  | test_package("elflib_tests") { | 
|  | deps = [ ":elflib_unittest" ] | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "elflib_unittest" | 
|  | environments = basic_envs | 
|  | }, | 
|  | ] | 
|  |  | 
|  | resources = [ | 
|  | { | 
|  | path = "test_data/6d4d8ac190ecc7.debug" | 
|  | dest = "6d4d8ac190ecc7.debug" | 
|  | }, | 
|  | { | 
|  | path = "test_data/stripped_example.elf" | 
|  | dest = "stripped_example.elf" | 
|  | }, | 
|  | { | 
|  | path = "test_data/unstripped_example.arm64.elf" | 
|  | dest = "unstripped_example.arm64.elf" | 
|  | }, | 
|  | { | 
|  | path = "test_data/unstripped_example.elf" | 
|  | dest = "unstripped_example.elf" | 
|  | }, | 
|  | { | 
|  | path = "test_data/unstripped_example_stripped.arm64.elf" | 
|  | dest = "unstripped_example_stripped.arm64.elf" | 
|  | }, | 
|  | { | 
|  | path = "test_data/unstripped_example_stripped.elf" | 
|  | dest = "unstripped_example_stripped.elf" | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | group("tests") { | 
|  | testonly = true | 
|  |  | 
|  | deps = [ | 
|  | ":elflib_fuzzers", | 
|  | ":elflib_tests", | 
|  | "//sdk/lib/syslog/cpp", | 
|  | ] | 
|  | } | 
|  |  | 
|  | fuzzer("elflib_fuzzer") { | 
|  | sources = [ "elflib_fuzztest.cc" ] | 
|  | deps = [ ":elflib" ] | 
|  |  | 
|  | # TODO(fxb/58162): delete the below and fix compiler warnings | 
|  | configs += [ "//build/config:Wno-conversion" ] | 
|  | } | 
|  |  | 
|  | fuzzers_package("elflib_fuzzers") { | 
|  | fuzzers = [ ":elflib_fuzzer" ] | 
|  | } |