Bug 1247050

Summary: glibc should support static PIE binaries
Product: [Fedora] Fedora Reporter: Dominik 'Rathann' Mierzejewski <dominik>
Component: glibcAssignee: Carlos O'Donell <codonell>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: arjun, codonell, dennis, dominik, fweimer, jakub, law, mfabian, mnewsome, pfrankli
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.26.9000-44.fc28 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-05 15:19:36 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: 1239338, 1239796    

Description Dominik 'Rathann' Mierzejewski 2015-07-27 08:40:55 UTC
Description of problem:
libpthread.a is compiled without -fPIC, causing linking errors in other packages, for example prelink.

Version-Release number of selected component (if applicable):
glibc-static-2.21.90-18.fc24.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. checkout prelink f22 branch
2. try to build it in rawhide mock

Actual results:
/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libpthread.a(libpthread.o): relocation R_X86_64_32S against `__stack_user' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/libpthread.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

Expected results:
prelink builds normally.

Comment 1 Jakub Jelinek 2015-07-27 08:44:21 UTC
IMNSHO this is not a bug.  If you link against these libraries statically, you should link them statically too.

Comment 2 Carlos O'Donell 2015-07-28 02:29:56 UTC
(In reply to Jakub Jelinek from comment #1)
> IMNSHO this is not a bug.  If you link against these libraries statically,
> you should link them statically too.

Agreed.

(In reply to Dominik 'Rathann' Mierzejewski from comment #0)
> Description of problem:
> libpthread.a is compiled without -fPIC, causing linking errors in other
> packages, for example prelink.

Why are you linking in a static libpthread to create a shared object?

Comment 3 Dominik 'Rathann' Mierzejewski 2015-07-31 13:37:59 UTC
(In reply to Carlos O'Donell from comment #2)
> (In reply to Dominik 'Rathann' Mierzejewski from comment #0)
> > Description of problem:
> > libpthread.a is compiled without -fPIC, causing linking errors in other
> > packages, for example prelink.
> 
> Why are you linking in a static libpthread to create a shared object?

That's actually a question for Jakub, as prelink is his code. However, since execstack is being packaged separately (bug 1247795), this will become moot unless someone wants to unretire prelink.

Comment 4 Florian Weimer 2016-02-05 15:20:01 UTC
*** Bug 1239796 has been marked as a duplicate of this bug. ***

Comment 5 Florian Weimer 2018-01-19 16:36:59 UTC
glibc-2.26.9000-44.fc28 provides static PIE support on aarch64, i686, x86-64.

GCC 8 will simplify matters by including the -static-pie option.