forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cli/trampolines] Clean up definitions, fix win32 exporting issue (Ju…
- Loading branch information
1 parent
1a39aeb
commit 9cf5b23
Showing
7 changed files
with
95 additions
and
82 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Preprocessor annoyances | ||
#define CONCAT_(x,y) x##y | ||
#define CONCAT(x,y) CONCAT_(x, y) | ||
#define CNAMEADDR(name) CONCAT(CNAME(name),_addr) | ||
#define STR_(x) #x | ||
#define STR(x) STR_(x) | ||
#define I(x) x | ||
|
||
// On macOS and 32-bit windows, we need to prepend underscores on symbols to match the C ABI | ||
#if defined(__APPLE__) || (defined(_WIN32) && !defined(_WIN64)) | ||
#define UNDERSCORE(x) _##x | ||
#else | ||
#define UNDERSCORE(x) x | ||
#endif | ||
|
||
// Windows requires some help with the linker when it comes to debuginfo/exporting | ||
#if defined(_WIN32) || defined(_WIN64) | ||
#define DEBUGINFO(name) .def name; \ | ||
.scl 2; \ | ||
.type 32; \ | ||
.endef | ||
#define EXPORT(name) .section .drectve,"r"; \ | ||
.ascii STR(-export:##I(name)); \ | ||
.ascii " "; \ | ||
.section .text | ||
#else | ||
#define DEBUGINFO(name) | ||
#define EXPORT(name) | ||
#endif | ||
|
||
// Windows 64-bit uses SEH | ||
#if defined(_WIN64) | ||
#define SEH_START1(name) .seh_proc CNAME(name) | ||
#define SEH_START2() .seh_endprologue | ||
#define SEH_END() .seh_endproc | ||
#else | ||
#define SEH_START1(name) | ||
#define SEH_START2() | ||
#define SEH_END() | ||
#endif | ||
|
||
// If we're compiling with control-flow branch protection, mark the trampoline entry | ||
// points with `endbr{32,64}`, as appropriate on this arch | ||
#if defined(__CET__) && __CET__ & 1 != 0 | ||
#if defined(__x86_64__) | ||
#define CET_START() endbr64 | ||
#else | ||
#define CET_START() endbr32 | ||
#endif | ||
#else | ||
#define CET_START() | ||
#endif | ||
|
||
// aarch64 on mac requires some special assembler syntax for both calculating memory | ||
// offsets and even just the assembler statement separator token | ||
#if defined(__aarch64__) | ||
#if defined(__APPLE__) | ||
#define PAGE(x) x##@PAGE | ||
#define PAGEOFF(x) x##@PAGEOFF | ||
#define SEP %% | ||
#else | ||
#define PAGE(x) x | ||
#define PAGEOFF(x) :lo12:##x | ||
#define SEP ; | ||
#endif | ||
#endif | ||
|
||
// If someday we need to mangle everything, we do so by defining this `CNAME()` | ||
// to do something more complex than just `UNDERSCORE(x)`. | ||
#define CNAME(x) UNDERSCORE(x) |
This file contains 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 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 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 |
---|---|---|
@@ -1,32 +1,16 @@ | ||
#include "common.h" | ||
#include "../../src/jl_exported_funcs.inc" | ||
|
||
// On Windows, we need to prepend underscores on symbols | ||
#if defined(_WIN32) | ||
#define CNAME(x) _##x | ||
#define DEBUGINFO(name) .def CNAME(name); \ | ||
.scl 2; \ | ||
.type 32; \ | ||
.endef | ||
#else | ||
#define CNAME(x) x | ||
#define DEBUGINFO(name) | ||
#endif | ||
|
||
#if defined(__CET__) && __CET__ & 1 != 0 | ||
#define CET_START() endbr32 | ||
#else | ||
#define CET_START() | ||
#endif | ||
|
||
#define XX(name) \ | ||
DEBUGINFO(name); \ | ||
DEBUGINFO(CNAME(name)); \ | ||
.global CNAME(name); \ | ||
.cfi_startproc; \ | ||
CNAME(name)##:; \ | ||
CET_START(); \ | ||
jmpl *(CNAME(name##_addr)); \ | ||
jmpl *(CNAMEADDR(name)); \ | ||
ud2; \ | ||
.cfi_endproc; \ | ||
EXPORT(name); \ | ||
|
||
JL_EXPORTED_FUNCS(XX) | ||
#undef XX |
This file contains 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 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