linker: store entire link map and use it.
authorTamar Christina <tamar@zhox.com>
Tue, 4 Dec 2018 00:29:08 +0000 (00:29 +0000)
committerBen Gamari <ben@smart-cactus.org>
Thu, 6 Dec 2018 17:49:25 +0000 (12:49 -0500)
commitc64918c1fc86d8feb15bf53b9db11ad81095b8b9
tree36d1b3100d1aa1e4b0f427372377353ac9b3de08
parentbf074e3e92c138947d0da3979838e5588f6f292c
linker: store entire link map and use it.

Summary:
This fixes a corner case in which we have seen the symbol multiple times in
different static libraries, but due to a depencency we end up loading the
symbol from a library other than the first one.

Previously the runtime linker would only track symbols from the first
library and did not store the full link map.  In this case it was unable
to find the address for the symbols in the second library during delay
loading.

This change stores the address of all symbols seen so a full link map
is generated, such that when we make a different decision later than what
was expected we're able to still correctly load the library.

Test Plan: ./validate, new testcase T15894

Reviewers: angerman, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15894

Differential Revision: https://phabricator.haskell.org/D5353

(cherry picked from commit a8b7cef4d45a5003bf7584e06912f0f632116c71)
rts/Linker.c
rts/LinkerInternals.h
rts/linker/Elf.c
rts/linker/MachO.c
rts/linker/PEi386.c
testsuite/tests/rts/T15894/Makefile [new file with mode: 0644]
testsuite/tests/rts/T15894/T15894.stdout [new file with mode: 0644]
testsuite/tests/rts/T15894/all.T [new file with mode: 0644]
testsuite/tests/rts/T15894/copysign.c [new file with mode: 0644]
testsuite/tests/rts/T15894/main.hs [new file with mode: 0644]