[all-commits] [llvm/llvm-project] 803178: [ELF][test] Improve --wrap tests

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Jan 19 21:24:15 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8031785f4a7ebd027edb34c91cbcf48db53ef444
      https://github.com/llvm/llvm-project/commit/8031785f4a7ebd027edb34c91cbcf48db53ef444
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-01-19 (Tue, 19 Jan 2021)

  Changed paths:
    M lld/test/ELF/wrap-shlib-undefined.s

  Log Message:
  -----------
  [ELF][test] Improve --wrap tests


  Commit: f96ff3c0f8ebd941b3f6b345164c3d858b781484
      https://github.com/llvm/llvm-project/commit/f96ff3c0f8ebd941b3f6b345164c3d858b781484
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-01-19 (Tue, 19 Jan 2021)

  Changed paths:
    M lld/ELF/Driver.cpp
    M lld/ELF/Symbols.h
    M lld/test/ELF/wrap-shlib-undefined.s

  Log Message:
  -----------
  [ELF] --wrap: Produce a dynamic symbol for undefined __wrap_

```
// a.s
jmp fcntl
// b.s
.globl fcntl
fcntl:
  ret
```

`ld.lld -shared --wrap=fcntl a.o b.o` has an `R_X86_64_JUMP_SLOT` referencing
the index 0 undefined symbol, which will cause a glibc `symbol lookup error` at
runtime. This is because `__wrap_fcntl` is not in .dynsym

We use an approximation `!wrap->isUndefined()`, which doesn't set
`isUsedInRegularObj` of `__wrap_fcntl` when `fcntl` is referenced and
`__wrap_fcntl` is undefined.

Fix this by using `sym->referenced`.


Compare: https://github.com/llvm/llvm-project/compare/b5c542d64b98...f96ff3c0f8eb


More information about the All-commits mailing list