Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size as symbols are created #106791

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3768,7 +3768,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {

SymbolType type = eSymbolTypeInvalid;
SectionSP symbol_section;
lldb::addr_t symbol_byte_size = 0;
bool add_nlist = true;
bool is_gsym = false;
bool demangled_is_synthesized = false;
Expand Down Expand Up @@ -4354,47 +4353,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {

if (symbol_section) {
const addr_t section_file_addr = symbol_section->GetFileAddress();
if (symbol_byte_size == 0 && function_starts_count > 0) {
addr_t symbol_lookup_file_addr = nlist.n_value;
// Do an exact address match for non-ARM addresses, else get the
// closest since the symbol might be a thumb symbol which has an
// address with bit zero set.
FunctionStarts::Entry *func_start_entry =
function_starts.FindEntry(symbol_lookup_file_addr, !is_arm);
if (is_arm && func_start_entry) {
// Verify that the function start address is the symbol address
// (ARM) or the symbol address + 1 (thumb).
if (func_start_entry->addr != symbol_lookup_file_addr &&
func_start_entry->addr != (symbol_lookup_file_addr + 1)) {
// Not the right entry, NULL it out...
func_start_entry = nullptr;
}
}
if (func_start_entry) {
func_start_entry->data = true;

addr_t symbol_file_addr = func_start_entry->addr;
if (is_arm)
symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;

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;
// Be sure the clear the Thumb address bit when we calculate the
// size from the current and next address
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;
}
}
}
symbol_value -= section_file_addr;
}

Expand Down Expand Up @@ -4501,9 +4459,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
if (nlist.n_desc & N_WEAK_REF)
sym[sym_idx].SetIsWeak(true);

if (symbol_byte_size > 0)
sym[sym_idx].SetByteSize(symbol_byte_size);

if (demangled_is_synthesized)
sym[sym_idx].SetDemangledNameIsSynthesized(true);

Expand Down Expand Up @@ -4622,23 +4577,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
Address symbol_addr;
if (module_sp->ResolveFileAddress(symbol_file_addr, symbol_addr)) {
SectionSP symbol_section(symbol_addr.GetSection());
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;
}
sym[sym_idx].SetID(synthetic_sym_id++);
// Don't set the name for any synthetic symbols, the Symbol
// object will generate one if needed when the name is accessed
Expand All @@ -4650,8 +4589,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
add_symbol_addr(symbol_addr.GetFileAddress());
if (symbol_flags)
sym[sym_idx].SetFlags(symbol_flags);
if (symbol_byte_size)
sym[sym_idx].SetByteSize(symbol_byte_size);
++sym_idx;
}
}
Expand Down
Loading