embeded/Cortex-M7 STM2024. 10. 8. 10:27

인터럽트 핸들러의 경우 __WEAK가 앞에 붙어있는데

c 언어라면 동일한 함수명은 사용이 불가능한게 상식인데

새로 정의하면 새로 정의된 함수가 사용되고 기존에 정의된 함수는 사용되지 않는 신기한 녀석이다

그래서 이 기회에서 찾아보는 중

 

cmsis_armcc.h 에서 아래와 같이 정의되어 있다.

#ifndef   __WEAK
  #define __WEAK                                 __attribute__((weak))
#endif

 

링크 시간에 strong symbol은 weak symbol을 override 한다. 라고 되어있는데

컴파일러가 아니라 링커가 연결해주는거라니 신기하다.

__attribute__((weak)) variable attribute
Generates a weak symbol for a variable, rather than the default symbol.

Syntax

__attribute__((weak)) <type> <variable>;
Parameters
None.

Operation
At link time, strong symbols override weak symbols. This attribute replaces a weak symbol with a strong symbol, by choosing a particular combination of object files to link.

Example

__attribute__((weak)) int foo;

[링크 : https://developer.arm.com/documentation/101754/0622/armclang-Reference/Compiler-specific-Function--Variable--and-Type-Attributes/--attribute----weak---variable-attribute]

 

[링크 : https://blog.naver.com/22wowow22/220825653093]

[링크 : https://gangsanilee.tistory.com/2874]

[링크 : https://tigershin-shinhyeonkyu.tistory.com/8]

[링크 : https://engineering-agit.tistory.com/25]

 

 

'embeded > Cortex-M7 STM' 카테고리의 다른 글

stm32f746g-disco with semtech sx1276 and lvgl  (0) 2026.02.03
modbus rtu coil read  (0) 2024.10.10
stm32 modbus  (0) 2024.09.26
SPI NSS, NSSP mode  (0) 2024.09.11
FDE CIE  (0) 2024.09.06
Posted by 구차니