Description
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).
(We're tracking this internally as rdar://124467787.)