Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

gcc

linker

ld

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.

like image 271
yurko Avatar asked Nov 24 '16 12:11

yurko


1 Answers

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

like image 110
Laser Avatar answered Sep 30 '22 15:09

Laser