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

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 11:21:08 PDT 2017


ruiu 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:
----------------
grimar wrote:
> 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`.
> 
> 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.
I'm confused. You are saying that this patch supports only the first one (which is DW_FORM_strp and that's what clang generates), but you are also saying that you will implement a DW_FORM_strp support after this patch. Which is correct?


https://reviews.llvm.org/D38721





More information about the llvm-commits mailing list