Index: include/lldb/Symbol/ObjectFile.h =================================================================== --- include/lldb/Symbol/ObjectFile.h +++ include/lldb/Symbol/ObjectFile.h @@ -241,6 +241,9 @@ //------------------------------------------------------------------ virtual lldb::AddressClass GetAddressClass(lldb::addr_t file_addr); + static lldb::AddressClass + SectionTypeToAddressClass(const lldb::SectionType st); + //------------------------------------------------------------------ /// Extract the dependent modules from an object file. /// Index: include/lldb/lldb-enumerations.h =================================================================== --- include/lldb/lldb-enumerations.h +++ include/lldb/lldb-enumerations.h @@ -825,7 +825,8 @@ eAddressClassCodeAlternateISA, eAddressClassData, eAddressClassDebug, - eAddressClassRuntime + eAddressClassRuntime, + eAddressClassTypeAbsoluteAddress }; //---------------------------------------------------------------------- Index: source/Core/Address.cpp =================================================================== --- source/Core/Address.cpp +++ source/Core/Address.cpp @@ -990,6 +990,17 @@ } AddressClass Address::GetAddressClass() const { + // Get address class based on loaded Section type + SectionSP section_sp(GetSection()); + if (section_sp) { + const SectionType section_type = section_sp->GetType(); + AddressClass addr_class; + addr_class = ObjectFile::SectionTypeToAddressClass(section_type); + if (addr_class != eAddressClassTypeAbsoluteAddress) + return addr_class; + } + + // Get Address class based on file address ModuleSP module_sp(GetModule()); if (module_sp) { ObjectFile *obj_file = module_sp->GetObjectFile(); Index: source/Symbol/ObjectFile.cpp =================================================================== --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -315,6 +315,65 @@ return false; } +AddressClass ObjectFile::SectionTypeToAddressClass(const SectionType st) { + switch (st) { + case eSectionTypeInvalid: + return eAddressClassUnknown; + case eSectionTypeCode: + return eAddressClassCode; + case eSectionTypeContainer: + return eAddressClassUnknown; + case eSectionTypeData: + case eSectionTypeDataCString: + case eSectionTypeDataCStringPointers: + case eSectionTypeDataSymbolAddress: + case eSectionTypeData4: + case eSectionTypeData8: + case eSectionTypeData16: + case eSectionTypeDataPointers: + case eSectionTypeZeroFill: + case eSectionTypeDataObjCMessageRefs: + case eSectionTypeDataObjCCFStrings: + case eSectionTypeGoSymtab: + return eAddressClassData; + case eSectionTypeDebug: + case eSectionTypeDWARFDebugAbbrev: + case eSectionTypeDWARFDebugAddr: + case eSectionTypeDWARFDebugAranges: + case eSectionTypeDWARFDebugFrame: + case eSectionTypeDWARFDebugInfo: + case eSectionTypeDWARFDebugLine: + case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugMacInfo: + case eSectionTypeDWARFDebugMacro: + case eSectionTypeDWARFDebugPubNames: + case eSectionTypeDWARFDebugPubTypes: + case eSectionTypeDWARFDebugRanges: + case eSectionTypeDWARFDebugStr: + case eSectionTypeDWARFDebugStrOffsets: + case eSectionTypeDWARFAppleNames: + case eSectionTypeDWARFAppleTypes: + case eSectionTypeDWARFAppleNamespaces: + case eSectionTypeDWARFAppleObjC: + return eAddressClassDebug; + case eSectionTypeEHFrame: + case eSectionTypeARMexidx: + case eSectionTypeARMextab: + case eSectionTypeCompactUnwind: + return eAddressClassRuntime; + case eSectionTypeELFSymbolTable: + case eSectionTypeELFDynamicSymbols: + case eSectionTypeELFRelocationEntries: + case eSectionTypeELFDynamicLinkInfo: + case eSectionTypeOther: + return eAddressClassUnknown; + case eSectionTypeAbsoluteAddress: + return eAddressClassTypeAbsoluteAddress; + default: + return eAddressClassUnknown; + } +} + AddressClass ObjectFile::GetAddressClass(addr_t file_addr) { Symtab *symtab = GetSymtab(); if (symtab) { @@ -324,68 +383,15 @@ const SectionSP section_sp(symbol->GetAddressRef().GetSection()); if (section_sp) { const SectionType section_type = section_sp->GetType(); - switch (section_type) { - case eSectionTypeInvalid: - return eAddressClassUnknown; - case eSectionTypeCode: - return eAddressClassCode; - case eSectionTypeContainer: - return eAddressClassUnknown; - case eSectionTypeData: - case eSectionTypeDataCString: - case eSectionTypeDataCStringPointers: - case eSectionTypeDataSymbolAddress: - case eSectionTypeData4: - case eSectionTypeData8: - case eSectionTypeData16: - case eSectionTypeDataPointers: - case eSectionTypeZeroFill: - case eSectionTypeDataObjCMessageRefs: - case eSectionTypeDataObjCCFStrings: - case eSectionTypeGoSymtab: - return eAddressClassData; - case eSectionTypeDebug: - case eSectionTypeDWARFDebugAbbrev: - case eSectionTypeDWARFDebugAddr: - case eSectionTypeDWARFDebugAranges: - case eSectionTypeDWARFDebugFrame: - case eSectionTypeDWARFDebugInfo: - case eSectionTypeDWARFDebugLine: - case eSectionTypeDWARFDebugLoc: - case eSectionTypeDWARFDebugMacInfo: - case eSectionTypeDWARFDebugMacro: - case eSectionTypeDWARFDebugPubNames: - case eSectionTypeDWARFDebugPubTypes: - case eSectionTypeDWARFDebugRanges: - case eSectionTypeDWARFDebugStr: - case eSectionTypeDWARFDebugStrOffsets: - case eSectionTypeDWARFAppleNames: - case eSectionTypeDWARFAppleTypes: - case eSectionTypeDWARFAppleNamespaces: - case eSectionTypeDWARFAppleObjC: - return eAddressClassDebug; - case eSectionTypeEHFrame: - case eSectionTypeARMexidx: - case eSectionTypeARMextab: - case eSectionTypeCompactUnwind: - return eAddressClassRuntime; - case eSectionTypeELFSymbolTable: - case eSectionTypeELFDynamicSymbols: - case eSectionTypeELFRelocationEntries: - case eSectionTypeELFDynamicLinkInfo: - case eSectionTypeOther: - return eAddressClassUnknown; - case eSectionTypeAbsoluteAddress: - // In case of absolute sections decide the address class based on - // the symbol - // type because the section type isn't specify if it is a code or a - // data - // section. - break; - } + AddressClass addr_class; + addr_class = ObjectFile::SectionTypeToAddressClass(section_type); + // In case of absolute sections decide the address class based on + // the symbol type because the section type isn't specify + // if it is a code or a data section + if (addr_class != eAddressClassTypeAbsoluteAddress) + return addr_class; } } - const SymbolType symbol_type = symbol->GetType(); switch (symbol_type) { case eSymbolTypeAny: