Open Source & Linux Lab

It's better when it's simple

User Tools

Site Tools


etc:users:jcmvbkbc:binutils-xtensa

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
etc:users:jcmvbkbc:binutils-xtensa [2024/02/25 00:59] – add TLS IE and LE jcmvbkbcetc:users:jcmvbkbc:binutils-xtensa [2024/03/18 14:47] (current) jcmvbkbc
Line 1: Line 1:
-===== binutils support for Xtensa =====+====== binutils support for Xtensa ======
  
   * git tree: https://github.com/jcmvbkbc/binutils-gdb-xtensa   * git tree: https://github.com/jcmvbkbc/binutils-gdb-xtensa
  
-==== FDPIC support ====+===== FDPIC support =====
  
   * [+] static linking   * [+] static linking
Line 9: Line 9:
   * [+] PIE   * [+] PIE
   * [±] PLT and lazy binding   * [±] PLT and lazy binding
-  * [-] TLS+  * [+] TLS
  
-==== FDPIC instruction sequences ====+===== FDPIC instruction sequences =====
  
-=== Local call ====+==== Local call ====
  
 Default local call Default local call
Line 44: Line 44:
 </code> </code>
  
-=== PLT call ====+==== PLT call ====
  
 Obvious version: Obvious version:
Line 73: Line 73:
 </code> </code>
 that reduces the inline part from 14 to 5 bytes, but adds two jumps to each call and some special logic to the resolver to avoid name resolution on each call. that reduces the inline part from 14 to 5 bytes, but adds two jumps to each call and some special logic to the resolver to avoid name resolution on each call.
 +
 +==== TLS Support ====
  
 === TLS General Dynamic === === TLS General Dynamic ===
Line 78: Line 80:
 <code> <code>
 +0:     movi    tmp1, x@GOTTLSDESC +0:     movi    tmp1, x@GOTTLSDESC
-+3:     add     arg0, tmp1, localGOTptr ++3:     add     arg0, tmp1, localGOTptr         # TLS_ARG 
-+5:     l32i    tmp2, arg0, 0 ++5:     l32i    tmp2, arg0, 0                   # TLS_FUNCDESC 
-+7:     l32i    GOTptr, tmp2, 4 ++7:     l32i    GOTptr, tmp2, 4                 # TLS_GOT 
-+9:     l32i    tmp3, tmp2, 0 ++9:     _l32i   tmp3, tmp2, 0                   # TLS_FUNC 
-+11:    callx0  tmp3++12:    callx0  tmp3                            # TLS_CALL
 </code> </code>
  
Line 89: Line 91:
 === TLS Local Dynamic === === TLS Local Dynamic ===
  
 +Header getting the address of the _TLS_MODULE_BASE_ is the same as in General Dynamic, or a possible one instruction less version:
 <code> <code>
 +0:     l32i    arg0, localGOTptr, _TLS_MODULE_BASE_DESC_OFF +0:     l32i    arg0, localGOTptr, _TLS_MODULE_BASE_DESC_OFF
 +2:     l32i    tmp1, arg0, 0 +2:     l32i    tmp1, arg0, 0
 +4:     l32i    GOTptr, tmp1, 4 +4:     l32i    GOTptr, tmp1, 4
-+6:     l32i    tmp2, tmp1, 0 ++6:     _l32i   tmp2, tmp1, 0 
-+8:     callx0  tmp2++9:     callx0  tmp2
 ... ...
 +m:     movi    tmp3, x@DTPOFF +m:     movi    tmp3, x@DTPOFF
Line 106: Line 109:
 <code> <code>
 +0:     movi    tmp1, x@GOTTPOFF +0:     movi    tmp1, x@GOTTPOFF
-+3:     add     tmp2, tmp1, localGOTptr ++3:     add     tmp2, tmp1, localGOTptr         # TLS_TPOFF_PTR 
-+5:     l32i    tmp3, tmp2, 0++5:     l32i    tmp3, tmp2, 0                   # TLS_TPOFF_LOAD
 +7:     rur     tmp4, THREADPTR +7:     rur     tmp4, THREADPTR
 +10:    add     res, tmp3, tmp4 +10:    add     res, tmp3, tmp4
Line 116: Line 119:
 <code> <code>
 +0:     movi    tmp1, x@TPOFF +0:     movi    tmp1, x@TPOFF
-+7:     rur     tmp2, THREADPTR ++3:     rur     tmp2, THREADPTR 
-+10:    add     res, tmp1, tmp2++6:     add     res, tmp1, tmp2 
 +</code> 
 + 
 +==== Linker optimizations ==== 
 + 
 +=== General Dynamic -> Initial Exec === 
 + 
 +<code> 
 ++0:     movi    tmp1, x@GOTTLSDESC                                              movi    tmp1, x@GOTTPOFF 
 ++3:     add     arg0, tmp1, localGOTptr         # TLS_ARG                       add     arg0, tmp1, localGOTptr 
 ++5:     l32i    tmp2, arg0, 0                   # TLS_FUNCDESC                  l32i    arg0, arg0, 0 
 ++7:     l32i    GOTptr, tmp2, 4                 # TLS_GOT                       nop 
 ++9:     _l32i   tmp3, tmp2, 0                   # TLS_FUNC                      rur     tmp3, THREADPTR 
 ++12:    callx0  tmp3                            # TLS_CALL                      add     arg0, arg0, tmp3 
 +</code> 
 + 
 +=== General Dynamic -> Local Exec === 
 + 
 +<code> 
 ++0:     movi    tmp1, x@GOTTLSDESC                                              movi    tmp1, x@TPOFF 
 ++3:     add     arg0, tmp1, localGOTptr         # TLS_ARG                       mov     arg0, tmp1 
 ++5:     l32i    tmp2, arg0, 0                   # TLS_FUNCDESC                  nop 
 ++7:     l32i    GOTptr, tmp2, 4                 # TLS_GOT                       nop 
 ++9:     _l32i   tmp3, tmp2, 0                   # TLS_FUNC                      rur     tmp3, THREADPTR 
 ++12:    callx0  tmp3                            # TLS_CALL                      add     arg0arg0, tmp3 
 +</code> 
 + 
 +=== Initial Exec -> Local Exec === 
 + 
 +<code> 
 ++0:     movi    tmp1, x@GOTTPOFF                                                movi    tmp1, x@TPOFF 
 ++3:     add     tmp2, tmp1, localGOTptr         # TLS_TPOFF_PTR                 mov     tmp2, tmp1 
 ++5:     l32i    tmp3, tmp2, 0                   # TLS_TPOFF_LOAD                mov     tmp3, tmp2 
 ++7:     rur     tmp4, THREADPTR                                                 rur     tmp4, THREADPTR 
 ++10:    add     res, tmp3, tmp4                                                 add     res, tmp3, tmp4
 </code> </code>
  
etc/users/jcmvbkbc/binutils-xtensa.1708811955.txt.gz · Last modified: 2024/02/25 00:59 by jcmvbkbc