[lld] [LLD][ELF] ignore ".so" in search path when relocatable set (PR #94965)

Reno Dakota via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 09:16:00 PDT 2024


================
@@ -49,6 +49,9 @@
 // RUN: ld.lld -o %t3 %t.o -L%t.dir -lls
 // RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
 
+// Should use static when dynamic exists in search path
+// RUN: ld.lld --relocatable -o %t3 %t.o -L%t.dir -lls
----------------
paparodeo wrote:

i think i figured it out. added the patterns under `RELOCATABLE`.

```
// RUN: ld.lld --relocatable -o %t3 %t.o -L%t.dir -lls
// RUN: llvm-readelf -s -h %t3 | FileCheck --check-prefix=RELOCATABLE %s
// RELOCATABLE: Type: REL (Relocatable file)
// RELOCATABLE: _static
```

<details><summary>llvm-readelf -s -h %t3</summary>

```
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          256 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         6
  Section header string table index: 4

Symbol table '.symtab' contains 5 entries:
   Num:    Value          Size Type    Bind   Vis       Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT   UND 
     1: 0000000000000000     0 SECTION LOCAL  DEFAULT     1 .text
     2: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT     1 _start
     3: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT     1 _bar
     4: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT     1 _static
```
</details>

https://github.com/llvm/llvm-project/pull/94965


More information about the llvm-commits mailing list