preload: Separate libc overrides from functional logic

Move all overridden libc functions below the "Overridden libc wrappers"
section, and split out their operation specific logic into new functions.

Add a new test to enforce this for the future.