[PATCH] D47373: [ELF] - Also use DW_AT_linkage_name when gathering information about variables for error messages.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 25 06:50:13 PDT 2018


grimar created this revision.
grimar added a reviewer: ruiu.
Herald added subscribers: JDevlieghere, arichardson, aprantl, emaste.
Herald added a reviewer: espindola.

Currently, when LLD do a lookup for variables location, it uses `DW_AT_name` attribute.
That is not always enough.

Imagine code:

  namespace A {
    int bar = 0;
  }
  
  namespace Z {
    int bar = 1;
  }
  
  int hoho;

In this case there are 3 variables and their debug attributes are following:

1. `A::bar` has: `DW_AT_name [DW_FORM_string] ("bar")` `DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00000006] = "_ZN1A3barE")`

2. `Z::bar` has: `DW_AT_name [DW_FORM_string] ("bar")` `DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x0000003f] = "_ZN1Z3barE")`

3. hoho has: `DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000004a] = "hoho")` and has `NO DW_AT_linkage_name` attribute. Because it would be the same as `DW_AT_name` and DWARF producers avoids emiting excessive data.

Hence LLD should also use DW_AT_linkage_name when it is available.
(currently, LLD fails to report location correctly because thinks that `A::bar` and `Z::bar` are the same things)


https://reviews.llvm.org/D47373

Files:
  ELF/InputFiles.cpp
  test/ELF/conflict-variable-linkage-name.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47373.148601.patch
Type: text/x-patch
Size: 9170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180525/e11cda34/attachment.bin>


More information about the llvm-commits mailing list