felknight
felknight

Reputation: 1421

Prevent g++ adding extra elf sections

When compiling with g++ it creates an extra section for almost each function. This occurs on linux with elf64 executable.
By example:

text._ZN12MemoryMapper11SetUpMemoryEP11KernelStart

How can I tell g++ to emit all code on .text so there is only one .text section

This happens with out the -ffunction-sections

And the sections stay even after

objcopy -S file.elf striped

==================================================

Extra information:

CXXFLAGS = -g -O0 -ffreestanding -fno-rtti -fno-exceptions -fno-asynchronous-unwind-tables -std=c++11 $(INCLUDES)
g++ version = gcc (GCC) 5.1.0

Upvotes: 1

Views: 271

Answers (1)

Employed Russian
Employed Russian

Reputation: 213616

text._ZN12MemoryMapper11SetUpMemoryEP11KernelStart

This is an inline function with vague linkage.

You can avoid creating such sections for inline functions by not having any inline functions in your source. There might be an option to disable generating code for inline functions, but I didn't find one.

Note that disabling this is generally a waste of time: they don't hurt anything, and are required if you have multiple compilation units, or you'll get either link errors, or binary bloat.

Upvotes: 3

Related Questions