| # Copyright 2021 The Cobalt Authors. All Rights Reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| _elf_loader_sources = [ |
| "dynamic_section.cc", |
| "dynamic_section.h", |
| "elf_hash_table.cc", |
| "elf_hash_table.h", |
| "elf_header.cc", |
| "elf_header.h", |
| "elf_loader.cc", |
| "elf_loader.h", |
| "elf_loader_constants.cc", |
| "elf_loader_constants.h", |
| "exported_symbols.cc", |
| "file.h", |
| "file_impl.cc", |
| "file_impl.h", |
| "gnu_hash_table.cc", |
| "gnu_hash_table.h", |
| "lz4_file_impl.cc", |
| "lz4_file_impl.h", |
| "program_table.cc", |
| "program_table.h", |
| "relocations.cc", |
| "relocations.h", |
| ] |
| |
| config("elf_loader_config") { |
| include_dirs = [ |
| "src/include", |
| "src/src", |
| ] |
| } |
| |
| static_library("elf_loader") { |
| sources = _elf_loader_sources + [ |
| "elf_loader_impl.cc", |
| "elf_loader_impl.h", |
| ] |
| |
| configs += [ ":elf_loader_config" ] |
| |
| deps = [ |
| ":evergreen_config", |
| ":evergreen_info", |
| "//starboard", |
| "//third_party/lz4_lib:lz4", |
| ] |
| } |
| |
| static_library("elf_loader_sys") { |
| # System loader based on dlopen/dlsym. |
| # Should be used only for debugging/troubleshooting. |
| sources = _elf_loader_sources + [ |
| "elf_loader_impl.h", |
| "elf_loader_sys_impl.cc", |
| "elf_loader_sys_impl.h", |
| ] |
| |
| configs += [ ":elf_loader_config" ] |
| |
| deps = [ |
| ":evergreen_config", |
| ":evergreen_info", |
| "//starboard", |
| ] |
| |
| if (sb_is_evergreen_compatible) { |
| deps += [ "//third_party/crashpad/wrapper" ] |
| } else { |
| deps += [ "//third_party/crashpad/wrapper:wrapper_stub" ] |
| } |
| } |
| |
| target(final_executable_type, "elf_loader_sandbox") { |
| sources = [ "sandbox.cc" ] |
| configs += [ ":elf_loader_config" ] |
| |
| deps = [ |
| ":elf_loader", |
| ":evergreen_info", |
| ":sabi_string", |
| "//cobalt/content/fonts:copy_font_data", |
| "//starboard", |
| ] |
| } |
| |
| target(final_executable_type, "elf_loader_sys_sandbox") { |
| # To properly function the system loader requires the starboard |
| # symbols to be exported from the binary. |
| # To allow symbols to be exported remove the '-fvisibility=hidden' flag |
| # from your compiler_flags.gypi. For Linux this would be: |
| # starboard/linux/shared/compiler_flags.gypi |
| # Example run: |
| # export LD_LIBRARY_PATH=. |
| # ./elf_loader_sys_sandbox --evergreen_library=app/cobalt/lib/libcobalt.so --evergreen_content=app/cobalt/content |
| sources = [ "sandbox.cc" ] |
| configs += [ ":elf_loader_config" ] |
| |
| starboard_syms_path = |
| rebase_path("//starboard/starboard.syms", root_build_dir) |
| ldflags = [ |
| "-Wl,--dynamic-list=$starboard_syms_path", |
| "-ldl", |
| ] |
| |
| deps = [ |
| ":elf_loader_sys", |
| ":evergreen_info", |
| ":sabi_string", |
| "//starboard", |
| ] |
| } |
| |
| target(gtest_target_type, "elf_loader_test") { |
| testonly = true |
| sources = [ "//starboard/common/test_main.cc" ] |
| deps = [ |
| "//starboard", |
| "//testing/gmock", |
| "//testing/gtest", |
| ] |
| |
| if (target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" || |
| target_cpu == "arm64") { |
| sources += [ |
| "dynamic_section_test.cc", |
| "elf_header_test.cc", |
| "elf_loader_test.cc", |
| "lz4_file_impl_test.cc", |
| "program_table_test.cc", |
| "relocations_test.cc", |
| ] |
| deps += [ |
| ":copy_elf_loader_testdata", |
| ":elf_loader", |
| ] |
| } |
| } |
| |
| copy("copy_elf_loader_testdata") { |
| sources = [ |
| "testdata/compressed.lz4", |
| "testdata/uncompressed", |
| ] |
| subdir = "starboard/elf_loader" |
| outputs = [ "$sb_static_contents_output_data_dir/test/$subdir/{{source_target_relative}}" ] |
| } |
| |
| static_library("evergreen_info") { |
| sources = [ |
| "evergreen_info.cc", |
| "evergreen_info.h", |
| ] |
| |
| public_deps = [ "//starboard/common" ] |
| } |
| |
| static_library("evergreen_config") { |
| sources = [ |
| "evergreen_config.cc", |
| "evergreen_config.h", |
| ] |
| |
| public_deps = [ "//starboard/common" ] |
| } |
| |
| static_library("sabi_string") { |
| sources = [ |
| "sabi_string.cc", |
| "sabi_string.h", |
| ] |
| |
| deps = [ "//starboard/common" ] |
| } |