[Lldb-commits] [PATCH] D68536: [MachO] Fix symbol merging during symtab parsing.

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 4 23:02:38 PDT 2019


JDevlieghere created this revision.
JDevlieghere added reviewers: clayborg, jasonmolenda, labath, aprantl, friss.
Herald added a subscriber: abidh.
Herald added a project: LLDB.

The symtab parser in ObjectFileMachO has logic to coalesce debug (STAB) and non-debug symbols, based on the address and the symbol name, for static (STSYM) and global symbols (GSYM) respectively. It makes the assumption that the debug variant is always encountered first. Rather than creating a second entry in the symbol table for the non-debug symbol, the non-debug symbol gets merged into the existing debug symbol.

This breaks when the linker emits the non-debug symbol first. We'd end up with two entries in the symbol table, each containing part of the information LLDB relies on. Indeed, commenting out the merging logic breaks the test suite spectacularly.

This patch solves that problem by always parsing the debug symbols first. This guarantees that the assumption for merging holds.

PS: I'm not particularly proud of the way this turned out, but after numerous attempts this is the best solution I could come up with. The symtab parsing logic is pretty complex in that it touches a lot of things. I've experienced first hand that it's very easy to break things. I believe this approach strikes a balance between fixing the issue while limiting the risk of regressions.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68536

Files:
  lldb/lit/ObjectFile/Inputs/SymbolTable.yaml
  lldb/lit/ObjectFile/TestSymbolTable.test
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68536.223363.patch
Type: text/x-patch
Size: 30147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191005/28bb2acf/attachment-0001.bin>


More information about the lldb-commits mailing list