[Lldb-commits] [lldb] [lldb] Fix block address resolution for functions in multiple sections (PR #137955)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri May 2 06:51:08 PDT 2025


================
@@ -283,39 +283,42 @@ uint32_t Block::GetRangeIndexContainingAddress(const Address &addr) {
   return m_ranges.FindEntryIndexThatContains(file_addr - func_file_addr);
 }
 
+static AddressRange ToAddressRange(const Address &func_addr,
+                                   const Block::Range &range) {
+  assert(func_addr.GetModule());
+  return AddressRange(func_addr.GetFileAddress() + range.base, range.size,
----------------
labath wrote:

A "file address" is an established (if somewhat confusing) concept. It roughly means "address, as specified in the (object) file". In elf terms, it's the "virtual address". After the file is loaded to memory, it gets a "load address" (by adding a constant to the file address).

`func_addr.GetFileAddress()` returns the (file) address of the function entry point, though that's not completely relevant in this case. The point is that addresses in the block are stored as offsets from some address (which happens to be the function entry point, but in theory we could have pick something else as well). This undoes the transformation, which confusingly doesn't happen inside this class, but (e.g.) in SymbolFileDWARF::ParseBlocksRecursive.

https://github.com/llvm/llvm-project/pull/137955


More information about the lldb-commits mailing list