modernize the PIE patch for the latest master branch

This is the part of #3960 that has to be rewritten to apply to latest
master branch code.
abc717f203Andrew Kelley committed on 11/23/2020, 12:28:11 AMparent55ab50e
18 files changedLine totals unavailable