@@ -3768,6 +3768,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
3768
3768
3769
3769
SymbolType type = eSymbolTypeInvalid;
3770
3770
SectionSP symbol_section;
3771
+ lldb::addr_t symbol_byte_size = 0 ;
3771
3772
bool add_nlist = true ;
3772
3773
bool is_gsym = false ;
3773
3774
bool demangled_is_synthesized = false ;
@@ -4353,6 +4354,47 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
4353
4354
4354
4355
if (symbol_section) {
4355
4356
const addr_t section_file_addr = symbol_section->GetFileAddress ();
4357
+ if (symbol_byte_size == 0 && function_starts_count > 0 ) {
4358
+ addr_t symbol_lookup_file_addr = nlist.n_value ;
4359
+ // Do an exact address match for non-ARM addresses, else get the
4360
+ // closest since the symbol might be a thumb symbol which has an
4361
+ // address with bit zero set.
4362
+ FunctionStarts::Entry *func_start_entry =
4363
+ function_starts.FindEntry (symbol_lookup_file_addr, !is_arm);
4364
+ if (is_arm && func_start_entry) {
4365
+ // Verify that the function start address is the symbol address
4366
+ // (ARM) or the symbol address + 1 (thumb).
4367
+ if (func_start_entry->addr != symbol_lookup_file_addr &&
4368
+ func_start_entry->addr != (symbol_lookup_file_addr + 1 )) {
4369
+ // Not the right entry, NULL it out...
4370
+ func_start_entry = nullptr ;
4371
+ }
4372
+ }
4373
+ if (func_start_entry) {
4374
+ func_start_entry->data = true ;
4375
+
4376
+ addr_t symbol_file_addr = func_start_entry->addr ;
4377
+ if (is_arm)
4378
+ symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
4379
+
4380
+ const FunctionStarts::Entry *next_func_start_entry =
4381
+ function_starts.FindNextEntry (func_start_entry);
4382
+ const addr_t section_end_file_addr =
4383
+ section_file_addr + symbol_section->GetByteSize ();
4384
+ if (next_func_start_entry) {
4385
+ addr_t next_symbol_file_addr = next_func_start_entry->addr ;
4386
+ // Be sure the clear the Thumb address bit when we calculate the
4387
+ // size from the current and next address
4388
+ if (is_arm)
4389
+ next_symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
4390
+ symbol_byte_size = std::min<lldb::addr_t >(
4391
+ next_symbol_file_addr - symbol_file_addr,
4392
+ section_end_file_addr - symbol_file_addr);
4393
+ } else {
4394
+ symbol_byte_size = section_end_file_addr - symbol_file_addr;
4395
+ }
4396
+ }
4397
+ }
4356
4398
symbol_value -= section_file_addr;
4357
4399
}
4358
4400
@@ -4459,6 +4501,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
4459
4501
if (nlist.n_desc & N_WEAK_REF)
4460
4502
sym[sym_idx].SetIsWeak (true );
4461
4503
4504
+ if (symbol_byte_size > 0 )
4505
+ sym[sym_idx].SetByteSize (symbol_byte_size);
4506
+
4462
4507
if (demangled_is_synthesized)
4463
4508
sym[sym_idx].SetDemangledNameIsSynthesized (true );
4464
4509
@@ -4577,7 +4622,23 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
4577
4622
Address symbol_addr;
4578
4623
if (module_sp->ResolveFileAddress (symbol_file_addr, symbol_addr)) {
4579
4624
SectionSP symbol_section (symbol_addr.GetSection ());
4625
+ uint32_t symbol_byte_size = 0 ;
4580
4626
if (symbol_section) {
4627
+ const addr_t section_file_addr = symbol_section->GetFileAddress ();
4628
+ const FunctionStarts::Entry *next_func_start_entry =
4629
+ function_starts.FindNextEntry (func_start_entry);
4630
+ const addr_t section_end_file_addr =
4631
+ section_file_addr + symbol_section->GetByteSize ();
4632
+ if (next_func_start_entry) {
4633
+ addr_t next_symbol_file_addr = next_func_start_entry->addr ;
4634
+ if (is_arm)
4635
+ next_symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
4636
+ symbol_byte_size = std::min<lldb::addr_t >(
4637
+ next_symbol_file_addr - symbol_file_addr,
4638
+ section_end_file_addr - symbol_file_addr);
4639
+ } else {
4640
+ symbol_byte_size = section_end_file_addr - symbol_file_addr;
4641
+ }
4581
4642
sym[sym_idx].SetID (synthetic_sym_id++);
4582
4643
// Don't set the name for any synthetic symbols, the Symbol
4583
4644
// object will generate one if needed when the name is accessed
@@ -4589,6 +4650,8 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
4589
4650
add_symbol_addr (symbol_addr.GetFileAddress ());
4590
4651
if (symbol_flags)
4591
4652
sym[sym_idx].SetFlags (symbol_flags);
4653
+ if (symbol_byte_size)
4654
+ sym[sym_idx].SetByteSize (symbol_byte_size);
4592
4655
++sym_idx;
4593
4656
}
4594
4657
}
0 commit comments