yurko yurko - 8 days ago 9
C Question

Difference between *(.data), *(.data*) and *(.data.*) in linker script

Just curious to know what is the difference between such constructions (for text, data, rodata, bss etc) in linker script:

.data :
{
*(.data)
}


.data :
{
*(.data*)
}


.data :
{
*(.data.*)
}


In all cases we gather data sections from all object files, but the devil is in the detail.

Fast test showed that addresses in map file differ and in turn it influences the size of executable file.

I tried to find the information in ld documentation but found nothing (or just missed it).

I guess that it should be something very simple (so called obvious).

Any ideas will be highly appreciated.

Answer

In any place where you may use a specific file or section name, you may also use a wildcard pattern.

It works like a regular pattern

  • *(.data) - .data sections, Example: .data
  • *(.data*)- .data* section, Example: .dataTEST
  • *(.data.*) - .data.* section, Example: .data.TEST

Find more info here

Comments