Page MenuHomeFreeBSD

Some fixes for LD_BIND_NOW + ifuncs.
ClosedPublic

Authored by kib on Dec 1 2018, 12:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 6:51 PM
Unknown Object (File)
Wed, Apr 17, 5:50 PM
Unknown Object (File)
Wed, Apr 3, 7:03 PM
Unknown Object (File)
Thu, Mar 28, 7:28 AM
Unknown Object (File)
Mar 10 2024, 8:57 PM
Unknown Object (File)
Jan 14 2024, 8:16 PM
Unknown Object (File)
Dec 20 2023, 2:11 AM
Unknown Object (File)
Dec 19 2023, 8:08 PM
Subscribers

Details

Summary
  • Do not perform ifunc relocations together with other PLT relocations in PLT. Instead, do it during an additional pass over the init list, so that ifuncs are resolved in the order of dso dependencies. This allows the ifuncs resolvers to call info depended libs. init list now includes all objects instead of only objects with init/fini callables,
  • Disable relro protection around bind_now ifunc relocations.
  • Provide memset() and bzero() internal implementations. This will be needed when the functions in libc are converted to ifuncs. To be committed separately.

I considered calling ifunc resolvers of dso after initializers of all dependencies are processed, and decided that this is wrong/should not be supported. The order now is normal relocations for all objects->ifunc resolution in init order->initializers, where each step does complete pass over all loaded objects before moving to the next step.

Test Plan

LD_BIND_NOW=yes threaded_program

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added a subscriber: theraven.

Will test shortly

libexec/rtld-elf/rtld.c
5369 ↗(On Diff #51467)

EOL whitespace here

I tested this patch in my tree, with BIND_NOW on by default, PIE on by default, and rS341429 reverted. Sanity tests on a few threaded applications showed no issues. Building vanilla FreeBSD + this patch for testing now.

Smoke test in my staging tree (this patch plus 3 unrelated changes) looks good.

libexec/rtld-elf/rtld.c
5364 ↗(On Diff #51467)

I find disable_relro vs enforce_relro slightly odd, although for the 'turn on' case enforce does seem somehow more appropriate than enable.

This revision is now accepted and ready to land.Dec 3 2018, 7:40 PM
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state Needs Review.Dec 3 2018, 8:04 PM
This revision was automatically updated to reflect the committed changes.