mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
Help the lli interpreter find the stderr/stdin/stdout symbols. These are
needed for output to be generated. On Linux these are both global vars and macro definitions so we have to special case Linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33374 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -164,11 +164,23 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
|
|||||||
}
|
}
|
||||||
#undef EXPLICIT_SYMBOL
|
#undef EXPLICIT_SYMBOL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This macro returns the address of a well-known, explicit symbol
|
||||||
#define EXPLICIT_SYMBOL(SYM) \
|
#define EXPLICIT_SYMBOL(SYM) \
|
||||||
if (!strcmp(symbolName, #SYM)) return &SYM
|
if (!strcmp(symbolName, #SYM)) return &SYM
|
||||||
// Try a few well known symbols just to give lli a shot at working.
|
|
||||||
// Note that on some systems stdin, etc. are macros so we have to
|
// On linux we have a weird situation. The stderr/out/in symbols are both
|
||||||
// avoid attempting to take the address of a macro :)
|
// macros and global variables because of standards requirements. So, we
|
||||||
|
// boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
|
||||||
|
#if defined(__linux__)
|
||||||
|
{
|
||||||
|
EXPLICIT_SYMBOL(stderr);
|
||||||
|
EXPLICIT_SYMBOL(stdout);
|
||||||
|
EXPLICIT_SYMBOL(stdin);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// For everything else, we want to check to make sure the symbol isn't defined
|
||||||
|
// as a macro before using EXPLICIT_SYMBOL.
|
||||||
{
|
{
|
||||||
#ifndef stdin
|
#ifndef stdin
|
||||||
EXPLICIT_SYMBOL(stdin);
|
EXPLICIT_SYMBOL(stdin);
|
||||||
@ -178,8 +190,12 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) {
|
|||||||
#endif
|
#endif
|
||||||
#ifndef stderr
|
#ifndef stderr
|
||||||
EXPLICIT_SYMBOL(stderr);
|
EXPLICIT_SYMBOL(stderr);
|
||||||
|
#endif
|
||||||
|
#ifndef errno
|
||||||
|
EXPLICIT_SYMBOL(errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#undef EXPLICIT_SYMBOL
|
#undef EXPLICIT_SYMBOL
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user