arm-none-eabi-g++ does not initialize class static members in code generated on debian
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
code falls in hard fault if I compile it on debian with gcc-arm-
and runs as expected if compiled on ubuntu.
I investigated the case and found that when led_list.
str r0, [r3, #0]
causes Hard Fault.
There differences of contexts of code compiled on ubuntu and debian:
function _ZNSt8_
ldr r3, [r1, #4]
stmia.w r0, {r1, r3}
ldr r3, [r1, #4]
str r0, [r3, #0]
str r0, [r1, #4]
bx lr
debian compiled regs and memory:
r0 0x200014e0
r1 0x20000a3c
r2 0x20000128
r3 0x1
r4 0x20000a3c
r5 0x20000a1c
0x20000a3c <_ZN2lk3led8led
0x20000a44 <_ZN2lk3led8led
ubuntu compiled regs and memory:
r0 0x200014e0
r1 0x20000a0c
r2 0x20000128
r3 0x1
r4 0x20000a0c
r5 0x20000a28
0x20000a0c <_ZN2lk3led8led
0x20000a14 <_ZN2lk3led8led
It is obvious that static std::list<led*> led_list is UNINITIALIZED on debian compiled code.
cpu is STM32F103C8T6
.......
lk::led led0(lk::gpio_c, 13);
.......
namespace lk {
class led : public pin{
int index, cnt, state;
static std::list<led*> led_list;
public:
enum PATTERN {
PTRN_HEARTBEAT = 0x23050505,
PTRN_BLINK = 0x1919,
PTRN_ALARM = 0x0703
};
uint32_t pattern;
int scale;
led(gpio *port, int pin_num)
:pin::pin(port, pin_num, 1)
{
reset();
printf("led\n");
this->pattern = PTRN_HEARTBEAT;
scale = 1;
led_list.
}
.......
namespace lk {
std::list<led*> led::led_list;
}
Changed in gcc-arm-embedded: | |
status: | New → Confirmed |
Here is full project.
folders
build.debian
build.ubuntu
contains .elf .bin .o files
compiled in OS mentioned.