From 47b350a4c3262b2c5bb4acb223bf1d2543bcd2ad Mon Sep 17 00:00:00 2001 From: chao an Date: Fri, 23 Sep 2022 17:16:14 +0800 Subject: [PATCH] arch/arm: declare vector array default type to read-only Reference: https://developer.arm.com/documentation/dui0474/m/image-structure-and-generation/section-placement-with-the-linker/section-placement-with-the-first-and-last-attributes CAUTION: FIRST and LAST must not violate the basic attribute sorting order. For example, FIRST RW is placed after any read-only code or read-only data. arm-none-eabi-readelf -aS arm_vectors.o 1. Without const: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 3] .vectors PROGBITS 00000000 000034 00011c 00 WA 0 0 4 2. const symbol: [ 3] .vectors PROGBITS 00000000 000034 00011c 00 A 0 0 4 Regression by: | commit 229b57d6cb1c87868e0ca86f6035e56226979fa5 | | arch/armv[6|7|8]-m: Move _vectors to arm_internal.h to avoid the duplication | | and change the type of _vectors from uint32_t to const void * | | Signed-off-by: Xiang Xiao Signed-off-by: chao an --- arch/arm/src/armv6-m/arm_vectors.c | 2 +- arch/arm/src/armv7-m/arm_vectors.c | 2 +- arch/arm/src/armv8-m/arm_vectors.c | 2 +- arch/arm/src/common/arm_internal.h | 2 +- arch/arm/src/rtl8720c/ameba_vectors.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/src/armv6-m/arm_vectors.c b/arch/arm/src/armv6-m/arm_vectors.c index 09ae1ad0b9..e6c56035a5 100644 --- a/arch/arm/src/armv6-m/arm_vectors.c +++ b/arch/arm/src/armv6-m/arm_vectors.c @@ -81,7 +81,7 @@ extern void exception_common(void); * Note that the [ ... ] designated initialiser is a GCC extension. */ -const void *_vectors[] locate_data(".vectors") = +const void * const _vectors[] locate_data(".vectors") = { /* Initial stack */ diff --git a/arch/arm/src/armv7-m/arm_vectors.c b/arch/arm/src/armv7-m/arm_vectors.c index cb42f57809..46eb448857 100644 --- a/arch/arm/src/armv7-m/arm_vectors.c +++ b/arch/arm/src/armv7-m/arm_vectors.c @@ -76,7 +76,7 @@ extern void exception_common(void); * Note that the [ ... ] designated initializer is a GCC extension. */ -const void *_vectors[] locate_data(".vectors") = +const void * const _vectors[] locate_data(".vectors") = { /* Initial stack */ diff --git a/arch/arm/src/armv8-m/arm_vectors.c b/arch/arm/src/armv8-m/arm_vectors.c index 531e2b7751..3e92f16676 100644 --- a/arch/arm/src/armv8-m/arm_vectors.c +++ b/arch/arm/src/armv8-m/arm_vectors.c @@ -76,7 +76,7 @@ extern void exception_common(void); * Note that the [ ... ] designated initializer is a GCC extension. */ -const void *_vectors[] locate_data(".vectors") = +const void * const _vectors[] locate_data(".vectors") = { /* Initial stack */ diff --git a/arch/arm/src/common/arm_internal.h b/arch/arm/src/common/arm_internal.h index fcd5e20686..b7e311f442 100644 --- a/arch/arm/src/common/arm_internal.h +++ b/arch/arm/src/common/arm_internal.h @@ -319,7 +319,7 @@ uintptr_t arm_intstack_top(void); extern const void *__vector_table[]; #else -extern const void *_vectors[]; +extern const void * const _vectors[]; #endif /* Interrupt acknowledge and dispatch */ diff --git a/arch/arm/src/rtl8720c/ameba_vectors.c b/arch/arm/src/rtl8720c/ameba_vectors.c index 322c24501c..68aadf89ca 100644 --- a/arch/arm/src/rtl8720c/ameba_vectors.c +++ b/arch/arm/src/rtl8720c/ameba_vectors.c @@ -63,7 +63,7 @@ extern void exception_common(void); * Note that the [ ... ] designated initialiser is a GCC extension. */ -const void *_vectors[] locate_data(".vectors") aligned_data(0x100) = +const void * const _vectors[] locate_data(".vectors") aligned_data(0x100) = { /* Initial stack */