gdb client flash custom section to wrong address

Bug #1689778 reported by zhang wenjin on 2017-05-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU ARM Embedded Toolchain
Undecided
Unassigned

Bug Description

  the gdb client can load elf with custom section, and decode lma address is ok. but it flash to wrong address. it seem follow the data section in flash.

  arm-none-eabi-gdb version is 7.8.1.20141128-cvs.
  windows 8.1 platform.

  cpp compile flags:
        "-std=gnu++0x",
        "-fno-exceptions",
        "-fpermissive",
        "-fno-rtti",
        "-gdwarf-2",

        "-Wall",
        "-Wextra",
        "-Wno-missing-field-initializers",
        "-Wno-unused-parameter",
        "-Wno-sign-compare",
        "-Wno-comment",
        "-Wno-switch",

        "-fno-delete-null-pointer-checks",
        "-fno-strict-aliasing",
        "-ffunction-sections",
        "-fmessage-length=0",
        "-fdata-sections",
        "-fsigned-char",
        "-fno-builtin",
        "-ffast-math",

        "-mno-sched-prolog",
        "-mthumb",

        "-nostdlib",
        "-MMD",
        "__CORTEX_M0",
        "ARM_MATH_CM0",
        "-mtune=cortex-m0",
        "-mcpu=cortex-m0",
        "-msoft-float",

linker flag:
        "-mthumb",
        "-fmessage-length=0",
        "-ffunction-sections",
        "-fdata-sections",
        "-fsigned-char",
        "-Wall",
        "-Wextra",
        "-g3",
        "-Xlinker",
        "--gc-sections",
        "-Wl,--wrap=main",
        "--specs=nano.specs",
        "-mcpu=cortex-m0",

test file:

const uint8_t test[1024] __attribute__((section (".test"))) =
{
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
    0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
    0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
};

void main()
{

}

the gdb client output:
$ arm-none-eabi-gdb custom-section.elf
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.1.20141128-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from custom-section.elf...done.
(gdb) target remote:3333
Remote debugging using :3333
Reset_Handler ()
    at C:/git/mesh-embedded/hal/target-stm32f051k6\startup_stm32f051x8.s:67
67 ldr r0, =_estack
(gdb) mon reset halt
adapter speed: 1000 kHz
stm32f0x.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x0800145c msp: 0x20002000
(gdb) load
Loading section .text, size 0x1668 lma 0x8000000
Loading section .data, size 0x1c lma 0x8001668
Loading section .test, size 0x400 lma 0x8007c00
Error finishing flash operation
(gdb)

the GDB server output:
openocd -f board/mb00xx.cfg -c init -c "reset init"
Open On-Chip Debugger 0.10.0-dev-00195-g5156bab (2016-01-29-17:27)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD IDCODE 0x0bb11477
Info : stm32f0x.cpu: hardware has 4 breakpoints, 2 watchpoints
adapter speed: 1000 kHz
stm32f0x.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x0800145c msp: 0x20002000
Info : reduce speed request: 8000kHz to 5000kHz maximum
adapter speed: 8000 kHz
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x20006440
Info : flash size = 32kbytes
adapter speed: 1000 kHz
stm32f0x.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x0800145c msp: 0x20002000
adapter speed: 1000 kHz
stm32f0x.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x0800145c msp: 0x20002000
Info : reduce speed request: 8000kHz to 5000kHz maximum
adapter speed: 8000 kHz
adapter speed: 1000 kHz
stm32f0x.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
Info : reduce speed request: 8000kHz to 5000kHz maximum
adapter speed: 8000 kHz
Info : Padding image section 0 with 25980 bytes
Error: flash write algorithm aborted by target
Error: flash write failed at address 0x8001802
Error: flash memory not erased before writing
Error: error writing to flash at address 0x08000000 at offset 0x00000000
adapter speed: 1000 kHz
stm32f0x.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x0800145c msp: 0x20002000

the address 0x8001802 is wrong. it should stop at 0x8001668 + 0x1C. then go start at 0x08007C00

symbols:
         U __call_exitprocs
         w __deregister_frame_info
         U __libc_fini_array
         w __register_frame_info
         w _Jv_RegisterClasses
         U _printf_float
         U _scanf_float
         U atexit
         U hardware_init_hook
         U software_init_hook
08000000 T g_pfnVectors
080000c0 t __do_global_dtors_aux
080000e8 t frame_dummy
08000120 T _Z5setupv
08000128 T _Z4loopv
08000130 T NVIC_SetVector
080001ac T SystemInit
08000244 T SystemCoreClockUpdate
08000314 W SetSysClock
08000324 T SetSysClock_PLL_HSI
080003bc T SysTick_Handler
080003c4 W mbed_main
080003cc T __wrap_main
080003e4 T ticker_irq_handler
08000478 T us_ticker_irq_handler
08000488 t NVIC_EnableIRQ
080004b0 T timer_irq_handler
08000604 T HAL_InitTick
08000700 T mbed_sdk_init
08000708 T set_compare
08000734 T us_ticker_init
08000754 T us_ticker_read
08000820 T us_ticker_set_interrupt
080008ac T us_ticker_disable_interrupt
080008cc T us_ticker_clear_interrupt
080008f0 T main
080009f4 t _Z41__static_initialization_and_destruction_0ii
08000a28 t _GLOBAL__sub_I__Z12insert_eventR9SetupLoopPFvmEmb
08000a40 T HAL_Init
08000a64 W HAL_MspInit
08000a68 W HAL_IncTick
08000a78 W HAL_GetTick
08000a84 T HAL_RCC_OscConfig
08000fb0 T HAL_RCC_ClockConfig
0800125c T HAL_TIM_OC_Init
080012a8 W HAL_TIM_OC_MspInit
080012b0 T HAL_TIM_OC_Start
08001334 T TIM_Base_SetConfig
08001420 T TIM_CCxChannelCmd
0800145c W Reset_Handler
08001464 t CopyDataInit
0800146c t LoopCopyDataInit
0800147a t FillZerobss
08001480 t LoopFillZerobss
08001492 t LoopForever
080014ac W ADC1_COMP_IRQHandler
080014ac W CEC_CAN_IRQHandler
080014ac T Default_Handler
080014ac W DMA1_Channel1_IRQHandler
080014ac W DMA1_Channel2_3_IRQHandler
080014ac W DMA1_Channel4_5_IRQHandler
080014ac W EXTI0_1_IRQHandler
080014ac W EXTI2_3_IRQHandler
080014ac W EXTI4_15_IRQHandler
080014ac W FLASH_IRQHandler
080014ac W HardFault_Handler
080014ac W I2C1_IRQHandler
080014ac W I2C2_IRQHandler
080014ac t Infinite_Loop
080014ac W NMI_Handler
080014ac W PendSV_Handler
080014ac W PVD_IRQHandler
080014ac W RCC_CRS_IRQHandler
080014ac W RTC_IRQHandler
080014ac W SPI1_IRQHandler
080014ac W SPI2_IRQHandler
080014ac W SVC_Handler
080014ac W TIM1_BRK_UP_TRG_COM_IRQHandler
080014ac W TIM1_CC_IRQHandler
080014ac W TIM14_IRQHandler
080014ac W TIM15_IRQHandler
080014ac W TIM16_IRQHandler
080014ac W TIM17_IRQHandler
080014ac W TIM2_IRQHandler
080014ac W TIM3_IRQHandler
080014ac W TIM6_DAC_IRQHandler
080014ac W TSC_IRQHandler
080014ac W USART1_IRQHandler
080014ac W USART2_IRQHandler
080014ac W WWDG_IRQHandler
080014b0 t .udivsi3_skip_div0_test
080014b0 T __aeabi_uidiv
080014b0 T __udivsi3
080015bc T __aeabi_uidivmod
080015d0 W __aeabi_idiv0
080015d0 W __aeabi_ldiv0
080015d4 T __libc_init_array
08001620 T _init
0800162c T _fini
08001638 T AHBPrescTable
08001648 t us_interface
0800165c t us_data
08001664 t __EH_FRAME_BEGIN__
08001664 t __FRAME_END__
08001668 t __etext
08001668 t __exidx_end
08001668 t __exidx_start
08001668 T _sidata
08007c00 r _ZL4test
200000c0 D __data_start__
200000c0 D _sdata
200000c0 d vectors.6667
200000c4 D SystemCoreClock
200000c8 d halTickerFirstInit
200000cc d __frame_dummy_init_array_entry
200000cc d __init_array_start
200000cc d __preinit_array_end
200000cc d __preinit_array_start
200000d4 d __do_global_dtors_aux_fini_array_entry
200000d4 d __init_array_end
200000d8 d __JCR_END__
200000d8 d __JCR_LIST__
200000dc D __data_end__
200000dc D _edata
200000e0 b __bss_start__
200000e0 B _sbss
200000e0 b completed.8019
200000e4 b object.8024
200000fc b vtor_remap
20000100 b events
20000108 b TimMasterHandle
20000144 B PreviousVal
20000148 b TimMasterHandle
20000184 b us_ticker_inited
20000188 B SlaveCounter
20000190 B oc_total
20000198 B oc_rem_part
2000019c B in_interrupt
200001a0 B in_interrupt_counter
200001a4 b _ZL4head
200001a8 b _ZL4tail
200001ac b _ZL4prev
200001b0 b _ZL4iter
200001b4 b uwTick
200001b8 b __bss_end__
200001b8 n __end__
200001b8 n __HeapLimit
200001b8 B _ebss
200001b8 N end
20002000 a __stack
20002000 a __StackLimit
20002000 a __StackTop
20002000 A _estack

zhang wenjin (wjzhang) wrote :
zhang wenjin (wjzhang) wrote :

Sorry! I need check more careful.

Changed in gcc-arm-embedded:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers