diff options
| author | Paul Eggert | 2019-04-21 20:34:03 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-04-21 21:16:26 -0700 |
| commit | f67bc3f12b8ebe4ff0d133063e3c41ab772dbd45 (patch) | |
| tree | f1f3482421b2358e0d95d1be4a62654c70a49a61 /src | |
| parent | 3a618e5f89c86bc96925b06647fb33568c8fa2c9 (diff) | |
| download | emacs-f67bc3f12b8ebe4ff0d133063e3c41ab772dbd45.tar.gz emacs-f67bc3f12b8ebe4ff0d133063e3c41ab772dbd45.zip | |
Port to recent gcc -fsanitize=undefined
* src/alloc.c (XPNTR): Add ATTRIBUTE_NO_SANITIZE_UNDEFINED and
remove ATTRIBUTE_UNUSED. Do not define as a macro, so that
ATTRIBUTE_NO_SANITIZE_UNDEFINED works.
* src/lisp.h (lisp_h_XSYMBOL): Remove. All uses removed.
With recent GCC the macro does not work with -fsanitize=undefined,
and the macro can be omitted as its only function is to optimize -O0.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 6 | ||||
| -rw-r--r-- | src/lisp.h | 24 |
2 files changed, 4 insertions, 26 deletions
diff --git a/src/alloc.c b/src/alloc.c index b5b6dc2f05f..a9cdd77ef2e 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -558,16 +558,12 @@ PNTR_ADD (char *p, EMACS_UINT i) | |||
| 558 | - ((EMACS_UINT) Lisp_Symbol << (USE_LSB_TAG ? 0 : VALBITS)))) \ | 558 | - ((EMACS_UINT) Lisp_Symbol << (USE_LSB_TAG ? 0 : VALBITS)))) \ |
| 559 | : (char *) XLP (o) - (XLI (o) & ~VALMASK))) | 559 | : (char *) XLP (o) - (XLI (o) & ~VALMASK))) |
| 560 | 560 | ||
| 561 | static ATTRIBUTE_UNUSED void * | 561 | static ATTRIBUTE_NO_SANITIZE_UNDEFINED void * |
| 562 | XPNTR (Lisp_Object a) | 562 | XPNTR (Lisp_Object a) |
| 563 | { | 563 | { |
| 564 | return macro_XPNTR (a); | 564 | return macro_XPNTR (a); |
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | #if DEFINE_KEY_OPS_AS_MACROS | ||
| 568 | # define XPNTR(a) macro_XPNTR (a) | ||
| 569 | #endif | ||
| 570 | |||
| 571 | static void | 567 | static void |
| 572 | XFLOAT_INIT (Lisp_Object f, double n) | 568 | XFLOAT_INIT (Lisp_Object f, double n) |
| 573 | { | 569 | { |
diff --git a/src/lisp.h b/src/lisp.h index c2cb89de9d5..2d250fc52ce 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -421,19 +421,6 @@ typedef EMACS_INT Lisp_Word; | |||
| 421 | XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0)) | 421 | XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0)) |
| 422 | # define lisp_h_XFIXNAT(a) XFIXNUM (a) | 422 | # define lisp_h_XFIXNAT(a) XFIXNUM (a) |
| 423 | # define lisp_h_XFIXNUM(a) (XLI (a) >> INTTYPEBITS) | 423 | # define lisp_h_XFIXNUM(a) (XLI (a) >> INTTYPEBITS) |
| 424 | # ifdef __CHKP__ | ||
| 425 | # define lisp_h_XSYMBOL(a) \ | ||
| 426 | (eassert (SYMBOLP (a)), \ | ||
| 427 | (struct Lisp_Symbol *) ((char *) XUNTAG (a, Lisp_Symbol, \ | ||
| 428 | struct Lisp_Symbol) \ | ||
| 429 | + (intptr_t) lispsym)) | ||
| 430 | # else | ||
| 431 | /* If !__CHKP__ this is equivalent, and is a bit faster as of GCC 7. */ | ||
| 432 | # define lisp_h_XSYMBOL(a) \ | ||
| 433 | (eassert (SYMBOLP (a)), \ | ||
| 434 | (struct Lisp_Symbol *) ((intptr_t) XLI (a) - Lisp_Symbol \ | ||
| 435 | + (char *) lispsym)) | ||
| 436 | # endif | ||
| 437 | # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK)) | 424 | # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK)) |
| 438 | #endif | 425 | #endif |
| 439 | 426 | ||
| @@ -479,7 +466,6 @@ typedef EMACS_INT Lisp_Word; | |||
| 479 | # define make_fixnum(n) lisp_h_make_fixnum (n) | 466 | # define make_fixnum(n) lisp_h_make_fixnum (n) |
| 480 | # define XFIXNAT(a) lisp_h_XFIXNAT (a) | 467 | # define XFIXNAT(a) lisp_h_XFIXNAT (a) |
| 481 | # define XFIXNUM(a) lisp_h_XFIXNUM (a) | 468 | # define XFIXNUM(a) lisp_h_XFIXNUM (a) |
| 482 | # define XSYMBOL(a) lisp_h_XSYMBOL (a) | ||
| 483 | # define XTYPE(a) lisp_h_XTYPE (a) | 469 | # define XTYPE(a) lisp_h_XTYPE (a) |
| 484 | # endif | 470 | # endif |
| 485 | #endif | 471 | #endif |
| @@ -1023,21 +1009,17 @@ INLINE bool | |||
| 1023 | } | 1009 | } |
| 1024 | 1010 | ||
| 1025 | INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED | 1011 | INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED |
| 1026 | (XSYMBOL) (Lisp_Object a) | 1012 | XSYMBOL (Lisp_Object a) |
| 1027 | { | 1013 | { |
| 1028 | #if USE_LSB_TAG | ||
| 1029 | return lisp_h_XSYMBOL (a); | ||
| 1030 | #else | ||
| 1031 | eassert (SYMBOLP (a)); | 1014 | eassert (SYMBOLP (a)); |
| 1032 | intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol, struct Lisp_Symbol); | 1015 | intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol, struct Lisp_Symbol); |
| 1033 | void *p = (char *) lispsym + i; | 1016 | void *p = (char *) lispsym + i; |
| 1034 | # ifdef __CHKP__ | 1017 | #ifdef __CHKP__ |
| 1035 | /* Bypass pointer checking. Although this could be improved it is | 1018 | /* Bypass pointer checking. Although this could be improved it is |
| 1036 | probably not worth the trouble. */ | 1019 | probably not worth the trouble. */ |
| 1037 | p = __builtin___bnd_set_ptr_bounds (p, sizeof (struct Lisp_Symbol)); | 1020 | p = __builtin___bnd_set_ptr_bounds (p, sizeof (struct Lisp_Symbol)); |
| 1038 | # endif | ||
| 1039 | return p; | ||
| 1040 | #endif | 1021 | #endif |
| 1022 | return p; | ||
| 1041 | } | 1023 | } |
| 1042 | 1024 | ||
| 1043 | INLINE Lisp_Object | 1025 | INLINE Lisp_Object |