| # Copyright lowRISC contributors. |
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| # SPDX-License-Identifier: Apache-2.0 |
| |
| # Test ROM_EXT linker parameters. |
| test_rom_ext_linker_script = '@0@/@1@'.format(meson.source_root(), files(['test_rom_ext.ld'])[0]) |
| test_rom_ext_linker_args = [ |
| # The linker script includes an autogenerated definition of the available |
| # memory regions. The include path is given relative to the source root, so we |
| # need to add the source root to the linker lookup path (which is the same for |
| # libraries and linker scripts. |
| '-Wl,-L,@0@'.format(meson.source_root()), |
| '-Wl,-T,@0@'.format(test_rom_ext_linker_script), |
| # Depending on the compiler and its configuration (*), |--build-id| is passed |
| # to the linker, causing the insertion of a ".note.gnu.build-id" section into |
| # the ELF file. We do not use the build ID. Achieve consistent behavior and |
| # potentially a small improvement in linking time by not computing the build |
| # ID in the first place. |
| # |
| # * GCC built with |--enable-linker-build-id|, clang before 3.9 or built with |
| # |-DENABLE_LINKER_BUILD_ID|. |
| '-Wl,--build-id=none', |
| ] |
| |
| # Test ROM_EXT-like startup library. Every OpenTitan (RISC-V) test executable |
| # should depend on this target. |
| # |
| # The crt defines the interrupt vector, the symbols of which are defined in |
| # in `sw/device/lib/testing/test_framework/ottf_isrs.S`. |
| test_rom_ext = declare_dependency( |
| link_args: test_rom_ext_linker_args, |
| # The following assembly files need to be included as a source, not a |
| # static library, so that their custom sections can be picked up when |
| # linking. |
| sources: [ |
| # This contains the contents of the `.crt` section which does the initial |
| # setup before jumping to `main`. |
| 'test_rom_ext_start.S', |
| # This contains the interrupt vector definition, as used by the crt to |
| # initialize mtvec. |
| 'test_rom_ext_irq_vector.S', |
| ], |
| dependencies: [ |
| freestanding_headers, |
| sw_lib_crt, |
| sw_lib_mem, |
| sw_lib_irq, |
| top_earlgrey, |
| ], |
| # This argument exists solely so that Meson realizes that |
| # test_rom_ext_linker_script is part of the dependency graph. This seems to be |
| # the only way to convince Meson to behave in this way, for the following |
| # reasons: |
| # - The dependencies arg can only include artifacts from declare_dependency(). |
| # - We can't put linker scripts into the sources list, since Meson has no |
| # clue how to deal with them. |
| # - custom_target() doesn't help, because we can't convince Meson to depend on |
| # a custom_target() unless it produces source files. |
| # - If we go with static_library, sources needs to be non-empty in order for |
| # Meson to correctly treat it as a cross-compile target (otherwise, we get |
| # linker errors). This is because Meson guesses the type of a target based |
| # off of the file extensions of the source files. |
| link_with: static_library( |
| 'test_rom_ext_linker_script_dep_shim', |
| sources: ['empty.c'], |
| link_depends: [test_rom_ext_linker_script], |
| ) |
| ) |