Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 234068 - prelinking a c++ shared library causes the symbols to not load correctly in gdb
Summary: prelinking a c++ shared library causes the symbols to not load correctly in gdb
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: prelink
Version: 4.4
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2007-03-26 20:50 UTC by Cameron Ring
Modified: 2012-06-20 16:01 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2012-06-20 16:01:13 UTC
Target Upstream Version:

Attachments (Terms of Use)
Repro case (deleted)
2007-03-26 20:50 UTC, Cameron Ring
no flags Details
Patch (deleted)
2007-03-26 20:52 UTC, Cameron Ring
no flags Details | Diff

Description Cameron Ring 2007-03-26 20:50:47 UTC
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 (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
11      C::C(bool f) {

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

Additional info:
As stated in, 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 20:50:47 UTC
Created attachment 150954 [details]
Repro case

Comment 2 Cameron Ring 2007-03-26 20:52:06 UTC
Created attachment 150955 [details]

Fix for the bug by making sure .debug_loc is updated in adjust_dwarf2_loc

Comment 3 Jiri Pallich 2012-06-20 16:01:13 UTC
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

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.