Bug 234068 - prelinking a c++ shared library causes the symbols to not load correctly in gdb
prelinking a c++ shared library causes the symbols to not load correctly in gdb
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: prelink (Show other bugs)
4.4
All Linux
medium Severity low
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-03-26 16:50 EDT by Cameron Ring
Modified: 2012-06-20 12:01 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-20 12:01:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Repro case (676 bytes, application/x-gzip)
2007-03-26 16:50 EDT, Cameron Ring
no flags Details
Patch (580 bytes, patch)
2007-03-26 16:52 EDT, Cameron Ring
no flags Details | Diff

  None (edit)
Description Cameron Ring 2007-03-26 16:50:47 EDT
Description of problem: prelinking a c++ shared library causes the symbols to
not load correctly in gdb.

Version-Release number of selected component (if applicable): 0.3.9-2

How reproducible: 100% with the provided test case

Steps to Reproduce:
1. Uncompress provided test case and cd into that directory
2. make
3. /usr/sbin/prelink -r0x22b000 libtest.so (the bug happens whether you prelink
or even just relocate. relocating has the benefit of not requiring root)
4. LD_LIBRARY_PATH=. gdb exe
5. b main
6. r
7. s
8. s
  
Actual results:
C (this=Could not find the frame base for "C".
) at lib.cc:11
11      C::C(bool f) {

Expected results:
C (this=0xbfecb457, f=true) at lib.cc:11
11      C::C(bool f) {

Additional info:
As stated in http://people.redhat.com/jakub/prelink.pdf, relocating a library
with prelink should be equivalent to specifying a non-standard base address
using a linker script. However, readelf -wo shows a discrepancy in the
.debug_loc section for a  library relocated by prelink and one built using a
linker script (ignore the readelf bug that only prints the first group, that's
enough to see the problem):

Relocated by prelink:
Contents of the .debug_loc section:
    Offset   Begin    End      Expression
    00000000 00000640 00000641 (DW_OP_breg4: 4)
    00000000 00000641 00000643 (DW_OP_breg4: 8)
    00000000 00000643 00000647 (DW_OP_breg5: 8)


Linker script:
Contents of the .debug_loc section:
    Offset   Begin    End      Expression
    00000000 0022b640 0022b641 (DW_OP_breg4: 4)
    00000000 0022b641 0022b643 (DW_OP_breg4: 8)
    00000000 0022b643 0022b647 (DW_OP_breg5: 8)

The above shows that prelink is not updating the .debug_loc section when
relocating the library, causing gdb to not be able to find the symbols. 

The included patch makes sure to update the .debug_loc section, which allows gdb
to find the symbols correctly.

Also, stripping the symbols into a separate symbol file works around the problem
as gdb is then responsible for offsetting the symbols by the library base address.
Comment 1 Cameron Ring 2007-03-26 16:50:47 EDT
Created attachment 150954 [details]
Repro case
Comment 2 Cameron Ring 2007-03-26 16:52:06 EDT
Created attachment 150955 [details]
Patch

Fix for the bug by making sure .debug_loc is updated in adjust_dwarf2_loc
Comment 3 Jiri Pallich 2012-06-20 12:01:13 EDT
Thank you for submitting this issue for consideration in Red Hat Enterprise Linux. The release for which you requested us to review is now End of Life. 
Please See https://access.redhat.com/support/policy/updates/errata/

If you would like Red Hat to re-consider your feature request for an active release, please re-open the request via appropriate support channels and provide additional supporting details about the importance of this issue.

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