Skip to content

Commit

Permalink
fix Issue 12092 - Wrong TLS access in PIC code (X86_32)
Browse files Browse the repository at this point in the history
- Use RI_TYPE_TLS_GD (general dynamic) to access global
  TLS symbols in PIC code.
  • Loading branch information
MartinNowak committed Dec 30, 2014
1 parent 22611aa commit cadc0f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 0 additions & 4 deletions src/backend/el.c
Expand Up @@ -1472,11 +1472,7 @@ elem * el_var(symbol *s)
//printf("el_var(s = '%s')\n", s->Sident);
//printf("%x\n", s->Stype->Tty);
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
// OSX is currently always pic
if (config.flags3 & CFG3pic &&
#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
(!(s->Stype->Tty & mTYthread) || I64) &&
#endif
!tyfunc(s->ty()))
// Position Independent Code
return el_picvar(s);
Expand Down
8 changes: 5 additions & 3 deletions src/backend/elfobj.c
Expand Up @@ -2974,7 +2974,8 @@ int Obj::reftoident(int seg, targ_size_t offset, Symbol *s, targ_size_t val,
if (config.flags3 & CFG3pic)
{
if (s->Sclass == SCstatic || s->Sclass == SClocstat)
relinfo = R_X86_64_TLSGD; // TLS_GD?
// Could use 'local dynamic (LD)' to optimize multiple local TLS reads
relinfo = R_X86_64_TLSGD;
else
relinfo = R_X86_64_TLSGD;
}
Expand All @@ -2991,9 +2992,10 @@ int Obj::reftoident(int seg, targ_size_t offset, Symbol *s, targ_size_t val,
if (config.flags3 & CFG3pic)
{
if (s->Sclass == SCstatic)
relinfo = R_386_TLS_LE; // TLS_GD?
// Could use 'local dynamic (LD)' to optimize multiple local TLS reads
relinfo = R_386_TLS_GD;
else
relinfo = R_386_TLS_IE;
relinfo = R_386_TLS_GD;
}
else
{
Expand Down

0 comments on commit cadc0f7

Please sign in to comment.