Bug 1468808

Summary: gcc: Call __tls_get_addr with a properly aligned stack on x86-64
Product: Red Hat Enterprise Linux 7 Reporter: Florian Weimer <fweimer>
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED CURRENTRELEASE QA Contact: Michael Petlan <mpetlan>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: jakub, law, ohudlick
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-14 17:18:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1473718    

Description Florian Weimer 2017-07-08 08:46:58 UTC
GCC generates code which calls __tls_get_addr with an unaligned stack, violating the x86-64 ABI.  We will compensate  for this in glibc, but the GCC bug should be fixed as well.

The upstream bug has a test case:

static __thread char ccc;
extern "C" void* __cxa_get_globals() throw()
{
 return &ccc;
}

  g++ -fPIC -S -O2 t.cc

results in:

__cxa_get_globals:
       leaq    _ZL3ccc@tlsld(%rip), %rdi
       call    __tls_get_addr@PLT
       addq    $_ZL3ccc@dtpoff, %rax
       ret

Comment 1 Marek Polacek 2017-10-11 11:30:26 UTC
I'm looking at the patches in PR58066 and it's not clear to me which ones need to be applied to fix this, but I'm nervous about backporting them.

Comment 7 Jeff Law 2019-06-14 17:18:22 UTC
This issue won't be fixed for RHEL 7, but it is fixed in RHEL 8.