[Bug ld/31956] -Wl,--wrap broken with LTO?

2024-07-07 Thread sam at gentoo dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=31956

--- Comment #5 from Sam James  ---
(In reply to Sam James from comment #4)
> Thank you! That fixes linking OpenVPN tests. They *do* fail at runtime which
> I haven't yet investigated, but they fail in the same way with mold, so not
> caused by the patch. I'll try the other packages tonight.

iwd works but mold+bfd both fail with openvpn's tests at runtime as the wrong
function gets called. Please wait a little bit while I reduce it into a clean
testcase.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/31956] -Wl,--wrap broken with LTO?

2024-07-07 Thread sam at gentoo dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=31956

--- Comment #6 from Sam James  ---
(In reply to Sam James from comment #5)

Here's a failing runtime test case with the patch.

tls_crypt_testdriver-buffer.c:
```
void buffer_write_file(void) {
  __builtin_printf("Called real buffer_write_file :(\n");
  __builtin_abort();
}
```

tls_crypt_testdriver-crypto.c:
```
void buffer_write_file(void);

void write_pem_key_file(const char *filename, const char *key_name) {
  buffer_write_file();
}
```

tls_crypt_testdriver-test_tls_crypt.c:
```
void write_pem_key_file(const char *filename, const char *key_name);

void __wrap_buffer_write_file(void) {
  __builtin_printf("Called wrapped buffer_write_file :)\n");
}

void test_tls_crypt_v2_write_server_key_file(void) {
  write_pem_key_file("testfilename.key", "OpenVPN tls-crypt-v2 server key");
}

int main() {
  test_tls_crypt_v2_write_server_key_file();
}
```

gcc -Og -flto -Wl,--wrap=buffer_write_file -o tls_crypt_testdriver
tls_crypt_testdriver-test_tls_crypt.c tls_crypt_testdriver-buffer.cc
tls_crypt_testdriver-crypto.c

It passes with lld but fails with mold and bfd.

-- 
You are receiving this mail because:
You are on the CC list for the bug.