[lld] [LLD][COFF] Do as many passes of resolveRemainingUndefines as necessary for undefined lazy symbols (PR #109082)

Mike Hommey via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 01:34:21 PDT 2024


glandium wrote:

This is the repro that ends up broken because of missing relocations: 
https://drive.google.com/file/d/1qh0dWMsg4xftyijorkEMudx4rsi-LVXI/view?usp=sharing
without the patch, it fails with:
```
lld-link: warning: libwhatsys-6987fe4a7a53db19.rlib(db3b6bfb95261072-windows.o): locally defined symbol imported: strncpy_s (defined in libucrt.lib(strncpy_s.obj)) [LNK4217]
lld-link: warning: libwhatsys-6987fe4a7a53db19.rlib(db3b6bfb95261072-windows.o): locally defined symbol imported: __stdio_common_vsprintf (defined in libucrt.lib(output.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o): locally defined symbol imported: __stdio_common_vsprintf (defined in libucrt.lib(output.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o): locally defined symbol imported: strerror (defined in libucrt.lib(strerror.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o): locally defined symbol imported: calloc (defined in libucrt.lib(calloc.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o): locally defined symbol imported: malloc (defined in libucrt.lib(malloc.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o): locally defined symbol imported: free (defined in libucrt.lib(free.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o): locally defined symbol imported: strncmp (defined in libucrt.lib(strncmp.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-midl.o): locally defined symbol imported: malloc (defined in libucrt.lib(malloc.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-midl.o): locally defined symbol imported: free (defined in libucrt.lib(free.obj)) [LNK4217]
lld-link: warning: liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-midl.o): locally defined symbol imported: realloc (defined in libucrt.lib(realloc.obj)) [LNK4217]
lld-link: warning: oldnames.lib(strdup.obi): locally defined symbol imported: _strdup (defined in libucrt.lib(strdup.obj)) [LNK4217]
lld-link: error: undefined symbol: __declspec(dllimport) wcscpy
>>> referenced by /tmp/gecko/third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb.c:4238
>>>               liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o):(mdb_fopen)

lld-link: error: undefined symbol: __declspec(dllimport) _aligned_malloc
>>> referenced by /tmp/gecko/third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb.c:9324
>>>               liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o):(mdb_env_copyfd1)

lld-link: error: undefined symbol: __declspec(dllimport) _aligned_free
>>> referenced by /tmp/gecko/third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb.c:9425
>>>               liblmdb_sys-f56ac55de745eb3d.rlib(61d5b3baa82548eb-mdb.o):(mdb_env_copyfd1)
```

With the patch, executing the binary crashes (to reduce noise from the number of processes spawned, you may run `crashreporter-6497c44cdd21c683.exe test::glean_ping_`) because  __stdio_common_vsprintf doesn't point to the right place (but so do _imp_wcscpy, _imp_aligned_malloc and _imp_aligned_free, and probably the others, but I don't know about that for sure)

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


More information about the llvm-commits mailing list