Skip to content

COFF: restructure metadata registration #13211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2017

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Dec 1, 2017

Restructure the COFF metadata handling to use the linker section
grouping to emit section start/stop markers in the appropriate location.
This allows us to lookup the sections statically without having to the
walk the entire image structure.

Introduce a constructor for PE/COFF binaries. This will ensure that the
registration occurs for all modules appropriately. This should resolve
rdar://problem/19045112. The registration should occur prior to
DllMain being invoked from DllMainCRTStartup.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

@compnerd compnerd requested a review from jckarter December 1, 2017 22:25
@compnerd
Copy link
Member Author

compnerd commented Dec 5, 2017

@swift-ci please test

@troughton
Copy link
Contributor

When trying to build for Windows with this merged in I run into issues. When linking swiftRemoteMirror.dll, swiftrt.o is passed to the linker invocation, but since the runtime isn't being linked in I'm getting __imp_swift_addNewDSOImage as undefined. Are you seeing anything similar locally?

This is from a clean build. I've removed the warning flags and abbreviated some paths to make it easier to read.

[3/14] Linking CXX shared library lib/swift/windows/x86_64/swiftRemoteMirror.dll
FAILED: : && /mnt/c/swift-source/build/Ninja-ReleaseAssert/llvm-linux-x86_64/./bin/clang++  -fPIC -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -fno-sanitize=all -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1 -O3  -target x86_64-unknown-windows-msvc -nostdlib -fuse-ld=lld  "-Llib/swift/windows/x86_64" "-L lib/swift/windows/x86_64" "-L lib/swift/windows" "-L VCToolsInstallDir/Lib/x64" "-L/ucrt/x64" "-L um/x64" -shared  -o lib/swift/windows/x86_64/swiftRemoteMirror.dll lib/swift/windows/x86_64/swiftrt.o stdlib/public/SwiftRemoteMirror/CMakeFiles/swiftRemoteMirror-windows-x86_64.dir/SwiftRemoteMirror.cpp.o -L/mnt/c/swift-source/build/Ninja-ReleaseAssert/llvm-linux-x86_64/./lib lib/swift/windows/x86_64/swiftReflection.lib && :
/usr/bin/lld-link: error: lib/swift/windows/x86_64/swiftrt.o: undefined symbol: __imp_swift_addNewDSOImage

@compnerd
Copy link
Member Author

compnerd commented Dec 7, 2017

Yeah, that is one issue that I need to fix still. Its interesting that this somehow works on ELF. I wonder if we should be preventing that injection here.

Restructure the COFF metadata handling to use the linker section
grouping to emit section start/stop markers in the appropriate location.
This allows us to lookup the sections statically without having to the
walk the entire image structure.

Introduce a constructor for PE/COFF binaries.  This will ensure that the
registration occurs for all modules appropriately.  This should resolve
rdar://problem/19045112.  The registration should occur prior to
`DllMain` being invoked from `DllMainCRTStartup`.
@compnerd
Copy link
Member Author

compnerd commented Dec 9, 2017

@swift-ci please test and merge

@swift-ci swift-ci merged commit a937179 into swiftlang:master Dec 9, 2017
@compnerd compnerd deleted the COFF-registration branch December 11, 2018 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants