[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

Martin Storsjö via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 29 00:58:09 PST 2019


mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth.
Herald added subscribers: kristof.beyls, aprantl.
Herald added a reviewer: jdoerfert.
Herald added a project: LLDB.

Windows on ARM is always thumb, and contrary to ELF, there's no per-symbol flag to indicate arm vs thumb mode. Therefore, the linkers both Microsoft's link.exe and lld) sets the thumb bit in all relocations pointing to code sections.

In ELF, the thumb bit is only set for symbols marked as %function, that is, it isn't set in local labels used when constructing the dwarf debug info and line tables.

As the windows linkers sets the thumb bit in all code addresses, we'd have to cope with this and strip out the lowest bit from all code addresses if the architecture is ARM/Thumb.

The testcase uses a prelinked .yaml source instead of an assembly source file, to avoid needing to run a linker as part of the test.

There's already predecent for this in DWARFCallFrameInfo::GetFDEIndex, this extends the same concept to DWARF debug info and line tables. I'm not sure if I managed to get all spots covered here, but I tried to look for all cases of DW_AT_low_pc/DW_AT_high_pc and find the best place to handle it, where it would have to be handled in as few places as possible.

This is admittedly not very pretty, improvement suggestions are welcome.

Finally, this makes sure to propagate the correct address byte size to DataExtractors that are taken from e.g. ObjectFile::ReadSectionData. Previously, the DataExtractor got the host address size set, which later tripped up DWARFDebugLine::LineTable::parse as the address size of the line table (4) mismatched the one set in the DWARFDataExtractor (which was propagated from ObjectFile's internal m_data, which never got anything else set than the default from the host's sizeof(void*)).

This caused line tables to end up missing if inspecting a foreign object file (like in the testcase).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70840

Files:
  lldb/include/lldb/Symbol/LineTable.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Symbol/LineTable.cpp
  lldb/source/Symbol/ObjectFile.cpp
  lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg
  lldb/test/Shell/SymbolFile/DWARF/thumb-windows.yaml

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70840.231485.patch
Type: text/x-patch
Size: 15933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191129/856d6c83/attachment-0001.bin>


More information about the lldb-commits mailing list