cancel
Showing results for 
Search instead for 
Did you mean: 

What is ltrans.o in .text section?

JD1800
Associate II

I am using STM32Cube IDE to build for the STM32F030. The MCU we are using has 16 KB flash, and we are looking for ways to reduce the build size to get it to fit. In the process of looking at module build sizes, I noticed the following at the start of the .text section:

.text 0x00000000080000c0 0x56c4
0x00000000080000c0 . = ALIGN (0x4)
*(.text)
.text 0x00000000080000c0 0x48 d:/st/stm32cubeide_1.12.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.200.202301161003/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v6-m/nofp/crtbegin.o
.text 0x0000000008000108 0x16e8 C:\Users\John\AppData\Local\Temp\RF_MCU_FW.elf.itYf8e.ltrans0.ltrans.o
0x000000000800166c EXTI4_15_IRQHandler

I am wondering what ltrans0.ltrans.o is or contains, as it is using over 5 KB of flash, making it the single largest component in flash. But I cannot seem to find anything that describes what it is. Can anyone tell me what ltrans is?

When I looked at some projects that were built using System Workbench for STM32, I did not see this ltrans component. So that makes me more curious on what it is and if it is necessary.

1 ACCEPTED SOLUTION

Accepted Solutions

hello @JD1800 

to have a better understanding of -flto optimization flag, here below a small part of what you could find here :

-flto[=n]This option runs the standard link-time optimizer. When invoked with source code, it generates GIMPLE (one of GCC's internal representations) and writes it to special ELF sections in the object file. When the object files are linked together, all the function bodies are read from these ELF sections and instantiated as if they had been part of the same translation unit.

Note that when a file is compiled with -flto, the generated object file is larger than a regular object file because it contains GIMPLE bytecodes and the usual final code. 

ARM site caution : https://developer.arm.com/documentation/100067/0612/armclang-Command-line-Options/-flto---fno-lto

Caution

Object files generated using the -flto option are not suitable for creating static libraries, or ROPI or RWPI images.

Caution

Link Time Optimization performs aggressive optimizations by analyzing the dependencies between bitcode format objects. This can result in the removal of unused variables and functions in the source code.
 

Best regards

Mikael

If you feel a post has answered your question, please click "Accept as Solution".

 

 
If you feel a post has answered your question, please click Accept as Solution.

View solution in original post

2 REPLIES 2
JD1800
Associate II

I think I might have figured this out. I had used the -flto flag to decrease code size, and I discovered that this ltrans.o object only exists when -flto flag is used. What it looks like to me is that link time optimized code is getting built into the ltrans.o object and included in the .text section.

hello @JD1800 

to have a better understanding of -flto optimization flag, here below a small part of what you could find here :

-flto[=n]This option runs the standard link-time optimizer. When invoked with source code, it generates GIMPLE (one of GCC's internal representations) and writes it to special ELF sections in the object file. When the object files are linked together, all the function bodies are read from these ELF sections and instantiated as if they had been part of the same translation unit.

Note that when a file is compiled with -flto, the generated object file is larger than a regular object file because it contains GIMPLE bytecodes and the usual final code. 

ARM site caution : https://developer.arm.com/documentation/100067/0612/armclang-Command-line-Options/-flto---fno-lto

Caution

Object files generated using the -flto option are not suitable for creating static libraries, or ROPI or RWPI images.

Caution

Link Time Optimization performs aggressive optimizations by analyzing the dependencies between bitcode format objects. This can result in the removal of unused variables and functions in the source code.
 

Best regards

Mikael

If you feel a post has answered your question, please click "Accept as Solution".

 

 
If you feel a post has answered your question, please click Accept as Solution.