<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Copyright (C) 1988-2018 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being "Funding Free Software", the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled "GNU Free Documentation License". (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. --> <!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ --> <head> <title>Emulated TLS (GNU Compiler Collection (GCC) Internals)</title> <meta name="description" content="Emulated TLS (GNU Compiler Collection (GCC) Internals)"> <meta name="keywords" content="Emulated TLS (GNU Compiler Collection (GCC) Internals)"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="index.html#Top" rel="start" title="Top"> <link href="Option-Index.html#Option-Index" rel="index" title="Option Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="Target-Macros.html#Target-Macros" rel="up" title="Target Macros"> <link href="MIPS-Coprocessors.html#MIPS-Coprocessors" rel="next" title="MIPS Coprocessors"> <link href="Target-Attributes.html#Target-Attributes" rel="prev" title="Target Attributes"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en"> <a name="Emulated-TLS"></a> <div class="header"> <p> Next: <a href="MIPS-Coprocessors.html#MIPS-Coprocessors" accesskey="n" rel="next">MIPS Coprocessors</a>, Previous: <a href="Target-Attributes.html#Target-Attributes" accesskey="p" rel="prev">Target Attributes</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p> </div> <hr> <a name="Emulating-TLS"></a> <h3 class="section">18.25 Emulating TLS</h3> <a name="index-Emulated-TLS"></a> <p>For targets whose psABI does not provide Thread Local Storage via specific relocations and instruction sequences, an emulation layer is used. A set of target hooks allows this emulation layer to be configured for the requirements of a particular target. For instance the psABI may in fact specify TLS support in terms of an emulation layer. </p> <p>The emulation layer works by creating a control object for every TLS object. To access the TLS object, a lookup function is provided which, when given the address of the control object, will return the address of the current thread’s instance of the TLS object. </p> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fGET_005fADDRESS"></a>Target Hook: <em>const char *</em> <strong>TARGET_EMUTLS_GET_ADDRESS</strong></dt> <dd><p>Contains the name of the helper function that uses a TLS control object to locate a TLS instance. The default causes libgcc’s emulated TLS helper function to be used. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fREGISTER_005fCOMMON"></a>Target Hook: <em>const char *</em> <strong>TARGET_EMUTLS_REGISTER_COMMON</strong></dt> <dd><p>Contains the name of the helper function that should be used at program startup to register TLS objects that are implicitly initialized to zero. If this is <code>NULL</code>, all TLS objects will have explicit initializers. The default causes libgcc’s emulated TLS registration function to be used. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fVAR_005fSECTION"></a>Target Hook: <em>const char *</em> <strong>TARGET_EMUTLS_VAR_SECTION</strong></dt> <dd><p>Contains the name of the section in which TLS control variables should be placed. The default of <code>NULL</code> allows these to be placed in any section. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fTMPL_005fSECTION"></a>Target Hook: <em>const char *</em> <strong>TARGET_EMUTLS_TMPL_SECTION</strong></dt> <dd><p>Contains the name of the section in which TLS initializers should be placed. The default of <code>NULL</code> allows these to be placed in any section. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fVAR_005fPREFIX"></a>Target Hook: <em>const char *</em> <strong>TARGET_EMUTLS_VAR_PREFIX</strong></dt> <dd><p>Contains the prefix to be prepended to TLS control variable names. The default of <code>NULL</code> uses a target-specific prefix. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fTMPL_005fPREFIX"></a>Target Hook: <em>const char *</em> <strong>TARGET_EMUTLS_TMPL_PREFIX</strong></dt> <dd><p>Contains the prefix to be prepended to TLS initializer objects. The default of <code>NULL</code> uses a target-specific prefix. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fVAR_005fFIELDS"></a>Target Hook: <em>tree</em> <strong>TARGET_EMUTLS_VAR_FIELDS</strong> <em>(tree <var>type</var>, tree *<var>name</var>)</em></dt> <dd><p>Specifies a function that generates the FIELD_DECLs for a TLS control object type. <var>type</var> is the RECORD_TYPE the fields are for and <var>name</var> should be filled with the structure tag, if the default of <code>__emutls_object</code> is unsuitable. The default creates a type suitable for libgcc’s emulated TLS function. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fVAR_005fINIT"></a>Target Hook: <em>tree</em> <strong>TARGET_EMUTLS_VAR_INIT</strong> <em>(tree <var>var</var>, tree <var>decl</var>, tree <var>tmpl_addr</var>)</em></dt> <dd><p>Specifies a function that generates the CONSTRUCTOR to initialize a TLS control object. <var>var</var> is the TLS control object, <var>decl</var> is the TLS object and <var>tmpl_addr</var> is the address of the initializer. The default initializes libgcc’s emulated TLS control object. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fVAR_005fALIGN_005fFIXED"></a>Target Hook: <em>bool</em> <strong>TARGET_EMUTLS_VAR_ALIGN_FIXED</strong></dt> <dd><p>Specifies whether the alignment of TLS control variable objects is fixed and should not be increased as some backends may do to optimize single objects. The default is false. </p></dd></dl> <dl> <dt><a name="index-TARGET_005fEMUTLS_005fDEBUG_005fFORM_005fTLS_005fADDRESS"></a>Target Hook: <em>bool</em> <strong>TARGET_EMUTLS_DEBUG_FORM_TLS_ADDRESS</strong></dt> <dd><p>Specifies whether a DWARF <code>DW_OP_form_tls_address</code> location descriptor may be used to describe emulated TLS control objects. </p></dd></dl> <hr> <div class="header"> <p> Next: <a href="MIPS-Coprocessors.html#MIPS-Coprocessors" accesskey="n" rel="next">MIPS Coprocessors</a>, Previous: <a href="Target-Attributes.html#Target-Attributes" accesskey="p" rel="prev">Target Attributes</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p> </div> </body> </html>