ghs: fix the UsageFault:INVSTATE error triggered by exception_common

when we build with greenhills compiler, if the exception_common function
is put into a separate section: ".text.exception_common", then the
address of exception_common function is an even number, for example "0x16a6c",
in this case, it will trigger the UsageFaults:INVSTATE error.
The reason for this error is that in the GHS compiler, a section declared
through the ".section" directive must specify at least the "a" attribute.
Otherwise, this section will not be linked into the final file, and this
is why the address of exception_common function is invalid.
The following is the official explanation in the GHS compiler documentation:
"The reason for this error is that in the GHS compiler, a section
declared through the .section directive must specify at least the "a"
attribute. Otherwise, this section will not be linked into the final
file. The following is the official explanation in the documentation:
"Sections that are intended be part of the final linked output should
have at least the `a` attribute"
and for GHS compiler, the .text section is recommended specify the
attribute of `ax`.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
This commit is contained in:
guoshichao
2025-03-18 16:48:25 +08:00
committed by Xiang Xiao
parent da43a2e53b
commit ba63a4d234
23 changed files with 32 additions and 32 deletions
+1 -1
View File
@@ -113,7 +113,7 @@
*/
.text
.section .text.exception_common
.section .text.exception_common, "ax"
#ifdef __ghs__
.type exception_common, $function
#else
+1 -1
View File
@@ -29,7 +29,7 @@
#include "arm_fork.h"
MODULE up_fork
SECTION .text:CODE:NOROOT(2)
SECTION .text:CODE:NOROOT(2), "ax"
/****************************************************************************
* Pre-processor Definitions
+9 -9
View File
@@ -21,7 +21,7 @@
****************************************************************************/
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
@@ -193,7 +193,7 @@ _modulelist_power_mgr:
.word 0
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
@@ -319,7 +319,7 @@ _modulelist_flash_mgr:
.word 0
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
@@ -389,7 +389,7 @@ _modulelist_rtc_mgr:
.word 0
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
@@ -551,7 +551,7 @@ _modulelist_gnss_pwr:
.word 0
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
@@ -591,7 +591,7 @@ _modulelist_aca:
.word 0
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
@@ -631,7 +631,7 @@ _modulelist_pinconfig:
.word 0
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
@@ -707,7 +707,7 @@ _modulelist_uart:
.word 0
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
@@ -783,7 +783,7 @@ _modulelist_update_mgr:
.word 0
.syntax unified
.section .text.stub
.section .text.stub, "ax"
.align 1
1:
push {r0-r3}
+2 -2
View File
@@ -22,7 +22,7 @@
/* Place a branch to the real head at the entry point */
.section .text.start
.section .text.start, "ax"
b __start
/* Exception Vectors like they are needed for the exception vector
@@ -30,7 +30,7 @@
* linked to appear at 0x80001c
*/
.section .text.exceptions
.section .text.exceptions, "ax"
_undef_instr:
b arm_vectorundefinsn
_sw_interr:
@@ -404,7 +404,7 @@ __irq:
tjl tc32_exception
ASMEND:
.section .bss
.section .bss, "aw"
.global g_intstackalloc
.global g_intstacktop
.align 4
+1 -1
View File
@@ -58,7 +58,7 @@
/* DDR training binaries via incbin */
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 64 \n"
" .globl g_dmem1d_begin \n"
"g_dmem1d_begin: \n"
@@ -69,7 +69,7 @@
****************************************************************************/
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 16 \n"
" .globl romfs_data_begin \n"
"romfs_data_begin: \n"
@@ -69,7 +69,7 @@
****************************************************************************/
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 16 \n"
" .globl romfs_data_begin \n"
"romfs_data_begin: \n"
@@ -69,7 +69,7 @@
****************************************************************************/
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 16 \n"
" .globl romfs_data_begin \n"
"romfs_data_begin: \n"
@@ -69,7 +69,7 @@
****************************************************************************/
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 16 \n"
" .globl romfs_data_begin \n"
"romfs_data_begin: \n"
@@ -69,7 +69,7 @@
****************************************************************************/
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 16 \n"
" .globl romfs_data_begin \n"
"romfs_data_begin: \n"
@@ -69,7 +69,7 @@
****************************************************************************/
__asm__ (
".section .rodata\n"
".section .rodata, \"a\"\n"
".balign 16\n"
".globl romfs_data_begin\n"
"romfs_data_begin:\n"
@@ -71,7 +71,7 @@
****************************************************************************/
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 16 \n"
" .globl romfs_data_begin \n"
"romfs_data_begin: \n"
@@ -71,7 +71,7 @@
****************************************************************************/
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 16 \n"
" .globl romfs_data_begin \n"
"romfs_data_begin: \n"
@@ -83,7 +83,7 @@
****************************************************************************/
__asm__ (
".section .rodata\n"
".section .rodata, \"a\"\n"
".balign 16\n"
".globl romfs_data_begin\n"
"romfs_data_begin:\n"
@@ -84,7 +84,7 @@
****************************************************************************/
__asm__ (
".section .rodata\n"
".section .rodata, \"a\"\n"
".balign 16\n"
".globl romfs_data_begin\n"
"romfs_data_begin:\n"
@@ -83,7 +83,7 @@
****************************************************************************/
__asm__ (
".section .rodata\n"
".section .rodata, \"a\"\n"
".balign 16\n"
".globl romfs_data_begin\n"
"romfs_data_begin:\n"
@@ -69,7 +69,7 @@
****************************************************************************/
__asm__ (
" .section .rodata \n"
" .section .rodata, \"a\" \n"
" .balign 16 \n"
" .globl romfs_data_begin \n"
"romfs_data_begin: \n"
+1 -1
View File
@@ -136,7 +136,7 @@
*/
.text
.section .text.memchr
.section .text.memchr, "ax"
.thumb_func
.align 4
.p2align 4,,15
+1 -1
View File
@@ -94,7 +94,7 @@
.syntax unified
.text
.section .text.memcpy
.section .text.memcpy, "ax"
.align 2
.global ARCH_LIBCFUN(memcpy)
.thumb
+1 -1
View File
@@ -72,7 +72,7 @@
.macro def_fn f p2align=0
.text
.section .text.strcmp
.section .text.strcmp, "ax"
.p2align \p2align
.global \f
.type \f, %function
+1 -1
View File
@@ -60,7 +60,7 @@
.syntax unified
.text
.section .text.strcpy
.section .text.strcpy, "ax"
.align 2
.global ARCH_LIBCFUN(strcpy)
.thumb
+1 -1
View File
@@ -70,7 +70,7 @@
.macro def_fn f p2align=0
.text
.section .text.strlen
.section .text.strlen, "ax"
.p2align \p2align
.global \f
.type \f, %function