mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix a dynamic symbol lookup issue in interpreter mode.
This was a very subtle bug, which occurred only in interpreter mode under Linux. The actual name of the symbol should be artificially prefixed by an underscore, because this underscore is stripped during a symbol lookup in interpreter mode. If this is not done, then a reference to variable "_x" is being resolved as a reference to the function "x"!
This commit is contained in:
@@ -595,8 +595,14 @@ llvm::Constant *swift::getWrapperFn(llvm::Module &Module,
|
||||
ARGS, ATTRS) \
|
||||
llvm::Constant *IRGenModule::get##ID##Fn() { \
|
||||
using namespace RuntimeConstants; \
|
||||
return getWrapperFn(Module, ID##Fn, #NAME, STR(SYMBOL_NAME), CC, RETURNS, \
|
||||
ARGS, ATTRS); \
|
||||
/* Add an underscore in JIT mode under Linux to enable proper symbol \
|
||||
* lookup */ \
|
||||
const char *Symbol = \
|
||||
(Opts.UseJIT && TargetInfo.OutputObjectFormat == llvm::Triple::ELF) \
|
||||
? "_" STR(SYMBOL_NAME) \
|
||||
: STR(SYMBOL_NAME); \
|
||||
return getWrapperFn(Module, ID##Fn, #NAME, Symbol, CC, RETURNS, ARGS, \
|
||||
ATTRS); \
|
||||
}
|
||||
|
||||
#include "swift/Runtime/RuntimeFunctions.def"
|
||||
|
||||
Reference in New Issue
Block a user