[lld] [LLD][COFF] Prevent to emit relocations for discarded weak wrapped symbols (PR #156214)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 30 20:23:03 PDT 2025
jeremyd2019 wrote:
It looks like it's still pulling in all the `__wrap_` symbols from cygwin1.dll:
```
00002220 000022b4 00000000 00000000 000029f0 0000242c
DLL Name: cygwin1.dll
vma: Ordinal Hint Member-Name Bound-To
0000242c <none> 0010 __cxa_atexit
00002434 <none> 002f __main
0000243c <none> 005d __wrap__ZdaPv
00002444 <none> 005e __wrap__ZdaPvRKSt9nothrow_t
0000244c <none> 005f __wrap__ZdaPvSt11align_val_t
00002454 <none> 0060 __wrap__ZdaPvSt11align_val_tRKSt9nothrow_t
0000245c <none> 0061 __wrap__ZdaPvm
00002464 <none> 0062 __wrap__ZdaPvmSt11align_val_t
0000246c <none> 0063 __wrap__ZdlPv
00002474 <none> 0064 __wrap__ZdlPvRKSt9nothrow_t
0000247c <none> 0065 __wrap__ZdlPvSt11align_val_t
00002484 <none> 0066 __wrap__ZdlPvSt11align_val_tRKSt9nothrow_t
0000248c <none> 0067 __wrap__ZdlPvm
00002494 <none> 0068 __wrap__ZdlPvmSt11align_val_t
0000249c <none> 0069 __wrap__Znam
000024a4 <none> 006a __wrap__ZnamRKSt9nothrow_t
000024ac <none> 006b __wrap__ZnamSt11align_val_t
000024b4 <none> 006c __wrap__ZnamSt11align_val_tRKSt9nothrow_t
000024bc <none> 006d __wrap__Znwm
000024c4 <none> 006e __wrap__ZnwmRKSt9nothrow_t
000024cc <none> 006f __wrap__ZnwmSt11align_val_t
000024d4 <none> 0070 __wrap__ZnwmSt11align_val_tRKSt9nothrow_t
000024dc <none> 0079 _dll_crt0
000024e4 <none> 0080 _impure_ptr
000024ec <none> 0118 calloc
000024f4 <none> 0192 cygwin_detach_dll
000024fc <none> 0194 cygwin_internal
00002504 <none> 01b0 dll_dllcrt0
0000250c <none> 0262 free
00002514 <none> 03ad malloc
0000251c <none> 0421 posix_memalign
00002524 <none> 0444 printf
0000252c <none> 04de realloc
```
vs this with bfd
```
00007028 000070a0 00000000 00000000 00007428 00007178
DLL Name: cygwin1.dll
vma: Ordinal Hint Member-Name Bound-To
00007178 <none> 0010 __cxa_atexit
00007180 <none> 002f __main
00007188 <none> 0067 __wrap__ZdlPvm
00007190 <none> 0068 __wrap__ZdlPvmSt11align_val_t
00007198 <none> 006d __wrap__Znwm
000071a0 <none> 006f __wrap__ZnwmSt11align_val_t
000071a8 <none> 0079 _dll_crt0
000071b0 <none> 0080 _impure_ptr
000071b8 <none> 0118 calloc
000071c0 <none> 0192 cygwin_detach_dll
000071c8 <none> 0194 cygwin_internal
000071d0 <none> 01b0 dll_dllcrt0
000071d8 <none> 0262 free
000071e0 <none> 03ad malloc
000071e8 <none> 0421 posix_memalign
000071f0 <none> 0444 printf
000071f8 <none> 04de realloc
```
<details>
<summary>Test source (no defines)</summary>
```c++
#include <stdio.h>
#include <new>
#include <string>
#ifdef OVERRIDE_NEW_DELETE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
void *operator new (std::size_t sz)
{
printf ("In new\n");
return LocalAlloc (LMEM_FIXED, sz);
}
void operator delete (void *p)
{
printf ("In delete\n");
LocalFree (p);
}
void operator delete (void *p, std::size_t)
{
printf ("In delete sz\n");
LocalFree (p);
}
#endif
struct alignas(32) foo {};
int main (void)
{
char *p = new char (0); // _Znwm
printf ("%p\n", p);
delete p; // _ZdlPvm
foo *bar = new foo; // _ZnwmSt11align_val_t
printf ("%p\n", bar);
delete bar; // _ZdlPvmSt11align_val_t
{
std::string foo (1024, 'x');
printf ("%p\n", foo.data ());
}
return 0;
}
```
</details>
https://github.com/llvm/llvm-project/pull/156214
More information about the llvm-commits
mailing list