[Lldb-commits] [lldb] [lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size as symbols are created (PR #106791)

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 3 16:44:43 PDT 2024


jasonmolenda wrote:

OK, I see in `Symtab::InitAddressIndexes` we go through the symbol table and calculate the sizes of any entries that don't have a size based on the next symbol, or the end of the section.  

A little further in ObjectFileMachO::ParseSymtab when we add any LC_FUNCTION_STARTS entries to the symbol table, we calculate the size of the symbols based on the symbols we have parsed so far, 

```
            uint32_t symbol_byte_size = 0;
            if (symbol_section) {
              const addr_t section_file_addr = symbol_section->GetFileAddress();
              const FunctionStarts::Entry *next_func_start_entry =
                  function_starts.FindNextEntry(func_start_entry);
              const addr_t section_end_file_addr =
                  section_file_addr + symbol_section->GetByteSize();
              if (next_func_start_entry) {
                addr_t next_symbol_file_addr = next_func_start_entry->addr;
                if (is_arm)   
                  next_symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
                symbol_byte_size = std::min<lldb::addr_t>(
                    next_symbol_file_addr - symbol_file_addr,
                    section_end_file_addr - symbol_file_addr);
              } else {            
                symbol_byte_size = section_end_file_addr - symbol_file_addr;
              }             
```

and this should probably set the size to 0 as well, leaving it to `Symtab::InitAddressIndexes` to do the same calculation. Does this sound right to you?

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


More information about the lldb-commits mailing list