diff --git a/include/arch/arm/cortex_m/scripts/linker.ld b/include/arch/arm/cortex_m/scripts/linker.ld index f74de0c6cb6..9dda8569c25 100644 --- a/include/arch/arm/cortex_m/scripts/linker.ld +++ b/include/arch/arm/cortex_m/scripts/linker.ld @@ -324,34 +324,6 @@ SECTIONS } GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION) #endif -#ifdef CONFIG_COVERAGE_GCOV - SECTION_DATA_PROLOGUE(_GCOV_BSS_SECTION_NAME,(NOLOAD),) - { - -#ifdef CONFIG_USERSPACE - MPU_ALIGN(__gcov_bss_end - __gcov_bss_start ); -#else /* CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT && CONFIG_USERSPACE */ - . = ALIGN(_region_min_align); -#endif /* CONFIG_USERSPACE */ - - __gcov_bss_start = .; - KEEP(*(".bss.__gcov0.*")); - -#ifdef CONFIG_USERSPACE - MPU_ALIGN(__gcov_bss_end - __gcov_bss_start ); -#else /* CONFIG_USERSPACE */ - . = ALIGN(_region_min_align); -#endif /* CONFIG_USERSPACE */ - - __gcov_bss_end = .; - - } GROUP_LINK_IN(RAMABLE_REGION) - - __gcov_bss_num_words = ((__gcov_bss_end - __gcov_bss_start) >> 2); - __gcov_bss_size = __gcov_bss_end - __gcov_bss_start; - -#endif /* CONFIG_COVERAGE_GCOV */ - /* Located in generated directory. This file is populated by the * zephyr_linker_sources() Cmake function. */ diff --git a/include/linker/common-rom.ld b/include/linker/common-rom.ld index bef2b4fe260..57211bf93b8 100644 --- a/include/linker/common-rom.ld +++ b/include/linker/common-rom.ld @@ -120,14 +120,3 @@ KEEP(*(SORT_BY_NAME(".font_entry.*"))) __font_entry_end = .; } GROUP_LINK_IN(ROMABLE_REGION) - -#ifdef CONFIG_COVERAGE_GCOV - /* Section needed by gcov when coverage is turned on.*/ - SECTION_PROLOGUE (gcov,,) - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } GROUP_LINK_IN(ROMABLE_REGION) -#endif /* CONFIG_COVERAGE_GCOV */ diff --git a/subsys/testsuite/coverage/CMakeLists.txt b/subsys/testsuite/coverage/CMakeLists.txt index 6cda8253b33..3c5c4e9e0bf 100644 --- a/subsys/testsuite/coverage/CMakeLists.txt +++ b/subsys/testsuite/coverage/CMakeLists.txt @@ -1,3 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 zephyr_sources_ifdef(CONFIG_COVERAGE_GCOV coverage.c) + +zephyr_linker_sources_ifdef(CONFIG_COVERAGE_GCOV RAM_SECTIONS coverage_ram.ld) +zephyr_linker_sources_ifdef(CONFIG_COVERAGE_GCOV SECTIONS coverage_rom.ld) + diff --git a/subsys/testsuite/coverage/coverage_ram.ld b/subsys/testsuite/coverage/coverage_ram.ld new file mode 100644 index 00000000000..15efa2c22d2 --- /dev/null +++ b/subsys/testsuite/coverage/coverage_ram.ld @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Copied from linker.ld */ + +SECTION_DATA_PROLOGUE(_GCOV_BSS_SECTION_NAME,(NOLOAD),) +{ +#ifdef CONFIG_USERSPACE + MPU_ALIGN(__gcov_bss_end - __gcov_bss_start ); +#else /* CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT && CONFIG_USERSPACE */ + . = ALIGN(_region_min_align); +#endif /* CONFIG_USERSPACE */ + + __gcov_bss_start = .; + KEEP(*(".bss.__gcov0.*")); + +#ifdef CONFIG_USERSPACE + MPU_ALIGN(__gcov_bss_end - __gcov_bss_start ); +#else /* CONFIG_USERSPACE */ + . = ALIGN(_region_min_align); +#endif /* CONFIG_USERSPACE */ + + __gcov_bss_end = .; +} GROUP_LINK_IN(RAMABLE_REGION) + +__gcov_bss_num_words = ((__gcov_bss_end - __gcov_bss_start) >> 2); +__gcov_bss_size = __gcov_bss_end - __gcov_bss_start; \ No newline at end of file diff --git a/subsys/testsuite/coverage/coverage_rom.ld b/subsys/testsuite/coverage/coverage_rom.ld new file mode 100644 index 00000000000..9b2c5a1e178 --- /dev/null +++ b/subsys/testsuite/coverage/coverage_rom.ld @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2019 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Copied from linker.ld */ + +/* Section needed by gcov when coverage is turned on.*/ +SECTION_PROLOGUE (gcov,,) +{ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); +} GROUP_LINK_IN(ROMABLE_REGION)