From: Marc Glisse Date: Sun, 20 Nov 2016 13:35:27 +0000 (+0000) Subject: Protect __TMC_END__ - __TMC_LIST__ == 0 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=62a7df9f59c014c272f4216aac02a301a0778fdf;p=gcc.git Protect __TMC_END__ - __TMC_LIST__ == 0 2016-11-20 Marc Glisse PR libgcc/77813 * crtstuff.c (deregister_tm_clones, register_tm_clones): Hide __TMC_END__ behind a passthrough asm. From-SVN: r242635 --- diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 6f985239dff..90d7ee8d079 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,6 +1,12 @@ +2016-11-20 Marc Glisse + + PR libgcc/77813 + * crtstuff.c (deregister_tm_clones, register_tm_clones): Hide + __TMC_END__ behind a passthrough asm. + 2016-11-18 Walter Lee - * config.host (tilepro*-*-linux*): Add t-slibgcc-libgcc to tmake_file. + * config.host (tilepro*-*-linux*): Add t-slibgcc-libgcc to tmake_file. 2016-11-17 Andrew Senkevich diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c index 5449c4dbdb6..564418191d9 100644 --- a/libgcc/crtstuff.c +++ b/libgcc/crtstuff.c @@ -280,7 +280,10 @@ deregister_tm_clones (void) void (*fn) (void *); #ifdef HAVE_GAS_HIDDEN - if (__TMC_END__ - __TMC_LIST__ == 0) + func_ptr *end = __TMC_END__; + // Do not optimize the comparison to false. + __asm ("" : "+g" (end)); + if (__TMC_LIST__ == end) return; #else if (__TMC_LIST__[0] == NULL) @@ -300,7 +303,10 @@ register_tm_clones (void) size_t size; #ifdef HAVE_GAS_HIDDEN - size = (__TMC_END__ - __TMC_LIST__) / 2; + func_ptr *end = __TMC_END__; + // Do not optimize the comparison to false. + __asm ("" : "+g" (end)); + size = (end - __TMC_LIST__) / 2; #else for (size = 0; __TMC_LIST__[size * 2] != NULL; size++) continue;