[llvm] r246406 - [dsymutil] Fix handling of inlined_subprogram low_pcs

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 09:05:27 PDT 2015


On Sun, Aug 30, 2015 at 6:43 PM, Frederic Riss via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: friss
> Date: Sun Aug 30 20:43:14 2015
> New Revision: 246406
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246406&view=rev
> Log:
> [dsymutil] Fix handling of inlined_subprogram low_pcs
>
> The value of an inlined subprogram low_pc attribute should not
> get relocated, but it can happen that it matches the enclosing
> function's start address and thus gets the generic treatment.
> Special case it to avoid applying the PC offset twice.
>

I'm a tad confused - do you store the low_pcs as offsets relative to the
function


>
> Added:
>     llvm/trunk/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map
>     llvm/trunk/test/tools/dsymutil/ARM/inlined-low_pc.c
>     llvm/trunk/test/tools/dsymutil/Inputs/inlined-low_pc/
>     llvm/trunk/test/tools/dsymutil/Inputs/inlined-low_pc/1.o
> Modified:
>     llvm/trunk/test/tools/dsymutil/ARM/lit.local.cfg
>     llvm/trunk/tools/dsymutil/DwarfLinker.cpp
>
> Added: llvm/trunk/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map?rev=246406&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map (added)
> +++ llvm/trunk/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map Sun Aug
> 30 20:43:14 2015
> @@ -0,0 +1,15 @@
> +# This is a dummy debug map used for some tests where the contents of the
> +# map are just an implementation detail. The tests wanting to use that
> file
> +# should put all there object files in an explicitely named sub-directory
> +# of Inputs, and they should be named 1.o, 2.o, ...
> +# As not finding an object file or symbols isn't a fatal error for
> dsymutil,
> +# you can extend this file with as much object files and symbols as
> needed.
> +
> +---
> +triple:          'arm64-apple-darwin'
> +objects:
> +  - filename: 1.o
> +    symbols:
> +      - { sym: _bar, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }
> +...
> +
>
> Added: llvm/trunk/test/tools/dsymutil/ARM/inlined-low_pc.c
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/ARM/inlined-low_pc.c?rev=246406&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/tools/dsymutil/ARM/inlined-low_pc.c (added)
> +++ llvm/trunk/test/tools/dsymutil/ARM/inlined-low_pc.c Sun Aug 30
> 20:43:14 2015
> @@ -0,0 +1,15 @@
> +/* Compiled with: clang -arch=arm64 -O2 -g -c inlined_low_pc.c */
> +
> +static int foo(int i) { return 42 + i; }
> +int bar(int a) { return foo(a); }
> +
> +// RUN: llvm-dsymutil -f -y %p/dummy-debug-map-amr64.map
> -oso-prepend-path %p/../Inputs/inlined-low_pc -o - | llvm-dwarfdump - |
> FileCheck %s
> +
> +// CHECK: DW_TAG_subprogram
> +// CHECK: DW_AT_low_pc{{.*}}0x0000000000010000
> +// CHECK: DW_AT_name{{.*}}"bar"
> +// CHECK-NOT: NULL
> +// CHECK: DW_TAG_inlined_subroutine
> +// CHECK-NEXT: DW_AT_abstract_origin{{.*}}"foo"
> +// CHECK-NEXT: DW_AT_low_pc{{.*}}0x0000000000010000
> +
>
> Modified: llvm/trunk/test/tools/dsymutil/ARM/lit.local.cfg
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/ARM/lit.local.cfg?rev=246406&r1=246405&r2=246406&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/tools/dsymutil/ARM/lit.local.cfg (original)
> +++ llvm/trunk/test/tools/dsymutil/ARM/lit.local.cfg Sun Aug 30 20:43:14
> 2015
> @@ -2,3 +2,6 @@ if not 'ARM' in config.root.targets:
>      config.unsupported = True
>  if not 'AArch64' in config.root.targets:
>      config.unsupported = True
> +
> +config.suffixes = ['.test', '.cpp', '.c']
> +
>
> Added: llvm/trunk/test/tools/dsymutil/Inputs/inlined-low_pc/1.o
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/inlined-low_pc/1.o?rev=246406&view=auto
>
> ==============================================================================
> Binary files llvm/trunk/test/tools/dsymutil/Inputs/inlined-low_pc/1.o
> (added) and llvm/trunk/test/tools/dsymutil/Inputs/inlined-low_pc/1.o Sun
> Aug 30 20:43:14 2015 differ
>
> Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=246406&r1=246405&r2=246406&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
> +++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Sun Aug 30 20:43:14 2015
> @@ -1206,6 +1206,7 @@ private:
>      const char *Name, *MangledName;         ///< Names.
>      uint32_t NameOffset, MangledNameOffset; ///< Offsets in the string
> pool.
>
> +    uint64_t OrigLowPc;  ///< Value of AT_low_pc in the input DIE
>      uint64_t OrigHighPc; ///< Value of AT_high_pc in the input DIE
>      int64_t PCOffset;    ///< Offset to apply to PC addresses inside a
> function.
>
> @@ -1214,8 +1215,8 @@ private:
>
>      AttributesInfo()
>          : Name(nullptr), MangledName(nullptr), NameOffset(0),
> -          MangledNameOffset(0), OrigHighPc(0), PCOffset(0),
> HasLowPc(false),
> -          IsDeclaration(false) {}
> +          MangledNameOffset(0), OrigLowPc(UINT64_MAX), OrigHighPc(0),
> +          PCOffset(0), HasLowPc(false), IsDeclaration(false) {}
>    };
>
>    /// \brief Helper for cloneDIE.
> @@ -2274,7 +2275,12 @@ unsigned DwarfLinker::cloneAddressAttrib
>    if (AttrSpec.Attr == dwarf::DW_AT_low_pc) {
>      if (Die.getTag() == dwarf::DW_TAG_inlined_subroutine ||
>          Die.getTag() == dwarf::DW_TAG_lexical_block)
> -      Addr += Info.PCOffset;
> +      // The low_pc of a block or inline subroutine might get
> +      // relocated because it happens to match the low_pc of the
> +      // enclosing subprogram. To prevent issues with that, always use
> +      // the low_pc from the input DIE if relocations have been applied.
> +      Addr = (Info.OrigLowPc != UINT64_MAX ? Info.OrigLowPc : Addr) +
> +             Info.PCOffset;
>      else if (Die.getTag() == dwarf::DW_TAG_compile_unit) {
>        Addr = Unit.getLowPc();
>        if (Addr == UINT64_MAX)
> @@ -2522,6 +2528,11 @@ DIE *DwarfLinker::cloneDIE(const DWARFDe
>      // high_pc value is done in cloneAddressAttribute().
>      AttrInfo.OrigHighPc =
>          InputDIE.getAttributeValueAsAddress(&U, dwarf::DW_AT_high_pc, 0);
> +    // Also store the low_pc. It might get relocated in an
> +    // inline_subprogram that happens at the beginning of its
> +    // inlining function.
> +    AttrInfo.OrigLowPc =
> +        InputDIE.getAttributeValueAsAddress(&U, dwarf::DW_AT_low_pc,
> UINT64_MAX);
>    }
>
>    // Reset the Offset to 0 as we will be working on the local copy of
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150831/cebc1a47/attachment-0001.html>


More information about the llvm-commits mailing list