[all-commits] [llvm/llvm-project] f2036a: [ELF] Print symbols with non-default versions for ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Apr 1 08:08:33 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f2036a15d3714fc9cfc8935634814d1c4e4263fa
      https://github.com/llvm/llvm-project/commit/f2036a15d3714fc9cfc8935634814d1c4e4263fa
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-04-01 (Wed, 01 Apr 2020)

  Changed paths:
    M lld/ELF/Symbols.cpp
    M lld/ELF/Symbols.h
    A lld/test/ELF/undef-suggest-version.s

  Log Message:
  -----------
  [ELF] Print symbols with non-default versions for better "undefined symbol" diagnostics

When reporting an "undefined symbol" diagnostic:

* We don't print @ for the reference.
* We don't print @ or @@ for the definition. https://bugs.llvm.org/show_bug.cgi?id=45318

This can lead to confusing diagnostics:

```
// foo may be foo at v2
ld.lld: error: undefined symbol: foo
>>> referenced by t1.o:(.text+0x1)
// foo may be foo at v1 or foo@@v1
>>> did you mean: foo
>>> defined in: t.so
```

There are 2 ways a symbol in symtab may get truncated:

* A @@ definition may be truncated *early* by SymbolTable::insert().
  The name ends with a '\0'.
* A @ definition/reference may be truncated *later* by Symbol::parseSymbolVersion().
  The name ends with a '@'.

This patch detects the second case and improves the diagnostics. The first case is
not improved but the second case is sufficient to make diagnostics not confusing.

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D76999




More information about the All-commits mailing list