The contents from section .CRT$XLA to .CRT$XLZ is an array of function pointers. They are called by the runtime when a new thread is created or (gracefully) terminated. You can make your own initialization function to be called by that mechanism. All you have to do is: - Define a pointer to a function in a .CRT$XL* section using pragma - Make an external reference to "__tls_used" symbol That technique is used in many projects. This patch is to support that. What this patch does is to set the relative virtual address of "__tls_used" to the PECOFF directory table. __tls_used is actually a struct containing pointers to a symbol in .CRT$XLA and another symbol in .CRT$XLZ. The runtime looks at the directory table, gets the address of the struct, and call the function pointers between XLA and XLZ. llvm-svn: 218007
15 lines
514 B
Plaintext
15 lines
514 B
Plaintext
# RUN: yaml2obj %p/Inputs/hello.obj.yaml > %t1.obj
|
|
# RUN: yaml2obj %p/Inputs/tlsused.obj.yaml > %t2.obj
|
|
|
|
# RUN: lld -flavor link /out:%t1.exe /subsystem:console /force -- %t1.obj
|
|
# RUN: llvm-readobj -file-headers %t1.exe | FileCheck -check-prefix=NOTLS %s
|
|
|
|
# RUN: lld -flavor link /out:%t2.exe /subsystem:console /force -- %t1.obj %t2.obj
|
|
# RUN: llvm-readobj -file-headers %t2.exe | FileCheck -check-prefix=TLS %s
|
|
|
|
NOTLS: TLSTableRVA: 0x0
|
|
NOTLS: TLSTableSize: 0x0
|
|
|
|
TLS: TLSTableRVA: 0x1014
|
|
TLS: TLSTableSize: 0x18
|