startup_stm32f103retx.s
| .syntax unified .cpu cortex-m3 .fpu softvfp .thumb .global g_pfnVectors .global Default_Handler /** * @brief This is the code that gets called when the processor first * starts execution following a reset event. Only the absolutely * necessary set is performed, after which the application * supplied main() routine is called. * @param None * @retval : None */ .section .text.Reset_Handler .weak Reset_Handler .type Reset_Handler, %function Reset_Handler: /****************************************************************************** * * The minimal vector table for a Cortex M3. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. * ******************************************************************************/ .section .isr_vector,"a",%progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors g_pfnVectors: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler .word MemManage_Handler .word BusFault_Handler .word UsageFault_Handler .word 0 .word 0 .word 0 .word 0 .word SVC_Handler .word DebugMon_Handler .word 0 .word PendSV_Handler .word SysTick_Handler .word WWDG_IRQHandler .word PVD_IRQHandler .word TAMPER_IRQHandler .word RTC_IRQHandler .word FLASH_IRQHandler .word RCC_IRQHandler .word EXTI0_IRQHandler .word EXTI1_IRQHandler .word EXTI2_IRQHandler .word EXTI3_IRQHandler .word EXTI4_IRQHandler .word DMA1_Channel1_IRQHandler .word DMA1_Channel2_IRQHandler .word DMA1_Channel3_IRQHandler .word DMA1_Channel4_IRQHandler .word DMA1_Channel5_IRQHandler .word DMA1_Channel6_IRQHandler .word DMA1_Channel7_IRQHandler .word ADC1_2_IRQHandler .word USB_HP_CAN1_TX_IRQHandler .word USB_LP_CAN1_RX0_IRQHandler .word CAN1_RX1_IRQHandler .word CAN1_SCE_IRQHandler .word EXTI9_5_IRQHandler .word TIM1_BRK_IRQHandler .word TIM1_UP_IRQHandler .word TIM1_TRG_COM_IRQHandler .word TIM1_CC_IRQHandler .word TIM2_IRQHandler .word TIM3_IRQHandler .word TIM4_IRQHandler .word I2C1_EV_IRQHandler .word I2C1_ER_IRQHandler .word I2C2_EV_IRQHandler .word I2C2_ER_IRQHandler .word SPI1_IRQHandler .word SPI2_IRQHandler .word USART1_IRQHandler .word USART2_IRQHandler .word USART3_IRQHandler .word EXTI15_10_IRQHandler .word RTC_Alarm_IRQHandler .word USBWakeUp_IRQHandler .word TIM8_BRK_IRQHandler .word TIM8_UP_IRQHandler .word TIM8_TRG_COM_IRQHandler .word TIM8_CC_IRQHandler .word ADC3_IRQHandler .word FSMC_IRQHandler .word SDIO_IRQHandler .word TIM5_IRQHandler .word SPI3_IRQHandler .word UART4_IRQHandler .word UART5_IRQHandler .word TIM6_IRQHandler .word TIM7_IRQHandler .word DMA2_Channel1_IRQHandler .word DMA2_Channel2_IRQHandler .word DMA2_Channel3_IRQHandler .word DMA2_Channel4_5_IRQHandler .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word 0 .word BootRAM /* @0x1E0. This is for boot in RAM mode for STM32F10x High Density devices. */ |
STM32F103RETX_FLASH.ld
| /* Memories definition */ MEMORY { RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K } /* Sections */ SECTIONS { /* The startup code into "FLASH" Rom type memory */ .isr_vector : { . = ALIGN(4); KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); } >FLASH /* The program code and other data into "FLASH" Rom type memory */ .text : { . = ALIGN(4); *(.text) /* .text sections (code) */ *(.text*) /* .text* sections (code) */ *(.glue_7) /* glue arm to thumb code */ *(.glue_7t) /* glue thumb to arm code */ *(.eh_frame) KEEP (*(.init)) KEEP (*(.fini)) . = ALIGN(4); _etext = .; /* define a global symbols at end of code */ } >FLASH /* Constant data into "FLASH" Rom type memory */ .rodata : { . = ALIGN(4); *(.rodata) /* .rodata sections (constants, strings, etc.) */ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ . = ALIGN(4); } >FLASH } |
| $ readelf -a test.elf ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0x8009499 Start of program headers: 52 (bytes into file) Start of section headers: 1299152 (bytes into file) Flags: 0x5000200, Version5 EABI, soft-float ABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 4 Size of section headers: 40 (bytes) Number of section headers: 26 Section header string table index: 25 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .isr_vector PROGBITS 08000000 001000 0001e4 00 A 0 0 1 [ 2] .text PROGBITS 080001e8 0011e8 012144 00 AX 0 0 8 [ 3] .rodata PROGBITS 08012330 013330 002338 00 A 0 0 8 [ 4] .ARM.extab PROGBITS 08014668 01622c 000000 00 W 0 0 1 [ 5] .ARM ARM_EXIDX 08014668 015668 000008 00 AL 2 0 4 [ 6] .preinit_array PREINIT_ARRAY 08014670 01622c 000000 04 WA 0 0 1 [ 7] .init_array INIT_ARRAY 08014670 015670 000004 04 A 0 0 4 [ 8] .fini_array FINI_ARRAY 08014674 015674 000004 04 A 0 0 4 [ 9] .data PROGBITS 20000000 016000 00022c 00 WA 0 0 4 [10] .bss NOBITS 20000230 016230 001b44 00 WA 0 0 8 [11] ._user_heap_stack NOBITS 20001d74 016d74 000604 00 WA 0 0 1 [12] .ARM.attributes ARM_ATTRIBUTES 00000000 01622c 000029 00 0 0 1 [13] .debug_info PROGBITS 00000000 016255 01da16 00 0 0 1 [14] .debug_abbrev PROGBITS 00000000 033c6b 0056f5 00 0 0 1 [15] .debug_aranges PROGBITS 00000000 039360 001bf8 00 0 0 8 [16] .debug_rnglists PROGBITS 00000000 03af58 0015ba 00 0 0 1 [17] .debug_macro PROGBITS 00000000 03c512 0206fd 00 0 0 1 [18] .debug_line PROGBITS 00000000 05cc0f 022fc5 00 0 0 1 [19] .debug_str PROGBITS 00000000 07fbd4 0aae1c 01 MS 0 0 1 [20] .comment PROGBITS 00000000 12a9f0 000043 01 MS 0 0 1 [21] .debug_frame PROGBITS 00000000 12aa34 008440 00 0 0 4 [22] .debug_line_str PROGBITS 00000000 132e74 000064 01 MS 0 0 1 [23] .symtab SYMTAB 00000000 132ed8 0072e0 10 24 1208 4 [24] .strtab STRTAB 00000000 13a1b8 002ffa 00 0 0 1 [25] .shstrtab STRTAB 00000000 13d1b2 00011c 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), D (mbind), y (purecode), p (processor specific) There are no section groups in this file. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x08000000 0x08000000 0x14678 0x14678 R E 0x1000 LOAD 0x016000 0x20000000 0x08014678 0x0022c 0x0022c RW 0x1000 LOAD 0x000230 0x20000230 0x080148a4 0x00000 0x01b44 RW 0x1000 LOAD 0x000d74 0x20001d74 0x080148a4 0x00000 0x00604 RW 0x1000 Section to Segment mapping: Segment Sections... 00 .isr_vector .text .rodata .ARM .init_array .fini_array 01 .data 02 .bss 03 ._user_heap_stack There is no dynamic section in this file. There are no relocations in this file. Unwind section '.ARM' at offset 0x15668 contains 1 entry: 0x8000228 <strlen>: 0x1 [cantunwind] Symbol table '.symtab' contains 1838 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 08000000 0 SECTION LOCAL DEFAULT 1 .isr_vector 2: 080001e8 0 SECTION LOCAL DEFAULT 2 .text 3: 08012330 0 SECTION LOCAL DEFAULT 3 .rodata 4: 08014668 0 SECTION LOCAL DEFAULT 4 .ARM.extab 5: 08014668 0 SECTION LOCAL DEFAULT 5 .ARM 6: 08014670 0 SECTION LOCAL DEFAULT 6 .preinit_array 7: 08014670 0 SECTION LOCAL DEFAULT 7 .init_array 8: 08014674 0 SECTION LOCAL DEFAULT 8 .fini_array 9: 20000000 0 SECTION LOCAL DEFAULT 9 .data 10: 20000230 0 SECTION LOCAL DEFAULT 10 .bss 11: 20001d74 0 SECTION LOCAL DEFAULT 11 ._user_heap_stack (많아서 생략) No version information found in this file. Attribute Section: aeabi File Attributes Tag_CPU_name: "7-M" Tag_CPU_arch: v7 Tag_CPU_arch_profile: Microcontroller Tag_THUMB_ISA_use: Thumb-2 Tag_ABI_PCS_wchar_t: 4 Tag_ABI_FP_denormal: Needed Tag_ABI_FP_exceptions: Needed Tag_ABI_FP_number_model: IEEE 754 Tag_ABI_align_needed: 8-byte Tag_ABI_enum_size: small Tag_CPU_unaligned_access: v6 |
[링크 : https://hackmd.io/@SgyGB0h2QGWBfbHp9n_ArQ/BygAD3fU_]
플래시를 읽어보면
0x8000000 은 _estack 값 같고
0x8000004 는 Reset_Handler의 주소 같다. 그런데 왜 1로 끝나지..? 4바이트 정렬 안하나?

근처에 읽어보면 모르겠...다(!)

NMI_Handler로 보는데 0x0800 7F01 인데 왜 1로 끝나냐도 모르겠고, 본다고 기계어가 어셈으로 눈에 들어오는것도 아니고..

[링크 : https://fuhehe.tistory.com/13]
| 벡터위치 변경하는 것을 요약하면 1. 링커스크립트에서 인터럽트벡터가 있는 .isr_vector 섹션의 위치를 수정 2. SystemInit() 함수에서 SCB->VTOR 레지스터를 변경하고자 하는 섹션의 위치로 수정 |
[링크 : https://m.blog.naver.com/chcbaram/222580261732]
암튼 object는 굳이 표현하면 array 나 variable 이라는데
딱히 pointer라는 개념이.. 어셈에 없을리가 없는데 멀까.
| For ELF targets, the .type directive is used like this: .type name , type description This sets the type of symbol name to be either a function symbol or an object symbol. There are five different syntaxes supported for the type description field, in order to provide compatibility with various other assemblers. Because some of the characters used in these syntaxes (such as ‘@’ and ‘#’) are comment characters for some architectures, some of the syntaxes below do not work on all architectures. The first variant will be accepted by the GNU assembler on all architectures so that variant should be used for maximum portability, if you do not need to assemble your code with other assemblers. The syntaxes supported are: .type <name> STT_<TYPE_IN_UPPER_CASE> .type <name>,#<type> .type <name>,@<type> .type <name>,%<type> .type <name>,"<type>" The types supported are: STT_FUNC function Mark the symbol as being a function name. STT_GNU_IFUNC gnu_indirect_function Mark the symbol as an indirect function when evaluated during reloc processing. (This is only supported on assemblers targeting GNU systems). STT_OBJECT object Mark the symbol as being a data object. |
[링크 : https://sourceware.org/binutils/docs/as/Type.html?utm_source=chatgpt.com]
| The .type directive allows you to tell the assembler what type a symbol is. Most of the time we just use %function and %object. .type hexTable,%object ...or... .type qsort,%function |
'embeded > Cortex-M3 STM' 카테고리의 다른 글
| stm32 hal rcc flag (0) | 2026.01.27 |
|---|---|
| bluepill stm32f103c8t6 USB CDC 리셋이후 안되는 문제 (0) | 2026.01.27 |
| stm32cubeide 2.0 에서 ioc 파일이 생성 안되네? (0) | 2026.01.11 |
| stm32cubeide에 x-cube-ai 설치 (0) | 2026.01.06 |
| stm32f103c9t6(bluepill) + stlinkv2 + cdc(vcp) (0) | 2026.01.05 |
