Page MenuHomeFreeBSD

rtld: actually resolve memcpy plt
ClosedPublic

Authored by rlibby on Jul 5 2024, 10:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 15, 7:11 AM
Unknown Object (File)
Thu, Mar 13, 3:49 PM
Unknown Object (File)
Wed, Mar 12, 12:12 AM
Unknown Object (File)
Tue, Mar 4, 10:28 PM
Unknown Object (File)
Feb 10 2025, 5:30 PM
Unknown Object (File)
Feb 5 2025, 2:54 PM
Unknown Object (File)
Feb 5 2025, 12:22 PM
Unknown Object (File)
Jan 20 2025, 9:25 AM
Subscribers

Details

Summary

The call to memcpy() meant to cause plt resolution in _thr_rtld_init()
was getting optimized by the compiler. Tell the compiler not to use its
memcpy() builtin in thr_rtld.c.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Should we disable all built-ins for the file, for the same reasoning?

This revision is now accepted and ready to land.Jul 5 2024, 10:32 PM
In D45891#1046235, @kib wrote:

Should we disable all built-ins for the file, for the same reasoning?

That makes sense to me, for future insurance. I checked just now that -fno-builtin didn't reveal any additional cases. Do you prefer to make that change?

kib: just disable all builtins

This revision now requires review to proceed.Jul 6 2024, 1:10 AM
kib added inline comments.
lib/libthr/Makefile
35

I would add a comment there, noting that this flag is there for functional purpose, instead of suppressing some warning.

This revision is now accepted and ready to land.Jul 6 2024, 2:33 AM
This revision now requires review to proceed.Jul 6 2024, 4:54 AM
This revision is now accepted and ready to land.Jul 6 2024, 7:52 AM
This revision was automatically updated to reflect the committed changes.

No sure how much the builtins optimization matters here but if it does the other workaround would be:

void* memcpy_for_plt(void*, const void*, size_t) asm("memcpy")

And then call that.

No sure how much the builtins optimization matters here but if it does the other workaround would be:

void* memcpy_for_plt(void*, const void*, size_t) asm("memcpy")

And then call that.

Thanks for the info. I think @kib could speak better to whether any code in this file could be important in terms of performance. In any case, I believe the one memcpy was the only site actually affected when I examined the codegen for amd64.

No sure how much the builtins optimization matters here but if it does the other workaround would be:

void* memcpy_for_plt(void*, const void*, size_t) asm("memcpy")

And then call that.

Thanks for the info. I think @kib could speak better to whether any code in this file could be important in terms of performance. In any case, I believe the one memcpy was the only site actually affected when I examined the codegen for amd64.

lock_acquire/release are the only functions which performance is critical for runtime.

That said, I do believe that correctness trumps speed.