linker: store entire link map and use it.
ClosedPublic

Authored by Phyx on Sun, Nov 18, 4:40 PM.

Details

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

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
Phyx created this revision.Sun, Nov 18, 4:40 PM
Phyx updated this revision to Diff 18755.Sun, Nov 18, 4:54 PM

Prevent builtin expansion.

simonmar added inline comments.Mon, Nov 19, 2:43 AM
rts/Linker.c
1582–1583

This comment is out of date now?

Phyx updated this revision to Diff 18760.Mon, Nov 19, 3:48 AM

Update comment

Phyx marked an inline comment as done.Mon, Nov 19, 3:49 AM
Phyx added inline comments.
rts/Linker.c
1582–1583

Thank you! I had completely missed it :)

bgamari accepted this revision.Thu, Nov 22, 10:44 AM

Thanks for the test!

This revision is now accepted and ready to land.Thu, Nov 22, 10:44 AM
Phyx added a comment.Wed, Nov 28, 12:53 PM

@angerman would it be possible for you to check if this compiles for me on MacOS? It's not a platform I have access to. Thanks 🙂

In D5353#148465, @Phyx wrote:

@angerman would it be possible for you to check if this compiles for me on MacOS? It's not a platform I have access to. Thanks 🙂

I'll try to get around to this over the weekend. Does that work for you?

Phyx added a comment.Thu, Nov 29, 2:47 AM

Yup that's fine, thanks!

It doesn't build for me; bails out with some rather weird linker errors.
I wouldn't put it past my system to be screwing me over here. I'll have to try in a clean room install again.

Phyx added a comment.Sun, Dec 2, 2:21 PM

It doesn't build for me; bails out with some rather weird linker errors.
I wouldn't put it past my system to be screwing me over here. I'll have to try in a clean room install again.

Thanks for testing, that's weird though... the code doesn't change any symbols so not expecting any link errors.. whenever you get a chance and can do the clean build let me know.

I'm mostly just after if I got all the replacements that needed to be done.

Thanks!

Log:

Seems to build a ghc on macOS.

Previous issue was gcc/binutils and llvm/clang/xcode crossing paths.

Phyx added a comment.Mon, Dec 3, 6:03 PM

Log:

Seems to build a ghc on macOS.

Previous issue was gcc/binutils and llvm/clang/xcode crossing paths.

Thanks you! Much appreciated!

Phyx updated this revision to Diff 18989.Tue, Dec 4, 1:08 AM

skip test when not dynway

This revision was automatically updated to reflect the committed changes.