So I would like to see this patch improved before we just remove all these 
symbols.

For 32 bit ARM, all of the magic $a $t $d symbols used to be preceded by a $m 
symbol and that symbol says how many $a/$t/$d symbols follow the $m symbol. So 
the question is: does this same thing exist for arm32 and also arm64? If so we 
should just modify this patch to skip $m symbols ahead. If not, we are not 
skipping all symbols correctly. From the ARM ELF specification we see:

  $a labels the first byte of a sequence of ARM instructions. Its type is 
STT_FUNC.
  $b labels a Thumb BL instruction. Its type is STT_FUNC.
  $d labels the first byte of a sequence of data items. Its type is STT_OBJECT.
  $f labels a function pointer constant (static pointer to code). Its type is 
STT_OBJECT.
  $p labels the final, PC-modifying instruction of an indirect function call. 
Its type is STT_FUNC.
  (An indirect call is a call through a function pointer variable). $p does not 
label the PC-modifying instruction of a function return sequence.
  $t labels the first byte of a sequence of Thumb instructions. Its type is 
STT_FUNC.

You should consult the aarch64 ELF specification and make sure we aren't 
missing any and also see if there is a $m symbol that can help us skip the 
symbols.

The next thing I would like to see fixed is we need to parse these symbols and 
make an AddressClass map for the ELF file so we can use this map in the 
following function:

  AddressClass
  ObjectFileELF::GetAddressClass (addr_t file_addr)

This currently implementation is a bit weak:

  AddressClass
  ObjectFileELF::GetAddressClass (addr_t file_addr)
  {
      auto res = ObjectFile::GetAddressClass (file_addr);
  
      if (res != eAddressClassCode)
          return res;
  
      ArchSpec arch_spec;
      GetArchitecture(arch_spec);
      if (arch_spec.GetMachine() != llvm::Triple::arm)
          return res;
  
      auto symtab = GetSymtab();
      if (symtab == nullptr)
          return res;
  
      auto symbol = symtab->FindSymbolContainingFileAddress(file_addr);
      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;
  }

This should really be changed to use the AddressClass map that we create when 
parsing the symbol table when we run into these magic $ variables. We should 
not be adding these $ symbols to the symbol table, but we should be using them 
to create a AddressClass map. Something like:

ObjectFileELF.h:

  typedef std::map<lldb::addr_t, AddressClass> FileAddressToAddressClassMap;
  FileAddressToAddressClassMap m_address_class_map;

Then in the symbol table parsing code when we detect one of the magic $ 
variables, we should parse the symbols and help create the map:

  if (arch == arm)
  {
      if (name == "$a")
          m_address_class_map[symbol.st_value] = eAddressClassCode;
      else if (name == "$t" || name == "$b")
          m_address_class_map[symbol.st_value] = eAddressClassCodeAlternateISA;
      else if (name == "$d")
          m_address_class_map[symbol.st_value] = eAddressClassData;
  }
  else if (arch == aarch64 || arch == arm64)
  {
      ....
  }

Then we should use this m_address_class_map inside 
ObjectFileELF::GetAddressClass().


http://reviews.llvm.org/D8776

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/



_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to