[all-commits] [llvm/llvm-project] 7e69b1: [ELF][test] Improve .symver & --version-script tests

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Aug 4 09:19:15 PDT 2021


  Branch: refs/heads/release/13.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 7e69b1728c2317610d3e9d82d52ca7ad38adb034
      https://github.com/llvm/llvm-project/commit/7e69b1728c2317610d3e9d82d52ca7ad38adb034
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-08-04 (Wed, 04 Aug 2021)

  Changed paths:
    M lld/test/ELF/partition-synthetic-sections.s
    R lld/test/ELF/undef-version-script.s
    M lld/test/ELF/verneed.s
    R lld/test/ELF/version-script-glob.s
    R lld/test/ELF/version-script-hide-so-symbol.s
    R lld/test/ELF/version-script-locals.s
    M lld/test/ELF/version-script-symver.s
    R lld/test/ELF/version-script-twice.s
    A lld/test/ELF/version-script-undef.s
    M lld/test/ELF/version-symbol-undef.s

  Log Message:
  -----------
  [ELF][test] Improve .symver & --version-script tests

And delete redundant tests.


  Commit: 17edcb3a6e131b84b8dc253fa950eec16dc47cc7
      https://github.com/llvm/llvm-project/commit/17edcb3a6e131b84b8dc253fa950eec16dc47cc7
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-08-04 (Wed, 04 Aug 2021)

  Changed paths:
    M lld/ELF/Config.h
    M lld/ELF/Driver.cpp
    M lld/ELF/ScriptParser.cpp
    M lld/ELF/SymbolTable.cpp
    M lld/ELF/SymbolTable.h
    M lld/ELF/Symbols.cpp
    R lld/test/ELF/version-script-extern-exact.s
    R lld/test/ELF/version-script-extern-wildcards.s
    R lld/test/ELF/version-script-extern.s
    M lld/test/ELF/version-script-noundef.s
    A lld/test/ELF/version-script-symver-extern.s
    M lld/test/ELF/version-script-symver.s

  Log Message:
  -----------
  [ELF] Apply version script patterns to non-default version symbols

Currently version script patterns are ignored for .symver produced
non-default version (single @) symbols. This makes such symbols
not localizable by `local:`, e.g.

```
.symver foo3_v1,foo3 at v1
.globl foo_v1
foo3_v1:

ld.lld --version-script=a.ver -shared a.o
# In a.out, foo3 at v1 is incorrectly exported.
```

This patch adds the support:

* Move `config->versionDefinitions[VER_NDX_LOCAL].patterns` to `config->versionDefinitions[versionId].localPatterns`
* Rename `config->versionDefinitions[versionId].patterns` to `config->versionDefinitions[versionId].nonLocalPatterns`
* Allow `findAllByVersion` to find non-default version symbols when `includeNonDefault` is true. (Note: `symtab` keys do not have `@@`)
* Make each pattern check both the unversioned `pat.name` and the versioned `${pat.name}@${v.name}`
* `localPatterns` can localize `${pat.name}@${v.name}`. `nonLocalPatterns` can prevent localization by assigning `verdefIndex` (before `parseSymbolVersion`).

---

If a user notices new `undefined symbol` errors with a version script containing
`local: *;`, the issue is likely due to a missing `global:` pattern.

Reviewed By: peter.smith

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


  Commit: 4783a6cdf0a9087212f517ce20e0e3a9cf39d6a4
      https://github.com/llvm/llvm-project/commit/4783a6cdf0a9087212f517ce20e0e3a9cf39d6a4
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-08-04 (Wed, 04 Aug 2021)

  Changed paths:
    M lld/ELF/Driver.cpp
    A lld/test/ELF/symver-non-default.s
    M lld/test/ELF/version-script-symver.s
    M lld/test/ELF/version-symbol-undef.s

  Log Message:
  -----------
  [ELF] Combine foo at v1 and foo with the same versionId if both are defined

Due to an assembler design flaw (IMO), `.symver foo,foo at v1` produces two symbols `foo` and `foo at v1` if `foo` is defined.

* `v1 {};` produces both `foo` and `foo at v1`, but GNU ld only produces `foo at v1`
* `v1 { foo; };` produces both `foo@@v1` and `foo at v1`, but GNU ld only produces `foo at v1`
* `v2 { foo; };` produces both `foo@@v2` and `foo at v1`, matching GNU ld. (Tested by symver.s)

This patch implements the GNU ld behavior by reusing the symbol redirection mechanism
in D92259. The new test symver-non-default.s checks the first two cases.

Without the patch, the second case will produce `foo at v1` and `foo@@v1` which
looks weird and makes foo unnecessarily default versioned.

Note: `.symver foo,foo at v1,remove` exists but the unfortunate `foo` will not go
away anytime soon.

Reviewed By: peter.smith

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


Compare: https://github.com/llvm/llvm-project/compare/73ea8254d2d7...4783a6cdf0a9


More information about the All-commits mailing list