[PATCH] D38721: [ELF] - Teach LLD to report line numbers for data symbols.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 09:01:15 PDT 2017


On Wed, Oct 11, 2017 at 3:27 AM George Rimar via Phabricator <
reviews at reviews.llvm.org> wrote:

> grimar added inline comments.
>
>
> ================
> Comment at: test/ELF/Inputs/conflict-debug-variable.s:1
> +# Used reduced output from following code and gcc 7.1.0
> +# to produce this input file:
> ----------------
> ruiu wrote:
> > I don't think we want to have this machine-generated assembly in the
> test directory. It is hard to verify/edit. Can you do this with llvm-as?
> Problem to do that is next. There is a difference in debug information
> produced by gcc and clang.
>
> clang encodes variables names using `DW_FORM_strp` (represents an offset
> in `.debug_str`):
>
> ```
> 0x0000001e:   DW_TAG_variable [2]
>                 DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000048] =
> "foo")
>                 DW_AT_type [DW_FORM_ref4]       (cu + 0x0033 =>
> {0x00000033})
>                 DW_AT_external [DW_FORM_flag_present]   (true)
>                 DW_AT_decl_file [DW_FORM_data1]
> ("/home/umb/tests/566_duplicatesym/1.c")
>                 DW_AT_decl_line [DW_FORM_data1] (1)
>                 DW_AT_location [DW_FORM_exprloc]        (DW_OP_addr 0x0)
> ```
>
> gcc places string in place using DW_FORM_string:
> ```
> 0x0000001d:   DW_TAG_variable [2]
>                  DW_AT_name [DW_FORM_string]    ("foo")
>                  DW_AT_decl_file [DW_FORM_data1]
> ("/home/umb/tests/566_duplicatesym/1.c")
>                  DW_AT_decl_line [DW_FORM_data1]        (1)
>                  DW_AT_type [DW_FORM_ref4]      (cu + 0x0032 =>
> {0x00000032})
>                 DW_AT_external [DW_FORM_flag_present]   (true)
>                  DW_AT_location [DW_FORM_exprloc]       (DW_OP_addr 0x0)
> ```
>
> We want to support both ways, and this patch supports only first one,
> because our `LLDDwarfObj`
> does not provide `.debug_str` section for DWARF parsers yet.
>
> I tried to use llvm-as + llc and found no way to make output to use gcc
> way (`DW_FORM_string` for name attribute).
> (used clang -S -emit-llvm -g to produce IR). I am not sure is it possible
> ? Seems - not.
> I think clang has no flags to drop use of `.debug_str`.
>

Yep, llvm uses FORM_strp for everything & has no fallback/other
path/flag/etc to do otherwise.

GCC will likely also use FORM_strp for longer strings (once it's longer
than the size of the relocation it costs to indirect through debug_str).


>
> I am going to implement support for `DW_FORM_strp` (clang way) after this
> patch be landed, but we need testcases
> for both ways I believe. For following patch I can use llvm-as.
>
> I updated this testcase so it should be more readable. It also should be
> no need to edit it in future I think.
>
>
> https://reviews.llvm.org/D38721
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171011/ad7d082f/attachment.html>


More information about the llvm-commits mailing list