Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC: support "gcc -flto" and fixes (#1353)

* Fix compiler warning "gcc -Wmissing-prototypes" in startup.c.
* For "gcc -flto" fix duplicate labels in asm (startup.c) and mark
  some functions as "used" in startup.c and syscalls.c.
* Fix "gcc -Wredundant-decls" in main.c.

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
This commit is contained in:
Florian La Roche 2025-05-26 12:17:12 +02:00 committed by GitHub
parent 9b50dc160b
commit 9d9bbd0e61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 15 deletions

View file

@ -66,7 +66,7 @@ void Reset_Handler( void )
_start(); _start();
} }
void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress ) __attribute__( ( used ) ) static void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress )
{ {
/* These are volatile to try and prevent the compiler/linker optimizing them /* These are volatile to try and prevent the compiler/linker optimizing them
* away as the variables never actually get used. If the debugger won't show the * away as the variables never actually get used. If the debugger won't show the
@ -196,7 +196,7 @@ void Debug_Handler( void )
); );
} }
const uint32_t * const isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) = const uint32_t * const isr_vector[] __attribute__( ( section( ".isr_vector" ), used ) ) =
{ {
( uint32_t * ) &_estack, ( uint32_t * ) &_estack,
( uint32_t * ) &Reset_Handler, /* Reset -15 */ ( uint32_t * ) &Reset_Handler, /* Reset -15 */
@ -244,12 +244,12 @@ void exit( int status )
__asm volatile ( __asm volatile (
"mov r1, r0\n" "mov r1, r0\n"
"cmp r1, #0\n" "cmp r1, #0\n"
"bne .notclean\n" "bne .notclean2\n"
"ldr r1, =0x20026\n" /* ADP_Stopped_ApplicationExit, a clean exit */ "ldr r1, =0x20026\n" /* ADP_Stopped_ApplicationExit, a clean exit */
".notclean:\n" ".notclean2:\n"
"movs r0, #0x18\n" /* SYS_EXIT */ "movs r0, #0x18\n" /* SYS_EXIT */
"bkpt 0xab\n" "bkpt 0xab\n"
"end: b end\n" "end2: b end2\n"
".ltorg\n" ".ltorg\n"
); );

View file

@ -34,9 +34,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
void vApplicationIdleHook( void );
void vApplicationTickHook( void );
int main( void ) int main( void )
{ {
app_main(); app_main();

View file

@ -90,7 +90,7 @@ static char * heap_end = ( char * ) &_heap_bottom;
* @todo implement if necessary * @todo implement if necessary
* *
*/ */
int _fstat( int file ) __attribute__( ( used ) ) int _fstat( int file )
{ {
( void ) file; ( void ) file;
return 0; return 0;
@ -101,7 +101,7 @@ int _fstat( int file )
* @todo implement if necessary * @todo implement if necessary
* *
*/ */
int _read( int file, __attribute__( ( used ) ) int _read( int file,
char * buf, char * buf,
int len ) int len )
{ {
@ -119,7 +119,7 @@ int _read( int file,
* @param [in] len length of the buffer * @param [in] len length of the buffer
* @returns the number of bytes written * @returns the number of bytes written
*/ */
int _write( int file, __attribute__( ( used ) ) int _write( int file,
char * buf, char * buf,
int len ) int len )
{ {
@ -141,7 +141,7 @@ int _write( int file,
* @returns the previous top of the heap * @returns the previous top of the heap
* @note uses a global variable <b>heap_end</b> to keep track of the previous top * @note uses a global variable <b>heap_end</b> to keep track of the previous top
*/ */
void * _sbrk( int incr ) __attribute__( ( used ) ) void * _sbrk( int incr )
{ {
void * prev_heap_end = heap_end; void * prev_heap_end = heap_end;
@ -155,12 +155,12 @@ void * _sbrk( int incr )
return prev_heap_end; return prev_heap_end;
} }
void _close( int fd ) __attribute__( ( used ) ) void _close( int fd )
{ {
( void ) fd; ( void ) fd;
} }
int _lseek( int filedes, __attribute__( ( used ) ) int _lseek( int filedes,
int offset, int offset,
int whence ) int whence )
{ {
@ -171,7 +171,7 @@ int _lseek( int filedes,
return 0; return 0;
} }
int _isatty() __attribute__( ( used ) ) int _isatty( void )
{ {
return 0; return 0;
} }