int i;
int main() {
return i;
}
Après -static
compilent readelf -l
montre les en-têtes de programme d'Elf:sections programme fichier ELF TLS et CHARGE
Elf file type is EXEC (Executable file)
Entry point 0xxxxx30
There are 6 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x08048000 0x08048000 0x79868 0x79868 R E 0x1000
> LOAD 0x079f94 0x080c2f94 0x080c2f94 0x0078c 0x02254 RW 0x1000 <<
NOTE 0x0000f4 0x080480f4 0x080480f4 0x00020 0x00020 R 0x4
> TLS 0x079f94 0x080c2f94 0x080c2f94 0x00010 0x0002c R 0x4 <<
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4
PAX_FLAGS 0x000000 0x00000000 0x00000000 0x00000 0x00000 0x4
Section to Segment mapping:
Segment Sections...
00 .note.ABI-tag .init .text __libc_freeres_fn .fini .rodata __libc_subfreeres __libc_atexit .eh_frame .gcc_except_table
01 .tdata .ctors .dtors .jcr .data.rel.ro .got .got.plt .data .bss __libc_freeres_ptrs
02 .note.ABI-tag
03 .tdata .tbss
quelqu'un peut-il expliquer, pourquoi les 2e et 4e têtes de programme ne se croisent (ils commencent par même décalage 0x079f94 et VirtAddr 0x080c2f94).
En outre, la section de segment .tdata
est référencée deux fois.
Comment PT_TLS
et PT_LOAD
seront chargés pour le premier thread (le programme lui-même)? Où se trouve .tbss
dans la mémoire?
ressemble à tls placé sur HEAP ... – osgx
Vous pouvez vérifier comment TLS est chargé par grepping stracing pour 'set_thread_area' syscall – osgx