Cortex-M3 low level assert issue.

Jack Applegame japplegame at gmail.com
Wed May 1 21:55:09 UTC 2019


file test.d:

```
module test;

struct Foo {
     struct Bar {
         struct Baz {
         }
     }
}

void foo() {
     assert(0);
}
```

compile and dump:

```
$ ldc2 -c -mtriple=thumb-none-linux-eabi -mcpu=cortex-m3 test.d
$ arm-none-eabi-objdump -dhsS test.o > test.o.dump
```

LDC compiles `assert(0)` to `_d_assert(file, line)` call and puts 
file name (test.d) to section `.rodata.str1.1`:

```
Contents of section .rodata.str1.1:
  0000 74657374 2e466f6f 2e426172 00746573  test.Foo.Bar.tes
  0010 742e466f 6f007465 73742e64 00        t.Foo.test.d.
```

The problem is that this section also contains symbols 
`test.Foo.Bar` and `test.Foo`. I don't know why these symbols are 
needed, but they are definitely not used in the program. And 
because they are in the same section as `test.d`, this whole 
section goes into firmware.

In my real application, such useless data occupy an unacceptable 
amount of flash memory of the MCU. It would be nice to get rid of 
them.



More information about the digitalmars-d-ldc mailing list