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)
Fri, Apr 25, 7:59 PM
Unknown Object (File)
Tue, Apr 22, 7:35 AM
Unknown Object (File)
Sun, Apr 13, 8:59 PM
Unknown Object (File)
Sun, Apr 13, 3:15 AM
Unknown Object (File)
Mar 15 2025, 7:11 AM
Unknown Object (File)
Mar 13 2025, 3:49 PM
Unknown Object (File)
Mar 12 2025, 12:12 AM
Unknown Object (File)
Mar 4 2025, 10:28 PM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 58536
Build 55424: arc lint + arc unit

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.