[all-commits] [llvm/llvm-project] 7bee6e: [ELF] Handle -u before input files

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Jun 5 08:44:59 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 7bee6e30fe634624a99b43615261f4b5311e7dd1
      https://github.com/llvm/llvm-project/commit/7bee6e30fe634624a99b43615261f4b5311e7dd1
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-06-05 (Fri, 05 Jun 2020)

  Changed paths:
    M lld/ELF/Driver.cpp
    M lld/test/ELF/undefined-opt.s

  Log Message:
  -----------
  [ELF] Handle -u before input files

If both a.a and b.so define foo

```
ld.bfd -u foo a.a b.so  # foo is defined
ld.bfd a.a b.so -u foo  # foo is defined
ld.bfd -u foo b.so a.a  # foo is undefined (provided at runtime by b.so)
ld.bfd b.so a.a -u foo  # foo is undefined (provided at runtime by b.so)
```

In all cases we make foo undefined in the output.  I tend to think the
GNU ld behavior makes more sense.

* In their model, they have to treat -u as a fake object file with an
  undefined symbol before all input files, otherwise the first archive would not be fetched.
* Following their behavior allows us to drop a --warn-backrefs special case.

Reviewed By: psmith

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




More information about the All-commits mailing list