diff options
| author | Pip Cet | 2021-02-28 06:31:00 +0000 |
|---|---|---|
| committer | Andrea Corallo | 2021-03-03 20:36:16 +0100 |
| commit | 43b40bc880f66cb3f48318ba3a480a76b149b815 (patch) | |
| tree | 3449076778da0bb8595d8fad5184cf39c0a5bb6a /src | |
| parent | cf37850e2d69eda908495950acf8decb0ecec517 (diff) | |
| download | emacs-43b40bc880f66cb3f48318ba3a480a76b149b815.tar.gz emacs-43b40bc880f66cb3f48318ba3a480a76b149b815.zip | |
Don't call _setjmp through a function pointer (Bug#46824)
* src/comp.c (helper_link_table): Don't include SETJMP except on Windows.
(emit_setjmp): Don't use function pointers except on Windows.
(declare_runtime_imported_funcs): Don't import SETJMP at runtime.
(ABI_VERSION): Bump.
* test/src/comp-tests.el (46824-1): New test.
* test/src/comp-test-funcs.el (comp-test-46824-1-f): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/comp.c b/src/comp.c index bcffd426d95..bc458595331 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -422,7 +422,7 @@ load_gccjit_if_necessary (bool mandatory) | |||
| 422 | 422 | ||
| 423 | 423 | ||
| 424 | /* Increase this number to force a new Vcomp_abi_hash to be generated. */ | 424 | /* Increase this number to force a new Vcomp_abi_hash to be generated. */ |
| 425 | #define ABI_VERSION "1" | 425 | #define ABI_VERSION "2" |
| 426 | 426 | ||
| 427 | /* Length of the hashes used for eln file naming. */ | 427 | /* Length of the hashes used for eln file naming. */ |
| 428 | #define HASH_LENGTH 8 | 428 | #define HASH_LENGTH 8 |
| @@ -646,7 +646,9 @@ void *helper_link_table[] = | |||
| 646 | helper_PSEUDOVECTOR_TYPEP_XUNTAG, | 646 | helper_PSEUDOVECTOR_TYPEP_XUNTAG, |
| 647 | pure_write_error, | 647 | pure_write_error, |
| 648 | push_handler, | 648 | push_handler, |
| 649 | #ifdef WINDOWSNT | ||
| 649 | SETJMP_NAME, | 650 | SETJMP_NAME, |
| 651 | #endif | ||
| 650 | record_unwind_protect_excursion, | 652 | record_unwind_protect_excursion, |
| 651 | helper_unbind_n, | 653 | helper_unbind_n, |
| 652 | helper_save_restriction, | 654 | helper_save_restriction, |
| @@ -1935,8 +1937,19 @@ emit_setjmp (gcc_jit_rvalue *buf) | |||
| 1935 | { | 1937 | { |
| 1936 | #ifndef WINDOWSNT | 1938 | #ifndef WINDOWSNT |
| 1937 | gcc_jit_rvalue *args[] = {buf}; | 1939 | gcc_jit_rvalue *args[] = {buf}; |
| 1938 | return emit_call (intern_c_string (STR (SETJMP_NAME)), comp.int_type, 1, args, | 1940 | gcc_jit_param *params[] = |
| 1939 | false); | 1941 | { |
| 1942 | gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "buf"), | ||
| 1943 | }; | ||
| 1944 | /* Don't call setjmp through a function pointer (Bug#46824) */ | ||
| 1945 | gcc_jit_function *f = | ||
| 1946 | gcc_jit_context_new_function (comp.ctxt, NULL, | ||
| 1947 | GCC_JIT_FUNCTION_IMPORTED, | ||
| 1948 | comp.int_type, STR (SETJMP_NAME), | ||
| 1949 | ARRAYELTS (params), params, | ||
| 1950 | false); | ||
| 1951 | |||
| 1952 | return gcc_jit_context_new_call (comp.ctxt, NULL, f, 1, args); | ||
| 1940 | #else | 1953 | #else |
| 1941 | /* _setjmp (buf, __builtin_frame_address (0)) */ | 1954 | /* _setjmp (buf, __builtin_frame_address (0)) */ |
| 1942 | gcc_jit_rvalue *args[2]; | 1955 | gcc_jit_rvalue *args[2]; |
| @@ -2668,10 +2681,7 @@ declare_runtime_imported_funcs (void) | |||
| 2668 | args[1] = comp.int_type; | 2681 | args[1] = comp.int_type; |
| 2669 | ADD_IMPORTED (push_handler, comp.handler_ptr_type, 2, args); | 2682 | ADD_IMPORTED (push_handler, comp.handler_ptr_type, 2, args); |
| 2670 | 2683 | ||
| 2671 | #ifndef WINDOWSNT | 2684 | #ifdef WINDOWSNT |
| 2672 | args[0] = gcc_jit_type_get_pointer (gcc_jit_struct_as_type (comp.jmp_buf_s)); | ||
| 2673 | ADD_IMPORTED (SETJMP_NAME, comp.int_type, 1, args); | ||
| 2674 | #else | ||
| 2675 | args[0] = gcc_jit_type_get_pointer (gcc_jit_struct_as_type (comp.jmp_buf_s)); | 2685 | args[0] = gcc_jit_type_get_pointer (gcc_jit_struct_as_type (comp.jmp_buf_s)); |
| 2676 | args[1] = comp.void_ptr_type; | 2686 | args[1] = comp.void_ptr_type; |
| 2677 | ADD_IMPORTED (SETJMP_NAME, comp.int_type, 2, args); | 2687 | ADD_IMPORTED (SETJMP_NAME, comp.int_type, 2, args); |