Add loadNativeObj and unloadNativeObj

(This change is originally written by niteria)

This adds two functions:
* `loadNativeObj`
* `unloadNativeObj`
and implements them for Linux.

They are useful if you want to load a shared object with Haskell code
using the system linker and have GHC call dlclose() after the
code is no longer referenced from the heap.

Using the system linker allows you to load the shared object
above outside the low-mem region. It also loads the DWARF sections
in a way that `perf` understands.

`dl_iterate_phdr` is what makes this implementation Linux specific.
22 jobs for !3842 with wip/unloading in 368 minutes and 13 seconds (queued for 1 second)
detached
Status Job ID Name Coverage
  Lint
passed #414710
lint
ghc-linters

00:00:16

passed #414711
lint
lint-linters

00:00:15

passed #414714
lint
lint-submods

00:00:23

passed #414712
lint
lint-testsuite

00:00:16

passed #414713
lint
typecheck-testsuite

00:00:15

 
  Quick Build
passed #414715
x86_64-linux
hadrian-ghc-in-ghci

00:11:36

 
  Build
passed #414716
x86_64-linux
validate-x86_64-linux-deb9-hadrian

01:55:12

 
  Full Build
failed #414719
aarch64-linux allowed to fail
validate-aarch64-linux-deb9

03:10:30

failed #414720
armv7-linux allowed to fail
validate-armv7-linux-deb9

03:35:25

passed #414721
x86_64-linux
validate-i386-linux-deb9

01:32:52

passed #414718
x86_64-darwin
validate-x86_64-darwin

01:09:37

passed #414722
x86_64-linux
validate-x86_64-linux-deb9-debug

02:11:01

passed #414724
x86_64-linux
validate-x86_64-linux-deb9-dwarf

02:17:58

passed #414723
x86_64-linux
validate-x86_64-linux-deb9-integer-simple

01:20:09

passed #414717
x86_64-linux
validate-x86_64-linux-deb9-unreg-hadrian

03:00:30

passed #414725
x86_64-linux
validate-x86_64-linux-fedora27

01:34:05

failed #414727
new-x86_64-windows test allowed to fail
validate-x86_64-windows

00:29:35

failed #414726
new-x86_64-windows test allowed to fail
validate-x86_64-windows-hadrian

00:37:11

 
  Cleanup
passed #414728
x86_64-darwin
cleanup-darwin

00:00:14

 
  Packaging
failed #414729
x86_64-linux allowed to fail
doc-tarball

00:00:38

 
  Testing
manual #414730
x86_64-linux allowed to fail manual
hackage
passed #414731
x86_64-linux
perf-nofib

00:24:09

 
Name Stage Failure
failed
doc-tarball Packaging
Entering 'utils/haddock'
Entering 'utils/hsc2hs'
Downloading artifacts
Downloading artifacts for validate-x86_64-linux-deb9-debug (414722)...
Downloading artifacts from coordinator... ok
id=414722 responseStatus=200 OK token=U9VDax8r
Executing "step_script" stage of the job script
$ if [ ! -f "$LINUX_BINDIST" ]; then # collapsed multi-line command
Error: ghc-x86_64-mingw32.tar.xz does not exist. Did the 64-bit Windows job fail?
ERROR: Job failed: exit code 1
failed
validate-x86_64-windows Full Build
Git branch:   13-1-stable
GO version: go1.13.8
Built: 2020-06-19T21:12:23+0000
OS/Arch: windows/amd64
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=3968 revision=6214287e version=13.1.0
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 1
failed
validate-x86_64-windows-hadrian Full Build
Git branch:   13-1-stable
GO version: go1.13.8
Built: 2020-06-19T21:12:23+0000
OS/Arch: windows/amd64
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=3120 revision=6214287e version=13.1.0
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 1
failed
validate-aarch64-linux-deb9 Full Build
Uploading artifacts...
ghc-aarch64-linux-deb9.tar.xz: found 1 matching files and directories

junit.xml: found 1 matching files and directories

performance-metrics.tsv: found 1 matching files and directories

Uploading artifacts as "archive" to coordinator... ok
id=414719 responseStatus=201 Created token=yB4_x3r1
Uploading artifacts...
junit.xml: found 1 matching files and directories

Uploading artifacts as "junit" to coordinator... ok
id=414719 responseStatus=201 Created token=yB4_x3r1
ERROR: Job failed: exit code 1
failed
validate-armv7-linux-deb9 Full Build
Uploading artifacts...
ghc-armv7-linux-deb9.tar.xz: found 1 matching files

junit.xml: found 1 matching files

performance-metrics.tsv: found 1 matching files

Uploading artifacts to coordinator... ok
id=414720 responseStatus=201 Created token=nyTwsz4a
Uploading artifacts...
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=414720 responseStatus=201 Created token=nyTwsz4a
ERROR: Job failed: exit code 1