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)
Sun, Dec 8, 8:16 PM
Unknown Object (File)
Fri, Dec 6, 10:41 PM
Unknown Object (File)
Fri, Nov 29, 9:45 AM
Unknown Object (File)
Oct 3 2024, 2:49 AM
Unknown Object (File)
Sep 5 2024, 11:16 PM
Unknown Object (File)
Sep 1 2024, 6:39 PM
Unknown Object (File)
Aug 31 2024, 9:06 PM
Unknown Object (File)
Aug 22 2024, 12:51 AM
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.