From 4e0b4a5de735ecb241fadb1e15381c947e16e71f Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 19 Jun 2014 02:50:45 -0400 Subject: add tlsdesc support for i386 --- arch/i386/reloc.h | 2 ++ src/ldso/i386/tlsdesc.s | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/ldso/i386/tlsdesc.s diff --git a/arch/i386/reloc.h b/arch/i386/reloc.h index 12224b79..eaf5aae0 100644 --- a/arch/i386/reloc.h +++ b/arch/i386/reloc.h @@ -26,6 +26,8 @@ static int remap_rel(int type) return REL_TPOFF; case R_386_TLS_TPOFF32: return REL_TPOFF_NEG; + case R_386_TLS_DESC: + return REL_TLSDESC; } return 0; } diff --git a/src/ldso/i386/tlsdesc.s b/src/ldso/i386/tlsdesc.s new file mode 100644 index 00000000..3ac61297 --- /dev/null +++ b/src/ldso/i386/tlsdesc.s @@ -0,0 +1,27 @@ +.text +.global __tlsdesc_static +.type __tlsdesc_static,@function +__tlsdesc_static: + mov 4(%eax),%eax + ret + +.global __tlsdesc_dynamic +.type __tlsdesc_dynamic,@function +__tlsdesc_dynamic: + mov 4(%eax),%eax + push %edx + mov %gs:4,%edx + push %ecx + mov (%eax),%ecx + cmp %ecx,(%edx) + jc 1f + mov 4(%eax),%eax + add (%edx,%ecx,4),%eax +2: pop %ecx + sub %gs:0,%eax + pop %edx + ret +1: push %eax + call __tls_get_addr + pop %ecx + jmp 2b -- cgit v1.2.1