https://sourceware.org/bugzilla/show_bug.cgi?id=31956

--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Sam James from comment #6)
> (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.

I don't think this testcase is valid. LTO knows nothing about symbol wrap. 
When
LTO sees a buffer_write_file call, it can inline it. To support symbol wrap,
the
original definition, buffer_write_file, shouldn't be visible to LTO.

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

Reply via email to