LTO and global variables used to create a memory area

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

I'm compiling for a cortex-m0 with a very small memory, so I would like to
use LTO to minimize my program size.

I compile all the source files of an SDK to object files. Then I create an
archive with gcc-ar. Finally I link everything together with gcc.
Everything except this global variable works as expected both with and
without LTO. I fail to understand why the variable is removed when I enable
LTO.

As you can see in the output maps below, the size in the correct version is
0x80c, whereas it is 0 in the bad output.

When I look at the object files and archives with gcc-nm they look the same
with and without -flto.

I guess this is a "hack" to define the size of a heap. But if there is
another way to achieve the same result I'm all open for it. This memory
area is referenced by code that is burned into a ROM at manufacturing time.
So it is used, but of course GCC doesn't see that.

The variable is defined like this:

```
uint32_t rwip_heap_non_ret[RWIP_CALC_HEAP_LEN(RWIP_HEAP_NON_RET_SIZE_JT)]
 __attribute__((section("heap_mem_area_not_ret")));
```

It is referenced like this in the linker script:
```
    ER_NZI (NOLOAD) :
    {
        . = ALIGN(4);
        __heap_mem_area_not_ret_start__ = .;
        *jump_table.o(heap_mem_area_not_ret)    /* not retained HEAP */
        __heap_mem_area_not_ret_end__ = .;
    } > LR_IROM3
```



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux