1 .section ".tdata", "awT", @progbits 2 .globl baz 3 .hidden baz 4 .globl var 5 .hidden var2 6 bar: .long 27 7 baz: .long 29 8 var: .long 31 9 var2: .long 33 10 .text 11 .globl fn 12 .type fn,@function 13 fn: 14 /* Main binary, no PIC. */ 15 1: movl 1b, %edx 16 addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx 17 18 /* foo can be anywhere in startup TLS. */ 19 movl %gs:0, %eax 20 subl foo@GOTTPOFF(%edx), %eax 21 /* %eax now contains &foo. */ 22 23 /* bar only in the main program. */ 24 movl %gs:0, %eax 25 subl $bar@TPOFF, %eax 26 /* %eax now contains &bar. */ 27 28 /* baz only in the main program. */ 29 movl %gs:0, %ecx 30 /* Arbitrary instructions in between. */ 31 nop 32 subl $baz@TPOFF, %ecx 33 /* %ecx now contains &baz. */ 34 35 /* var and var2 only in the main program. */ 36 movl %gs:0, %ecx 37 /* Arbitrary instructions in between. */ 38 nop 39 nop 40 leal var@NTPOFF(%ecx), %eax 41 /* Arbitrary instructions in between. */ 42 nop 43 leal var2@NTPOFF(%ecx), %edx 44 45 /* foo can be anywhere in startup TLS. */ 46 movl foo@INDNTPOFF, %eax 47 movl %gs:(%eax), %eax 48 /* %eax now contains foo. */ 49 50 movl %gs:0, %eax 51 addl foo@INDNTPOFF, %eax 52 /* %eax now contains &foo. */ 53 54 ret 55