You copied the Doc URL to your clipboard.

Arm Compiler armclang Reference Guide : -ffunction-sections, -fno-function-sections

-ffunction-sections, -fno-function-sections

-ffunction-sections generates a separate ELF section for each function in the source file. The unused section elimination feature of the linker can then remove unused functions at link time.

The output section for each function has the same name as the function that generates the section, but with a .text. prefix. To disable this, use -fno-function-sections.

Note

If you want to place specific data items or structures in separate sections, mark them individually with __attribute__((section("name"))).

Default

-ffunction-sections is set by default.

Restrictions

-ffunction-sections reduces the potential for sharing addresses, data, and string literals between functions. Consequently, it might increase code size slightly for some functions.

Example

int function1(int x)
{
  return x+1;
}

int function2(int x)
{
  return x+2;
}

Compiling this code with -ffunction-sections produces:

armclang --target=arm-arm-none-eabi -march=armv8-a -ffunction-sections -S -O3 -o- main.c
				
...				
    .section    .text.function1,"ax",%progbits
    .globl      function1
    .p2align    2
    .type       function1,%function
function1:                              @ @function1
    .fnstart
@ BB#0:
    add         r0, r0, #1
    bx          lr
.Lfunc_end0:
    .size	  function1, .Lfunc_end0-function1
    .cantunwind
    .fnend

    .section    .text.function2,"ax",%progbits
    .globl	 function2
    .p2align    2
    .type	  function2,%function
function2:                              @ @function2
    .fnstart
@ BB#0:
    add	    r0, r0, #2
    bx	     lr
.Lfunc_end1:
    .size       function2, .Lfunc_end1-function2
    .cantunwind
    .fnend
...
Was this page helpful? Yes No