Bug 1081960

Summary: glibc: PIE alters names returned by dladdr
Product: [Fedora] Fedora Reporter: Florian Weimer <fweimer>
Component: glibcAssignee: Carlos O'Donell <codonell>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 23CC: codonell, fweimer, jakub, law, mnewsome, pfrankli
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-24 18:04:57 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:
Attachments:
Description Flags
dladdr.c none

Description Florian Weimer 2014-03-28 10:10:19 UTC
Created attachment 879776 [details]
dladdr.c

Without PIE, I get this output:

[fweimer@oldenburg tmp]$ gcc dladdr.c -ldl
[fweimer@oldenburg tmp]$ ./a.out 
open: 0x4006f0
dli_fname: ./a.out
dli_fbase: 0x400000
dli_sname: open
dli_saddr: 0x4006f0

chdir: 0x400670
dli_fname: ./a.out
dli_fbase: 0x400000
dli_sname: chdir
dli_saddr: 0x400670

fstat: 0x400990
dli_fname: ./a.out
dli_fbase: 0x400000
dli_sname: (null)
dli_saddr: (nil)

fstat64: 0x4009a0
dli_fname: ./a.out
dli_fbase: 0x400000
dli_sname: (null)
dli_saddr: (nil)

dlsym: 0x400700
dli_fname: ./a.out
dli_fbase: 0x400000
dli_sname: dlsym
dli_saddr: 0x400700

But if I activate PIE, the output for "open" changes:

[fweimer@oldenburg tmp]$ gcc -fpie -pie dladdr.c -ldl
[fweimer@oldenburg tmp]$ ./a.out 
open: 0x7fefe5263580
dli_fname: /lib64/libc.so.6
dli_fbase: 0x7fefe517d000
dli_sname: __open64
dli_saddr: 0x7fefe5263580

chdir: 0x7fefe5263fd0
dli_fname: /lib64/libc.so.6
dli_fbase: 0x7fefe517d000
dli_sname: chdir
dli_saddr: 0x7fefe5263fd0

fstat: 0x7fefe5962c30
dli_fname: ./a.out
dli_fbase: 0x7fefe5962000
dli_sname: (null)
dli_saddr: (nil)

fstat64: 0x7fefe5962c40
dli_fname: ./a.out
dli_fbase: 0x7fefe5962000
dli_sname: (null)
dli_saddr: (nil)

dlsym: 0x7fefe553d150
dli_fname: /lib64/libdl.so.2
dli_fbase: 0x7fefe553c000
dli_sname: dlsym
dli_saddr: 0x7fefe553d150

It would be nice if I could get consistent output in all cases.  The resolution for fstat and fstat64 is missing as well, which is somewhat annoying.

(I use dladdr to obtain function names for error messages in a C++ wrapper, to avoid the need for a separate string constant with the function name.)

Comment 1 Fedora End Of Life 2015-05-29 11:23:29 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 2 Jan Kurik 2015-07-15 14:41:46 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 23 development cycle.
Changing version to '23'.

(As we did not run this process for some time, it could affect also pre-Fedora 23 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 23 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora23

Comment 3 Fedora End Of Life 2016-11-24 11:08:37 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Florian Weimer 2016-11-24 18:04:44 UTC
If a function is aliased, it the name returned by dladdr is not deterministic.

The missing symbols come from libc_nonshared.a, so this is expected as well.