-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Restore -static-executable on Linux. #29039
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,10 @@ | |
|
||
#include "ImageInspection.h" | ||
#include "ImageInspectionELF.h" | ||
|
||
#ifndef ELF_STATIC_LIB | ||
#include <dlfcn.h> | ||
#endif | ||
|
||
using namespace swift; | ||
|
||
|
@@ -56,6 +59,7 @@ void swift::initializeProtocolLookup() { | |
sections = sections->next; | ||
} | ||
} | ||
|
||
void swift::initializeProtocolConformanceLookup() { | ||
const swift::MetadataSections *sections = registered; | ||
while (true) { | ||
|
@@ -89,10 +93,8 @@ void swift::initializeTypeMetadataRecordLookup() { | |
void swift::initializeDynamicReplacementLookup() { | ||
} | ||
|
||
// As ELF images are loaded, ImageInspectionInit:sectionDataInit() will call | ||
// addNewDSOImage() with an address in the image that can later be used via | ||
// dladdr() to dlopen() the image after the appropriate initialize*Lookup() | ||
// function has been called. | ||
// As ELF images are loaded, SwiftRT-ELF:swift_image_constructor() will call | ||
// addNewDSOImage() with a pointer to the MetadataSections in the image. | ||
SWIFT_RUNTIME_EXPORT | ||
void swift_addNewDSOImage(const void *addr) { | ||
const swift::MetadataSections *sections = | ||
|
@@ -131,6 +133,12 @@ void swift_addNewDSOImage(const void *addr) { | |
} | ||
} | ||
|
||
#ifndef ELF_STATIC_LIB | ||
|
||
// For shared executables only, static executables use the version defined in | ||
// StaticBinaryELF.cpp. | ||
// libswiftImageInspectionShared.a contains the below function and | ||
// libswiftImageInspectionStatic.a contains the version in StaticBinaryELF.cpp | ||
int swift::lookupSymbol(const void *address, SymbolInfo *info) { | ||
Dl_info dlinfo; | ||
if (dladdr(address, &dlinfo) == 0) { | ||
|
@@ -144,6 +152,8 @@ int swift::lookupSymbol(const void *address, SymbolInfo *info) { | |
return 1; | ||
} | ||
|
||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just use the alternate version always? The cost is nearly negligible - the cost is largely associated with the fact that the information from the ELF header parsing may be cached by the loader, which is not guaranteed. |
||
|
||
// This is only used for backward deployment hooks, which we currently only support for | ||
// MachO. Add a stub here to make sure it still compiles. | ||
void *swift::lookupSection(const char *segment, const char *section, size_t *outSize) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.