Skip to content

[LLDB][ELF] LLDB gets confused if there are multiple .text sections in a binary #88001

Closed
@al45tair

Description

@al45tair

I had a Swift PR open (swiftlang/swift#72061) that changes how Swift handles the metadata sections (in particular), but as a consequence causes the compiler to set SHF_GNU_RETAIN on other sections as well. At time of writing, all of the tests are passing except some LLDB API tests, which was very puzzling.

The problem appears to be that, because of the behaviour of older versions of ld.gold (prior to binutils 2.36), libswiftCore.so ends up with two .text sections, and then when LLDB tries to print a Swift object, it attempts to call Swift._DebuggerSupport.stringForPrintObject, but gets mixed up and adds the offset it found for that function to the wrong .text section, jumps into the end of an entirely unrelated function and (eventually) crashes after triggering an assertion failure.

The bug here is that LLDB appears to get confused about the presence of two .text sections, which leads to symbol lookups going awry.

I've attached a small reproducer, which doesn't need Swift (or anything to do with Swift).

lldb-two-text-sections.tar.gz

(We're tracking this internally as rdar://124467787.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions