| # Copyright 2021 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/cpp/library_headers.gni") |
| import("//build/toolchain/zircon/user_basic_redirect.gni") |
| |
| is_elf = current_os != "mac" && current_os != "win" |
| |
| has_fd = !is_kernel && toolchain_variant.tags + [ "standalone" ] - |
| [ "standalone" ] == toolchain_variant.tags |
| |
| library_headers("headers") { |
| public_deps = [ |
| "//sdk/lib/fit", |
| "//sdk/lib/stdcompat", |
| |
| # <lib/elfldltl/memory.h> has #include <fbl/alloc_checker.h>. |
| "//zircon/system/ulib/fbl", |
| ] |
| if (has_fd) { |
| public_deps += [ |
| # <lib/elfldltl/mapped-fd-file.h> has #include <lib/fit/result.h>. |
| "//sdk/lib/fit", |
| ] |
| } |
| if (is_fuchsia && !is_kernel) { |
| # Make sure that there's no transitive deps on libzircon, so header-only |
| # use of the library doesn't affect dynamic linking dependencies. |
| if (zircon_toolchain == false) { |
| _headers = "" |
| } else { |
| _headers = ":headers" |
| } |
| public_deps += [ |
| # <lib/elfldltl/vmo.h> has #include <lib/zx/vmo.h>. |
| "//zircon/system/ulib/zx$_headers", |
| ] |
| } |
| if (is_kernel) { |
| public_deps += [ |
| "//zircon/kernel/lib/ktl", |
| "//zircon/kernel/lib/libc", |
| ] |
| } |
| |
| headers = [ |
| "lib/elfldltl/abi-ptr.h", |
| "lib/elfldltl/abi-span.h", |
| "lib/elfldltl/alloc-checker-container.h", |
| "lib/elfldltl/compat-hash.h", |
| "lib/elfldltl/constants.h", |
| "lib/elfldltl/container.h", |
| "lib/elfldltl/diagnostics-ostream.h", |
| "lib/elfldltl/diagnostics.h", |
| "lib/elfldltl/dwarf/cfi-entry.h", |
| "lib/elfldltl/dwarf/eh-frame-hdr.h", |
| "lib/elfldltl/dwarf/encoding.h", |
| "lib/elfldltl/dwarf/section-data.h", |
| "lib/elfldltl/dynamic.h", |
| "lib/elfldltl/fd.h", |
| "lib/elfldltl/field.h", |
| "lib/elfldltl/file.h", |
| "lib/elfldltl/gnu-hash.h", |
| "lib/elfldltl/init-fini.h", |
| "lib/elfldltl/internal/const-string.h", |
| "lib/elfldltl/internal/diagnostics-printf.h", |
| "lib/elfldltl/internal/dynamic-tag-error.h", |
| "lib/elfldltl/internal/load-segment-types.h", |
| "lib/elfldltl/internal/phdr-error.h", |
| "lib/elfldltl/layout.h", |
| "lib/elfldltl/link.h", |
| "lib/elfldltl/load.h", |
| "lib/elfldltl/loadinfo-mapped-memory.h", |
| "lib/elfldltl/loadinfo-mutable-memory.h", |
| "lib/elfldltl/machine.h", |
| "lib/elfldltl/mapped-fd-file.h", |
| "lib/elfldltl/mapped-vmo-file.h", |
| "lib/elfldltl/memory.h", |
| "lib/elfldltl/mmap-loader.h", |
| "lib/elfldltl/note.h", |
| "lib/elfldltl/phdr.h", |
| "lib/elfldltl/posix.h", |
| "lib/elfldltl/preallocated-vector.h", |
| "lib/elfldltl/relocation.h", |
| "lib/elfldltl/relro.h", |
| "lib/elfldltl/resolve.h", |
| "lib/elfldltl/segment-with-vmo.h", |
| "lib/elfldltl/self.h", |
| "lib/elfldltl/static-pie-with-vdso.h", |
| "lib/elfldltl/static-pie.h", |
| "lib/elfldltl/static-vector.h", |
| "lib/elfldltl/svr4-abi.h", |
| "lib/elfldltl/symbol.h", |
| "lib/elfldltl/tls-layout.h", |
| "lib/elfldltl/vmar-loader.h", |
| "lib/elfldltl/vmo.h", |
| "lib/elfldltl/zircon.h", |
| ] |
| } |
| |
| static_library("elfldltl") { |
| public_deps = [ ":headers" ] |
| complete_static_lib = true |
| |
| sources = [ "leb128.cc" ] |
| deps = [] |
| if (is_elf) { |
| if (toolchain_base_environment == "user") { |
| deps += [ ":self.basic" ] |
| } else { |
| deps += [ ":self" ] |
| } |
| } |
| if (has_fd) { |
| sources += [ "mapped-fd-file.cc" ] |
| deps += [ |
| "//sdk/lib/fit", |
| "//zircon/system/ulib/fbl", |
| ] |
| } |
| if (is_fuchsia && !is_kernel) { |
| sources += [ |
| "mapped-vmo-file.cc", |
| "vmar-loader.cc", |
| ] |
| deps += [ "//zircon/system/ulib/zx" ] |
| } |
| |
| if (is_linux) { |
| configs -= [ "//build/config/linux:implicit-host-libs" ] |
| } |
| } |
| |
| if (is_elf) { |
| # When the elfldltl::Self<...> code is not fully inlined, it's still used in |
| # places where only the basic machine ABI is available. |
| |
| if (toolchain_base_environment == "user") { |
| user_basic_redirect("self.basic") { |
| visibility = [ ":*" ] |
| public_deps = [ ":self" ] |
| } |
| } |
| |
| source_set("self") { |
| visibility = [ ":*" ] |
| deps = [ ":headers" ] |
| sources = [ "self.cc" ] |
| libs = [ "./self-base.ld" ] |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| |
| deps = [ "test:tests" ] |
| } |
| |
| group("boot_tests") { |
| testonly = true |
| |
| deps = [ "test:boot_tests" ] |
| } |