BOLT icon indicating copy to clipboard operation
BOLT copied to clipboard

[Question] What is the .bolt.org.text segment used for?

Open zbetter opened this issue 4 years ago • 4 comments

Hi,

I noticed that the .bolt.org.text segment takes up half of the binary size, but the content of the .bolt.org.text segment already has an optimized edition in the .text and .text.cold segments. I tried to get rid of the .bolt.org.text segment with llvm-objcopy, but the binary won't run.. So what is the .bolt.org.text segment mainly used for?

Thanks!

zbetter avatar Jul 13 '20 09:07 zbetter

I tested a small test case and found that the .bolt.org.text section was consistent with the pre-optimized .text section, and the new .text section and the .text.cold section were not empty. But after I deleted the .text section, the program worked well. I don't know why.

zbetter avatar Jul 14 '20 09:07 zbetter

The answer depends on how you build the application and what BOLT flags you use. If you run in relocation mode (link with --emit-relocs), then .bolt.org.text wouldn't be used unless you also specify -lite. You can also add --use-old-text BOLT flag that will reuse the original section for the optimized code.

maksfb avatar Jul 14 '20 17:07 maksfb

Hi, @maksfb. I have a similar question. Why not just remove .bolt.org.text segment if it won't be used. It can reduce the generated binary size.

getianao avatar Oct 24 '21 15:10 getianao

It should be possible to remove .bolt.org.text, but then to make the use of the created gap we would have to break the containing segment into two.

maksfb avatar Oct 25 '21 03:10 maksfb