Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 755872 - -fpie + -pie does not appear to work with __thread variables
-fpie + -pie does not appear to work with __thread variables
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: binutils (Show other bugs)
5.8
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Andreas Schwab
qe-baseos-tools
:
Depends On:
Blocks: 758797
  Show dependency treegraph
 
Reported: 2011-11-22 05:00 EST by Paolo Bonzini
Modified: 2013-01-09 06:56 EST (History)
4 users (show)

See Also:
Fixed In Version: binutils-2.17.50.0.6-20.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-02-21 01:39:41 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0271 normal SHIPPED_LIVE binutils bug fix update 2012-02-20 10:06:19 EST

  None (edit)
Description Paolo Bonzini 2011-11-22 05:00:49 EST
Description of problem:
Compiling this little program as a PIE leads to problems on x86-64:

$ cat w.c
__thread int a;

int
main(void)
{
  return a;
}

Using

  gcc -o w -g -O2 -pie -fpie w.c

one sees

/usr/bin/ld: /tmp/ccU3JvLp.o: relocation R_X86_64_TPOFF32 against `a' can not
be used when making a shared object; recompile with -fPIC

It works with "-fpic -ftls-model=initial-exec", but not with "-fpic -ftls-model=local-exec".

Based on http://sourceware.org/bugzilla/show_bug.cgi?id=10434 and the two-line patch there (http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&r1=1.178&r2=1.179), it's a simple mistake where the linker allows local-exec only for non-PIC (!info->shared) instead of testing for executable vs shared (info->executable).

Version-Release number of selected component (if applicable):
binutils-2.17.50.0.6-14.el5

How reproducible:
100%

Steps to Reproduce:
1. See above.
  
Actual results:
Binaries that use TLS cannot be hardened with PIE.

Expected results:
Hardened binaries can use TLS.

Additional info:
Reproduced with QEMU 1.0-rc3.
Comment 5 errata-xmlrpc 2012-02-21 01:39:41 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0271.html

Note You need to log in before you can comment on or make changes to this bug.