| Summary: | -fpie + -pie does not appear to work with __thread variables | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 5 | Reporter: | Paolo Bonzini <pbonzini> |
| Component: | binutils | Assignee: | Andreas Schwab <schwab> |
| Status: | CLOSED ERRATA | QA Contact: | qe-baseos-tools-bugs |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 5.8 | CC: | jan.kratochvil, knoel, kraxel, mnowak |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| 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 06:39:41 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Bug Depends On: | |||
| Bug Blocks: | 758797 | ||
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 |
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.