<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Greetings.  I'm submitting a few patches that resolve issues I<br>
encountered when using lldb to symbolicate FreeBSD kernel backtraces.<br>
The problems mostly centered around FreeBSD kernel modules actually<br>
being relocatable (.o) ELF Files.<br>
<br>
The major problems:<br>
<br>
- Relocations were not being applied to the DWARF debug info despite<br>
  there being code to do this.  Several issues prevented it from working:<br>
<br>
  * Relocations are computed at the same time as the symbol table, but<br>
    in the case of split debug files, symbol table parsing always<br>
    redirects to the primary object file, meaning that relocations<br>
    would never be applied in the debug file.<br>
<br>
  * There's actually no guarantee that the symbol table has been<br>
    parsed yet when trying to parse debug information.<br>
<br>
  * When actually applying relocations, it will segfault because the<br>
    object files are not mapped with MAP_PRIVATE and PROT_WRITE.<br>
<br>
- LLDB returned invalid results when performing ordinary<br>
  address-to-symbol resolution. It turned out that the addresses<br>
  specified in the section headers were all 0, so LLDB believed all the<br>
  sections had overlapping "file addresses" and would sometimes<br>
  return a symbol from the wrong section.<br>
<br>
I rearranged some of the symbol table parsing code to ensure<br>
relocations would get applied consistently and added manual calls to<br>
make sure it happens before trying to use DWARF info, but it feels<br>
kind of hacky.  I'm open to suggestions for refactoring it.<br>
<br>
I solved the file address problem by computing synthetic addresses for<br>
the sections in object files so that they would not overlap in LLDB's<br>
lookup maps.<br>
<br>
With all these changes I'm able to successfully symbolicate backtraces<br>
that pass through FreeBSD kernel modules.  Let me know if there is a<br>
better/cleaner way to achieve any of these fixes.<br>
<br>
--<br>
<br>
Brian Koropoff<br>
Dell EMC</div>
</body>
</html>