forked from OSchip/llvm-project
				
			Ignore mapping symbols on aarch64
ELF symbol tables on aarch64 may contains some mapping symbols. They provide information about the underlying data but interfere with symbol look-up of lldb. They are already ignored on arm32. With this CL they will be ignored on aarch64 also. Differential revision: http://reviews.llvm.org/D8776 llvm-svn: 234307
This commit is contained in:
		
							parent
							
								
									303c3ac925
								
							
						
					
					
						commit
						83544cf660
					
				| 
						 | 
					@ -895,25 +895,18 @@ ObjectFileELF::GetAddressClass (addr_t file_addr)
 | 
				
			||||||
    if (res != eAddressClassCode)
 | 
					    if (res != eAddressClassCode)
 | 
				
			||||||
        return res;
 | 
					        return res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ArchSpec arch_spec;
 | 
					    auto ub = m_address_class_map.upper_bound(file_addr);
 | 
				
			||||||
    GetArchitecture(arch_spec);
 | 
					    if (ub == m_address_class_map.begin())
 | 
				
			||||||
    if (arch_spec.GetMachine() != llvm::Triple::arm)
 | 
					    {
 | 
				
			||||||
        return res;
 | 
					        // No entry in the address class map before the address. Return
 | 
				
			||||||
 | 
					        // default address class for an address in a code section.
 | 
				
			||||||
 | 
					        return eAddressClassCode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    auto symtab = GetSymtab();
 | 
					    // Move iterator to the address class entry preceding address
 | 
				
			||||||
    if (symtab == nullptr)
 | 
					    --ub;
 | 
				
			||||||
        return res;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    auto symbol = symtab->FindSymbolContainingFileAddress(file_addr);
 | 
					    return ub->second;
 | 
				
			||||||
    if (symbol == nullptr)
 | 
					 | 
				
			||||||
        return res;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Thumb symbols have the lower bit set in the flags field so we just check
 | 
					 | 
				
			||||||
    // for that.
 | 
					 | 
				
			||||||
    if (symbol->GetFlags() & ARM_ELF_SYM_IS_THUMB)
 | 
					 | 
				
			||||||
        res = eAddressClassCodeAlternateISA;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return res;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t
 | 
					size_t
 | 
				
			||||||
| 
						 | 
					@ -1872,33 +1865,66 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ArchSpec arch;
 | 
					 | 
				
			||||||
        int64_t symbol_value_offset = 0;
 | 
					        int64_t symbol_value_offset = 0;
 | 
				
			||||||
        uint32_t additional_flags = 0;
 | 
					        uint32_t additional_flags = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (GetArchitecture(arch) &&
 | 
					        ArchSpec arch;
 | 
				
			||||||
            arch.GetMachine() == llvm::Triple::arm)
 | 
					        if (GetArchitecture(arch))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // ELF symbol tables may contain some mapping symbols. They provide
 | 
					            if (arch.GetMachine() == llvm::Triple::arm)
 | 
				
			||||||
            // information about the underlying data. There are three of them
 | 
					            {
 | 
				
			||||||
            // currently defined:
 | 
					                if (symbol.getBinding() == STB_LOCAL && symbol_name && symbol_name[0] == '$')
 | 
				
			||||||
            //   $a[.<any>]* - marks an ARM instruction sequence
 | 
					                {
 | 
				
			||||||
            //   $t[.<any>]* - marks a THUMB instruction sequence
 | 
					                    // These are reserved for the specification (e.g.: mapping
 | 
				
			||||||
            //   $d[.<any>]* - marks a data item sequence (e.g. lit pool)
 | 
					                    // symbols). We don't want to add them to the symbol table.
 | 
				
			||||||
            // These symbols interfere with normal debugger operations and we
 | 
					 | 
				
			||||||
            // don't need them. We can drop them here.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            static const llvm::StringRef g_armelf_arm_marker("$a");
 | 
					 | 
				
			||||||
            static const llvm::StringRef g_armelf_thumb_marker("$t");
 | 
					 | 
				
			||||||
            static const llvm::StringRef g_armelf_data_marker("$d");
 | 
					 | 
				
			||||||
                    llvm::StringRef symbol_name_ref(symbol_name);
 | 
					                    llvm::StringRef symbol_name_ref(symbol_name);
 | 
				
			||||||
 | 
					                    if (symbol_name_ref == "$a" || symbol_name_ref.startswith("$a."))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // $a[.<any>]* - marks an ARM instruction sequence
 | 
				
			||||||
 | 
					                        m_address_class_map[symbol.st_value] = eAddressClassCode;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (symbol_name_ref == "$b" || symbol_name_ref.startswith("$b.") ||
 | 
				
			||||||
 | 
					                             symbol_name_ref == "$t" || symbol_name_ref.startswith("$t."))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // $b[.<any>]* - marks a THUMB BL instruction sequence
 | 
				
			||||||
 | 
					                        // $t[.<any>]* - marks a THUMB instruction sequence
 | 
				
			||||||
 | 
					                        m_address_class_map[symbol.st_value] = eAddressClassCodeAlternateISA;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (symbol_name_ref == "$d" || symbol_name_ref.startswith("$d."))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // $d[.<any>]* - marks a data item sequence (e.g. lit pool)
 | 
				
			||||||
 | 
					                        m_address_class_map[symbol.st_value] = eAddressClassData;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (symbol_name &&
 | 
					 | 
				
			||||||
                (symbol_name_ref.startswith(g_armelf_arm_marker) ||
 | 
					 | 
				
			||||||
                 symbol_name_ref.startswith(g_armelf_thumb_marker) ||
 | 
					 | 
				
			||||||
                 symbol_name_ref.startswith(g_armelf_data_marker)))
 | 
					 | 
				
			||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (arch.GetMachine() == llvm::Triple::aarch64)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (symbol.getBinding() == STB_LOCAL && symbol_name && symbol_name[0] == '$')
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // These are reserved for the specification (e.g.: mapping
 | 
				
			||||||
 | 
					                    // symbols). We don't want to add them to the symbol table.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    llvm::StringRef symbol_name_ref(symbol_name);
 | 
				
			||||||
 | 
					                    if (symbol_name_ref == "$x" || symbol_name_ref.startswith("$x."))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // $x[.<any>]* - marks an A64 instruction sequence
 | 
				
			||||||
 | 
					                        m_address_class_map[symbol.st_value] = eAddressClassCode;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (symbol_name_ref == "$d" || symbol_name_ref.startswith("$d."))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // $d[.<any>]* - marks a data item sequence (e.g. lit pool)
 | 
				
			||||||
 | 
					                        m_address_class_map[symbol.st_value] = eAddressClassData;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (arch.GetMachine() == llvm::Triple::arm)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
                // THUMB functions have the lower bit of their address set. Fixup
 | 
					                // THUMB functions have the lower bit of their address set. Fixup
 | 
				
			||||||
                // the actual address and mark the symbol as THUMB.
 | 
					                // the actual address and mark the symbol as THUMB.
 | 
				
			||||||
                if (symbol_type == eSymbolTypeCode && symbol.st_value & 1)
 | 
					                if (symbol_type == eSymbolTypeCode && symbol.st_value & 1)
 | 
				
			||||||
| 
						 | 
					@ -1913,6 +1939,7 @@ ObjectFileELF::ParseSymbols (Symtab *symtab,
 | 
				
			||||||
                    additional_flags = ARM_ELF_SYM_IS_THUMB;
 | 
					                    additional_flags = ARM_ELF_SYM_IS_THUMB;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // If the symbol section we've found has no data (SHT_NOBITS), then check the module section
 | 
					        // If the symbol section we've found has no data (SHT_NOBITS), then check the module section
 | 
				
			||||||
        // list. This can happen if we're parsing the debug file and it has no .text section, for example.
 | 
					        // list. This can happen if we're parsing the debug file and it has no .text section, for example.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -219,6 +219,8 @@ private:
 | 
				
			||||||
    typedef DynamicSymbolColl::iterator         DynamicSymbolCollIter;
 | 
					    typedef DynamicSymbolColl::iterator         DynamicSymbolCollIter;
 | 
				
			||||||
    typedef DynamicSymbolColl::const_iterator   DynamicSymbolCollConstIter;
 | 
					    typedef DynamicSymbolColl::const_iterator   DynamicSymbolCollConstIter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    typedef std::map<lldb::addr_t, lldb::AddressClass> FileAddressToAddressClassMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Version of this reader common to all plugins based on this class.
 | 
					    /// Version of this reader common to all plugins based on this class.
 | 
				
			||||||
    static const uint32_t m_plugin_version = 1;
 | 
					    static const uint32_t m_plugin_version = 1;
 | 
				
			||||||
    static const uint32_t g_core_uuid_magic;
 | 
					    static const uint32_t g_core_uuid_magic;
 | 
				
			||||||
| 
						 | 
					@ -252,6 +254,9 @@ private:
 | 
				
			||||||
    /// The architecture detected from parsing elf file contents.
 | 
					    /// The architecture detected from parsing elf file contents.
 | 
				
			||||||
    lldb_private::ArchSpec m_arch_spec;
 | 
					    lldb_private::ArchSpec m_arch_spec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// The address class for each symbol in the elf file
 | 
				
			||||||
 | 
					    FileAddressToAddressClassMap m_address_class_map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Returns a 1 based index of the given section header.
 | 
					    /// Returns a 1 based index of the given section header.
 | 
				
			||||||
    size_t
 | 
					    size_t
 | 
				
			||||||
    SectionIndex(const SectionHeaderCollIter &I);
 | 
					    SectionIndex(const SectionHeaderCollIter &I);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue