[Lldb-commits] SBTarget::SetModuleLoadAddress() patch

Dmitry Vyukov dvyukov at google.com
Mon Mar 26 02:21:07 PDT 2012


ping

On Tue, Feb 28, 2012 at 1:57 PM, Dmitry Vyukov <dvyukov at google.com> wrote:

> Hi,
>
> I would like to ask you to review and land the following patch.
> It improves SBTarget::SetModuleLoadAddress() (at least for Linux) by
> skipping sections that are not actually mapped. I had to hack around .tbss
> section, because it has weird elf representation on Linux (from everything
> you see in the elf itself it is mapped, but it is actually not).
>
>
> Index: include/lldb/lldb-enumerations.h
> ===================================================================
> --- include/lldb/lldb-enumerations.h (revision 151625)
> +++ include/lldb/lldb-enumerations.h (working copy)
> @@ -467,6 +467,7 @@
>          eSectionTypeCode,
>          eSectionTypeContainer,              // The section contains child
> sections
>          eSectionTypeData,
> +        eSectionTypeThreadData,             // Thread-local data
>          eSectionTypeDataCString,            // Inlined C string data
>          eSectionTypeDataCStringPointers,    // Pointers to C string data
>          eSectionTypeDataSymbolAddress,      // Address of a symbol in the
> symbol table
> @@ -476,6 +477,7 @@
>          eSectionTypeDataPointers,
>          eSectionTypeDebug,
>          eSectionTypeZeroFill,
> +        eSectionTypeThreadZeroFill,         // Thread-local zero data
>          eSectionTypeDataObjCMessageRefs,    // Pointer to function
> pointer + selector
>          eSectionTypeDataObjCCFStrings,      // Objective C const
> CFString/NSString objects
>          eSectionTypeDWARFDebugAbbrev,
> Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
> ===================================================================
> --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (revision 151625)
> +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (working copy)
> @@ -620,6 +620,8 @@
>              static ConstString g_sect_name_text (".text");
>              static ConstString g_sect_name_data (".data");
>              static ConstString g_sect_name_bss (".bss");
> +            static ConstString g_sect_name_tdata (".tdata");
> +            static ConstString g_sect_name_tbss (".tbss");
>              static ConstString g_sect_name_dwarf_debug_abbrev
> (".debug_abbrev");
>              static ConstString g_sect_name_dwarf_debug_aranges
> (".debug_aranges");
>              static ConstString g_sect_name_dwarf_debug_frame
> (".debug_frame");
> @@ -638,6 +640,8 @@
>              if      (name == g_sect_name_text)                  sect_type
> = eSectionTypeCode;
>              else if (name == g_sect_name_data)                  sect_type
> = eSectionTypeData;
>              else if (name == g_sect_name_bss)                   sect_type
> = eSectionTypeZeroFill;
> +            else if (name == g_sect_name_tdata)                 sect_type
> = eSectionTypeThreadData;
> +            else if (name == g_sect_name_tbss)                  sect_type
> = eSectionTypeThreadZeroFill;
>              else if (name == g_sect_name_dwarf_debug_abbrev)    sect_type
> = eSectionTypeDWARFDebugAbbrev;
>              else if (name == g_sect_name_dwarf_debug_aranges)   sect_type
> = eSectionTypeDWARFDebugAranges;
>              else if (name == g_sect_name_dwarf_debug_frame)     sect_type
> = eSectionTypeDWARFDebugFrame;
> Index: source/API/SBTarget.cpp
> ===================================================================
> --- source/API/SBTarget.cpp (revision 151625)
> +++ source/API/SBTarget.cpp (working copy)
> @@ -2010,7 +2010,19 @@
>                      {
>                          SectionSP section_sp
> (section_list->GetSectionAtIndex(sect_idx));
>                          if (section_sp)
> +                        {
> +                            // These are not actually mapped.
> +                            if (section_sp->GetFileAddress() == 0)
> +                                continue;
> +                            // Skip .tbss
> +                            // On Linux I observe that .tbss has some
> real virtual address
> +                            // and ALLOC flag, but the next section
> starts at the same address.
> +                            // It suggests that .tbss is not actually
> mapped
> +                            // (even if it is mapped, it should be
> uninteresting for us).
> +                            if (section_sp->GetType() ==
> eSectionTypeThreadZeroFill)
> +                                continue;
>
>  target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp.get(),
> section_sp->GetFileAddress() + slide_offset);
> +                        }
>                      }
>                  }
>                  else
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20120326/1f9d9c07/attachment.html>


More information about the lldb-commits mailing list