diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-04-03 15:01:34 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-04-03 15:01:34 -0700 |
commit | 00eb71c43c74cc5143b60d470450c3981037ed3c (patch) | |
tree | 66833e46153e7869903229adb39ebb1a86c86169 /libgcc | |
parent | 213caedb0104ed919b67b3446a53f06054d62fec (diff) | |
parent | ff229375721d1763a18ec76403aa1215b2932fb3 (diff) | |
download | gcc-00eb71c43c74cc5143b60d470450c3981037ed3c.zip gcc-00eb71c43c74cc5143b60d470450c3981037ed3c.tar.gz gcc-00eb71c43c74cc5143b60d470450c3981037ed3c.tar.bz2 |
Merge from trunk revision ff229375721d1763a18ec76403aa1215b2932fb3
Diffstat (limited to 'libgcc')
34 files changed, 774 insertions, 356 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 76c9946..c113897 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,118 @@ +2020-03-03 Richard Earnshaw <rearnsha@arm.com> + + * config/arm/bpabi-v6m.S (aeabi_lcmp): Convert thumb1 code to unified + syntax. + (aeabi_ulcmp, aeabi_ldivmod, aeabi_uldivmod): Likewise. + (aeabi_frsub, aeabi_cfcmpeq, aeabi_fcmpeq): Likewise. + (aeabi_fcmp, aeabi_drsub, aeabi_cdrcmple): Likewise. + (aeabi_cdcmpeq, aeabi_dcmpeq, aeabi_dcmp): Likewise. + * config/arm/lib1funcs.S (Lend_fde): Convert thumb1 code to unified + syntax. + (divsi3, modsi3): Likewise. + (clzdi2, ctzsi2): Likewise. + * config/arm/libunwind.S (restore_core_regs): Convert thumb1 code to + unified syntax. + (UNWIND_WRAPPER): Likewise. + +2020-03-02 Martin Liska <mliska@suse.cz> + + * libgcov-interface.c: Remove duplicate + declaration of __gcov_flush_mx. + +2020-02-18 Martin Liska <mliska@suse.cz> + + PR ipa/92924 + * libgcov-merge.c (merge_topn_values_set): Record + when a TOP N counter becomes invalid. When merging + remove a smallest value if the space is needed. + +2020-02-12 Sandra Loosemore <sandra@codesourcery.com> + + PR libstdc++/79193 + PR libstdc++/88999 + + * configure: Regenerated. + +2020-02-10 Jeff Law <law@redhat.com> + + * config/frv/frvbegin.c: Use right flags for .ctors and .dtors + sections. + * config/frv/frvend.c: Similarly. + +2020-02-10 H.J. Lu <hongjiu.lu@intel.com> + + PR libgcc/85334 + * config/i386/shadow-stack-unwind.h (_Unwind_Frames_Increment): + New. + +2020-02-10 Christophe Lyon <christophe.lyon@linaro.org> + + PR target/93615 + * unwind-arm-common.inc: Replace uses of gnu_Unwind_Find_got with + _Unwind_gnu_Find_got. + * unwind-pe.h: Likewise. + +2020-02-07 Jakub Jelinek <jakub@redhat.com> + + PR target/93615 + * config/arm/unwind-arm.h (gnu_Unwind_Find_got): Rename to ... + (_Unwind_gnu_Find_got): ... this. Use __asm instead of asm. Remove + trailing :s in asm. Formatting fixes. + (_Unwind_decode_typeinfo_ptr): Adjust caller. + +2020-01-31 Sandra Loosemore <sandra@codesourcery.com> + + nios2: Support for GOT-relative DW_EH_PE_datarel encoding. + + * config.host [nios2-*-linux*] (tmake_file, tm_file): Adjust. + * config/nios2-elf-lib.h: New. + * unwind-dw2-fde-dip.c (_Unwind_IteratePhdrCallback): Use existing + code for finding GOT base for nios2. + +2020-01-27 Martin Liska <mliska@suse.cz> + + PR gcov-profile/93403 + * libgcov-profiler.c (__gcov_indirect_call_profiler_v4): + Call __gcov_indirect_call_profiler_body. + (__gcov_indirect_call_profiler_body): New. + (__gcov_indirect_call_profiler_v4_atomic): New. + * libgcov.h (__gcov_indirect_call_profiler_v4_atomic): + New declaration. + +2020-01-27 Claudiu Zissulescu <claziss@synopsys.com> + + * config/arc/crti.S: Add RF16 object attribute. + * config/arc/crtn.S: Likewise. + * config/arc/crttls.S: Likewise. + * config/arc/lib1funcs.S: Likewise. + * config/arc/fp-hack.h (ARC_OPTFPE): Define. + * config/arc/lib2funcs.c: New file. + * config/arc/t-arc: Add lib2funcs to LIB2ADD. + +2020-01-24 Maciej W. Rozycki <macro@wdc.com> + + * Makefile.in (configure_deps): Add `toolexeclibdir.m4'. + * configure.ac: Handle `--with-toolexeclibdir='. + * configure: Regenerate. + +2020-01-23 Dragan Mladjenovic <dmladjenovic@wavecomp.com> + + * config/mips/gnustack.h: Check for TARGET_LIBC_GNUSTACK also. + +2020-01-23 Dragan Mladjenovic <dmladjenovic@wavecomp.com> + + * config/mips/gnustack.h: New file. + * config/mips/crti.S: Include gnustack.h. + * config/mips/crtn.S: Likewise. + * config/mips/mips16.S: Likewise. + * config/mips/vr4120-div.S: Likewise. + +2020-01-23 Martin Liska <mliska@suse.cz> + + * libgcov-driver.c (prune_topn_counter): Remove + check for -1 as we only prune run-time counters + that do not generate an invalid state. + 2020-01-22 Martin Liska <mliska@suse.cz> PR tree-optimization/92924 diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 43bad01..851e765 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -165,6 +165,7 @@ AUTOCONF = autoconf configure_deps = \ $(srcdir)/../config/enable.m4 \ $(srcdir)/../config/tls.m4 \ + $(srcdir)/../config/toolexeclibdir.m4 \ $(srcdir)/../config/acx.m4 \ $(srcdir)/../config/no-executables.m4 \ $(srcdir)/../config/lib-ld.m4 \ diff --git a/libgcc/config.host b/libgcc/config.host index 8f0ea90..1ff4159 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1112,7 +1112,8 @@ nds32*-elf*) esac ;; nios2-*-linux*) - tmake_file="$tmake_file nios2/t-nios2 nios2/t-linux t-libgcc-pic t-slibgcc-libgcc" + tmake_file="$tmake_file nios2/t-nios2 nios2/t-linux t-libgcc-pic t-eh-dw2-dip t-slibgcc-libgcc" + tm_file="$tm_file nios2/elf-lib.h" md_unwind_header=nios2/linux-unwind.h ;; nios2-*-*) @@ -1300,7 +1301,7 @@ s390x-*-linux*) md_unwind_header=s390/linux-unwind.h ;; s390x-ibm-tpf*) - tmake_file="${tmake_file} s390/t-crtstuff t-libgcc-pic t-eh-dw2-dip" + tmake_file="${tmake_file} s390/t-crtstuff t-libgcc-pic t-eh-dw2-dip s390/t-tpf" extra_parts="crtbeginS.o crtendS.o" md_unwind_header=s390/tpf-unwind.h ;; diff --git a/libgcc/config/arc/crti.S b/libgcc/config/arc/crti.S index 297ddc7..e05a789 100644 --- a/libgcc/config/arc/crti.S +++ b/libgcc/config/arc/crti.S @@ -28,6 +28,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # This file contains the stack frame setup for contents of the .fini and # .init sections. +#ifdef __ARC_RF16__ + /* Use object attributes to inform other tools this file is + safe for RF16 configuration. */ + .arc_attribute Tag_ARC_ABI_rf16, 1 +#endif .section .init .global _init .word 0 diff --git a/libgcc/config/arc/crtn.S b/libgcc/config/arc/crtn.S index fc6197f..37eac5e 100644 --- a/libgcc/config/arc/crtn.S +++ b/libgcc/config/arc/crtn.S @@ -28,6 +28,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # This file just makes sure that the .fini and .init sections do in # fact return. This file is the last thing linked into any executable. +#ifdef __ARC_RF16__ + /* Use object attributes to inform other tools this file is + safe for RF16 configuration. */ + .arc_attribute Tag_ARC_ABI_rf16, 1 +#endif .section .init pop_s blink j_s [blink] diff --git a/libgcc/config/arc/crttls.S b/libgcc/config/arc/crttls.S index 4c8faf9..b5aebf1 100644 --- a/libgcc/config/arc/crttls.S +++ b/libgcc/config/arc/crttls.S @@ -33,6 +33,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see the executable file might be covered by the GNU General Public License. */ +#ifdef __ARC_RF16__ + /* Use object attributes to inform other tools this file is + safe for RF16 configuration. */ + .arc_attribute Tag_ARC_ABI_rf16, 1 +#endif + #if (__ARC_TLS_REGNO__ != -1) /* ANSI concatenation macros. */ diff --git a/libgcc/config/arc/fp-hack.h b/libgcc/config/arc/fp-hack.h index 86b63d9..65cdcdd 100644 --- a/libgcc/config/arc/fp-hack.h +++ b/libgcc/config/arc/fp-hack.h @@ -30,7 +30,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define ARC_FP_DEBUG 1 #define FINE_GRAINED_LIBRARIES -#define ARC_OPTFPE (defined (__ARC700__) || defined (__ARC_FPX_QUARK__)) + +#if defined (__ARC700__) || defined (__ARC_FPX_QUARK__) +#define ARC_OPTFPE 1 +#endif #if !ARC_OPTFPE || ARC_FP_DEBUG #define L_pack_sf diff --git a/libgcc/config/arc/lib1funcs.S b/libgcc/config/arc/lib1funcs.S index 1ada0fe..cc54b40 100644 --- a/libgcc/config/arc/lib1funcs.S +++ b/libgcc/config/arc/lib1funcs.S @@ -53,7 +53,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define ENDFUNC0(X) .Lfe_##X: .size X,.Lfe_##X-X #define ENDFUNC(X) ENDFUNC0(X) - +#ifdef __ARC_RF16__ + /* Use object attributes to inform other tools this file is + safe for RF16 configuration. */ + .arc_attribute Tag_ARC_ABI_rf16, 1 +#endif #ifdef L_mulsi3 .section .text @@ -232,6 +236,7 @@ SYM(__umulsi3_highpart): #endif #endif /* L_umulsidi3 */ +#ifndef __ARC_RF16__ #ifdef L_muldi3 .section .text .align 4 @@ -285,6 +290,7 @@ SYM(__muldi3): #endif /* __LITTLE_ENDIAN__ */ ENDFUNC(__muldi3) #endif /* L_muldi3 */ +#endif /* !__ARC_RF16__ */ #ifdef L_umulsi3_highpart #include "ieee-754/arc-ieee-754.h" @@ -544,12 +550,6 @@ SYM(__udivmodsi4): SYM(__udivsi3): b @SYM(__udivmodsi4) ENDFUNC(__udivsi3) -#if 0 /* interferes with linux loader */ - .section .__arc_profile_forward, "a" - .long SYM(__udivsi3) - .long SYM(__udivmodsi4) - .long 65536 -#endif #endif /* L_udivsi3 */ @@ -948,12 +948,6 @@ SYM(__umodsi3): j.d [r7] mov r0,r1 ENDFUNC(__umodsi3) -#if 0 /* interferes with linux loader */ - .section .__arc_profile_forward, "a" - .long SYM(__umodsi3) - .long SYM(__udivmodsi4) - .long 65536 -#endif #endif /* L_umodsi3 */ @@ -1106,6 +1100,7 @@ SYM(__clzsi2): ;; ;#endif +#ifndef __ARC_RF16__ #ifdef L_millicodethunk_st .section .text .align 4 @@ -1315,9 +1310,7 @@ SYM(__ld_r13_to_r14_ret): #endif /* L_millicodethunk_ret */ -#define ARC_OPTFPE (defined (__ARC700__) || defined (__ARC_FPX_QUARK__)) - -#if ARC_OPTFPE +#if defined (__ARC700__) || defined (__ARC_FPX_QUARK__) #ifdef L_adddf3 #ifdef __ARC_NORM__ #include "ieee-754/adddf3.S" @@ -1482,3 +1475,5 @@ SYM(__ld_r13_to_r14_ret): #endif #endif #endif /* ARC_OPTFPE */ + +#endif /* !__ARC_RF16__ */ diff --git a/libgcc/config/arc/lib2funcs.c b/libgcc/config/arc/lib2funcs.c new file mode 100644 index 0000000..f9de7b2 --- /dev/null +++ b/libgcc/config/arc/lib2funcs.c @@ -0,0 +1,88 @@ +/* libgcc routines for ARC + Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. */ + + +typedef int sint64_t __attribute__ ((mode (DI))); +typedef unsigned int uint64_t __attribute__ ((mode (DI))); +typedef unsigned int nint32_t __attribute__ ((mode (SI))); +typedef int word_t __attribute__ ((mode (__word__))); + +sint64_t __muldi3 (sint64_t, sint64_t); +nint32_t __umodsi3 (nint32_t, nint32_t); + +#ifdef __ARC_RF16__ + +/* Generic multiplication procedure. No mpy operation involved. */ +sint64_t +__muldi3 (sint64_t a, sint64_t b) +{ + sint64_t res = 0; + uint64_t cnt = a; + + while (cnt) + { + if (cnt & 1) + res += b; + b <<= 1; + cnt >>= 1; + } + return res; +} + +/* Unsigned 32bit integer division/modulus. */ + +static inline __attribute__ ((__always_inline__)) +nint32_t +udivmodsi4 (nint32_t num, nint32_t den, word_t modwanted) +{ + nint32_t bit = 1; + nint32_t res = 0; + + while (den < num && bit && !(den & (1LL << 63))) + { + den <<= 1; + bit <<= 1; + } + while (bit) + { + if (num >= den) + { + num -= den; + res |= bit; + } + bit >>= 1; + den >>= 1; + } + if (modwanted) + return num; + return res; +} + +nint32_t +__umodsi3 (nint32_t a, nint32_t b) +{ + return udivmodsi4 (a, b, 1); +} + +#endif diff --git a/libgcc/config/arc/t-arc b/libgcc/config/arc/t-arc index 3844fef..34aa444 100644 --- a/libgcc/config/arc/t-arc +++ b/libgcc/config/arc/t-arc @@ -43,6 +43,7 @@ LIB1ASMFUNCS = _mulsi3 _umulsidi3 _umulsi3_highpart _muldi3 \ # used in an asm wrapper. LIB2ADD = fp-bit.c dp-bit.c +LIB2ADD += $(srcdir)/config/arc/lib2funcs.c dp-bit.c: $(srcdir)/fp-bit.c echo '#ifndef __big_endian__' > dp-bit.c diff --git a/libgcc/config/arm/bpabi-v6m.S b/libgcc/config/arm/bpabi-v6m.S index 29fe8fa..1a403ef 100644 --- a/libgcc/config/arm/bpabi-v6m.S +++ b/libgcc/config/arm/bpabi-v6m.S @@ -39,21 +39,21 @@ FUNC_START aeabi_lcmp cmp xxh, yyh beq 1f bgt 2f - mov r0, #1 - neg r0, r0 + movs r0, #1 + negs r0, r0 RET 2: - mov r0, #1 + movs r0, #1 RET 1: - sub r0, xxl, yyl + subs r0, xxl, yyl beq 1f bhi 2f - mov r0, #1 - neg r0, r0 + movs r0, #1 + negs r0, r0 RET 2: - mov r0, #1 + movs r0, #1 1: RET FUNC_END aeabi_lcmp @@ -65,15 +65,15 @@ FUNC_START aeabi_lcmp FUNC_START aeabi_ulcmp cmp xxh, yyh bne 1f - sub r0, xxl, yyl + subs r0, xxl, yyl beq 2f 1: bcs 1f - mov r0, #1 - neg r0, r0 + movs r0, #1 + negs r0, r0 RET 1: - mov r0, #1 + movs r0, #1 2: RET FUNC_END aeabi_ulcmp @@ -91,29 +91,29 @@ FUNC_START aeabi_ulcmp cmp xxl, #0 2: beq 3f - mov xxh, #0 - mvn xxh, xxh @ 0xffffffff - mov xxl, xxh + movs xxh, #0 + mvns xxh, xxh @ 0xffffffff + movs xxl, xxh 3: .else blt 6f bgt 4f cmp xxl, #0 beq 5f -4: mov xxl, #0 - mvn xxl, xxl @ 0xffffffff - lsr xxh, xxl, #1 @ 0x7fffffff +4: movs xxl, #0 + mvns xxl, xxl @ 0xffffffff + lsrs xxh, xxl, #1 @ 0x7fffffff b 5f -6: mov xxh, #0x80 - lsl xxh, xxh, #24 @ 0x80000000 - mov xxl, #0 +6: movs xxh, #0x80 + lsls xxh, xxh, #24 @ 0x80000000 + movs xxl, #0 5: .endif @ tailcalls are tricky on v6-m. push {r0, r1, r2} ldr r0, 1f adr r1, 1f - add r0, r1 + adds r0, r1 str r0, [sp, #8] @ We know we are not on armv4t, so pop pc is safe. pop {r0, r1, pc} @@ -128,15 +128,15 @@ FUNC_START aeabi_ulcmp FUNC_START aeabi_ldivmod test_div_by_zero signed - push {r0, r1} - mov r0, sp - push {r0, lr} - ldr r0, [sp, #8] - bl SYM(__gnu_ldivmod_helper) - ldr r3, [sp, #4] - mov lr, r3 - add sp, sp, #8 - pop {r2, r3} + push {r0, r1} + mov r0, sp + push {r0, lr} + ldr r0, [sp, #8] + bl SYM(__gnu_ldivmod_helper) + ldr r3, [sp, #4] + mov lr, r3 + add sp, sp, #8 + pop {r2, r3} RET FUNC_END aeabi_ldivmod @@ -147,15 +147,15 @@ FUNC_START aeabi_ldivmod FUNC_START aeabi_uldivmod test_div_by_zero unsigned - push {r0, r1} - mov r0, sp - push {r0, lr} - ldr r0, [sp, #8] - bl SYM(__udivmoddi4) - ldr r3, [sp, #4] - mov lr, r3 - add sp, sp, #8 - pop {r2, r3} + push {r0, r1} + mov r0, sp + push {r0, lr} + ldr r0, [sp, #8] + bl SYM(__udivmoddi4) + ldr r3, [sp, #4] + mov lr, r3 + add sp, sp, #8 + pop {r2, r3} RET FUNC_END aeabi_uldivmod @@ -166,9 +166,9 @@ FUNC_START aeabi_uldivmod FUNC_START aeabi_frsub push {r4, lr} - mov r4, #1 - lsl r4, #31 - eor r0, r0, r4 + movs r4, #1 + lsls r4, #31 + eors r0, r0, r4 bl __aeabi_fadd pop {r4, pc} @@ -181,7 +181,7 @@ FUNC_START aeabi_frsub FUNC_START aeabi_cfrcmple mov ip, r0 - mov r0, r1 + movs r0, r1 mov r1, ip b 6f @@ -196,8 +196,8 @@ FUNC_ALIAS aeabi_cfcmple aeabi_cfcmpeq cmp r0, #0 @ Clear the C flag if the return value was -1, indicating @ that the first operand was smaller than the second. - bmi 1f - mov r1, #0 + bmi 1f + movs r1, #0 cmn r0, r1 1: pop {r0, r1, r2, r3, r4, pc} @@ -210,8 +210,8 @@ FUNC_START aeabi_fcmpeq push {r4, lr} bl __eqsf2 - neg r0, r0 - add r0, r0, #1 + negs r0, r0 + adds r0, r0, #1 pop {r4, pc} FUNC_END aeabi_fcmpeq @@ -223,10 +223,10 @@ FUNC_START aeabi_fcmp\cond bl __\helper\mode cmp r0, #0 b\cond 1f - mov r0, #0 + movs r0, #0 pop {r4, pc} 1: - mov r0, #1 + movs r0, #1 pop {r4, pc} FUNC_END aeabi_fcmp\cond @@ -244,9 +244,9 @@ COMPARISON ge, ge FUNC_START aeabi_drsub push {r4, lr} - mov r4, #1 - lsl r4, #31 - eor xxh, xxh, r4 + movs r4, #1 + lsls r4, #31 + eors xxh, xxh, r4 bl __aeabi_dadd pop {r4, pc} @@ -259,10 +259,10 @@ FUNC_START aeabi_drsub FUNC_START aeabi_cdrcmple mov ip, r0 - mov r0, r2 + movs r0, r2 mov r2, ip mov ip, r1 - mov r1, r3 + movs r1, r3 mov r3, ip b 6f @@ -277,8 +277,8 @@ FUNC_ALIAS aeabi_cdcmple aeabi_cdcmpeq cmp r0, #0 @ Clear the C flag if the return value was -1, indicating @ that the first operand was smaller than the second. - bmi 1f - mov r1, #0 + bmi 1f + movs r1, #0 cmn r0, r1 1: pop {r0, r1, r2, r3, r4, pc} @@ -291,8 +291,8 @@ FUNC_START aeabi_dcmpeq push {r4, lr} bl __eqdf2 - neg r0, r0 - add r0, r0, #1 + negs r0, r0 + adds r0, r0, #1 pop {r4, pc} FUNC_END aeabi_dcmpeq @@ -304,10 +304,10 @@ FUNC_START aeabi_dcmp\cond bl __\helper\mode cmp r0, #0 b\cond 1f - mov r0, #0 + movs r0, #0 pop {r4, pc} 1: - mov r0, #1 + movs r0, #1 pop {r4, pc} FUNC_END aeabi_dcmp\cond diff --git a/libgcc/config/arm/lib1funcs.S b/libgcc/config/arm/lib1funcs.S index e4b73ca..e8d2158 100644 --- a/libgcc/config/arm/lib1funcs.S +++ b/libgcc/config/arm/lib1funcs.S @@ -22,6 +22,10 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ +/* Everything in this file should now use unified syntax. */ + + .syntax unified + /* An executable stack is *not* required for these functions. */ #if defined(__ELF__) && defined(__linux__) .section .note.GNU-stack,"",%progbits @@ -270,7 +274,7 @@ LSYM(Lend_fde): #ifdef NOT_ISA_TARGET_32BIT push {r0, lr} - mov r0, #0 + movs r0, #0 bl SYM(__aeabi_idiv0) @ We know we are not on armv4t, so pop pc is safe. pop {r1, pc} @@ -310,7 +314,7 @@ LSYM(Lend_fde): push { r1, lr } 98: cfi_push 98b - __\name, 0xe, -0x4, 0x8 bl SYM (__div0) - mov r0, #0 @ About as wrong as it could be. + movs r0, #0 @ About as wrong as it could be. #if defined (__INTERWORKING__) pop { r1, r2 } bx r2 @@ -349,7 +353,7 @@ SYM (\name): #define THUMB_FUNC .thumb_func #define THUMB_CODE .force_thumb # if defined(__thumb2__) -#define THUMB_SYNTAX .syntax divided +#define THUMB_SYNTAX # else #define THUMB_SYNTAX # endif @@ -725,8 +729,8 @@ pc .req r15 /* ------------------------------------------------------------------------ */ .macro THUMB_DIV_MOD_BODY modulo @ Load the constant 0x10000000 into our work register. - mov work, #1 - lsl work, #28 + movs work, #1 + lsls work, #28 LSYM(Loop1): @ Unless the divisor is very big, shift it up in multiples of @ four bits, since this is the amount of unwinding in the main @@ -736,12 +740,12 @@ LSYM(Loop1): bhs LSYM(Lbignum) cmp divisor, dividend bhs LSYM(Lbignum) - lsl divisor, #4 - lsl curbit, #4 + lsls divisor, #4 + lsls curbit, #4 b LSYM(Loop1) LSYM(Lbignum): @ Set work to 0x80000000 - lsl work, #3 + lsls work, #3 LSYM(Loop2): @ For very big divisors, we must shift it a bit at a time, or @ we will be in danger of overflowing. @@ -749,8 +753,8 @@ LSYM(Loop2): bhs LSYM(Loop3) cmp divisor, dividend bhs LSYM(Loop3) - lsl divisor, #1 - lsl curbit, #1 + lsls divisor, #1 + lsls curbit, #1 b LSYM(Loop2) LSYM(Loop3): @ Test for possible subtractions ... @@ -758,39 +762,39 @@ LSYM(Loop3): @ ... On the final pass, this may subtract too much from the dividend, @ so keep track of which subtractions are done, we can fix them up @ afterwards. - mov overdone, #0 + movs overdone, #0 cmp dividend, divisor blo LSYM(Lover1) - sub dividend, dividend, divisor + subs dividend, dividend, divisor LSYM(Lover1): - lsr work, divisor, #1 + lsrs work, divisor, #1 cmp dividend, work blo LSYM(Lover2) - sub dividend, dividend, work + subs dividend, dividend, work mov ip, curbit - mov work, #1 - ror curbit, work - orr overdone, curbit + movs work, #1 + rors curbit, work + orrs overdone, curbit mov curbit, ip LSYM(Lover2): - lsr work, divisor, #2 + lsrs work, divisor, #2 cmp dividend, work blo LSYM(Lover3) - sub dividend, dividend, work + subs dividend, dividend, work mov ip, curbit - mov work, #2 - ror curbit, work - orr overdone, curbit + movs work, #2 + rors curbit, work + orrs overdone, curbit mov curbit, ip LSYM(Lover3): - lsr work, divisor, #3 + lsrs work, divisor, #3 cmp dividend, work blo LSYM(Lover4) - sub dividend, dividend, work + subs dividend, dividend, work mov ip, curbit - mov work, #3 - ror curbit, work - orr overdone, curbit + movs work, #3 + rors curbit, work + orrs overdone, curbit mov curbit, ip LSYM(Lover4): mov ip, curbit @@ -800,46 +804,46 @@ LSYM(Lover4): @ since the "bit" will have been shifted out at the bottom. cmp dividend, divisor blo LSYM(Lover1) - sub dividend, dividend, divisor - orr result, result, curbit + subs dividend, dividend, divisor + orrs result, result, curbit LSYM(Lover1): - lsr work, divisor, #1 + lsrs work, divisor, #1 cmp dividend, work blo LSYM(Lover2) - sub dividend, dividend, work - lsr work, curbit, #1 - orr result, work + subs dividend, dividend, work + lsrs work, curbit, #1 + orrs result, work LSYM(Lover2): - lsr work, divisor, #2 + lsrs work, divisor, #2 cmp dividend, work blo LSYM(Lover3) - sub dividend, dividend, work - lsr work, curbit, #2 - orr result, work + subs dividend, dividend, work + lsrs work, curbit, #2 + orrs result, work LSYM(Lover3): - lsr work, divisor, #3 + lsrs work, divisor, #3 cmp dividend, work blo LSYM(Lover4) - sub dividend, dividend, work - lsr work, curbit, #3 - orr result, work + subs dividend, dividend, work + lsrs work, curbit, #3 + orrs result, work LSYM(Lover4): .endif cmp dividend, #0 @ Early termination? beq LSYM(Lover5) - lsr curbit, #4 @ No, any more bits to do? + lsrs curbit, #4 @ No, any more bits to do? beq LSYM(Lover5) - lsr divisor, #4 + lsrs divisor, #4 b LSYM(Loop3) LSYM(Lover5): .if \modulo @ Any subtractions that we should not have done will be recorded in @ the top three bits of "overdone". Exactly which were not needed @ are governed by the position of the bit, stored in ip. - mov work, #0xe - lsl work, #28 - and overdone, work + movs work, #0xe + lsls work, #28 + ands overdone, work beq LSYM(Lgot_result) @ If we terminated early, because dividend became zero, then the @@ -849,33 +853,33 @@ LSYM(Lover5): @ the bit in ip could be in the top two bits which might then match @ with one of the smaller RORs. mov curbit, ip - mov work, #0x7 + movs work, #0x7 tst curbit, work beq LSYM(Lgot_result) mov curbit, ip - mov work, #3 - ror curbit, work + movs work, #3 + rors curbit, work tst overdone, curbit beq LSYM(Lover6) - lsr work, divisor, #3 - add dividend, work + lsrs work, divisor, #3 + adds dividend, work LSYM(Lover6): mov curbit, ip - mov work, #2 - ror curbit, work + movs work, #2 + rors curbit, work tst overdone, curbit beq LSYM(Lover7) - lsr work, divisor, #2 - add dividend, work + lsrs work, divisor, #2 + adds dividend, work LSYM(Lover7): mov curbit, ip - mov work, #1 - ror curbit, work + movs work, #1 + rors curbit, work tst overdone, curbit beq LSYM(Lgot_result) - lsr work, divisor, #1 - add dividend, work + lsrs work, divisor, #1 + adds dividend, work .endif LSYM(Lgot_result): .endm @@ -885,7 +889,7 @@ LSYM(Lgot_result): /* Branch to div(n), and jump to label if curbit is lo than divisior. */ .macro BranchToDiv n, label - lsr curbit, dividend, \n + lsrs curbit, dividend, \n cmp curbit, divisor blo \label .endm @@ -893,13 +897,13 @@ LSYM(Lgot_result): /* Body of div(n). Shift the divisor in n bits and compare the divisor and dividend. Update the dividend as the substruction result. */ .macro DoDiv n - lsr curbit, dividend, \n + lsrs curbit, dividend, \n cmp curbit, divisor bcc 1f - lsl curbit, divisor, \n - sub dividend, dividend, curbit + lsls curbit, divisor, \n + subs dividend, dividend, curbit -1: adc result, result +1: adcs result, result .endm /* The body of division with positive divisor. Unless the divisor is very @@ -907,29 +911,29 @@ LSYM(Lgot_result): unwinding in the main division loop. Continue shifting until the divisor is larger than the dividend. */ .macro THUMB1_Div_Positive - mov result, #0 + movs result, #0 BranchToDiv #1, LSYM(Lthumb1_div1) BranchToDiv #4, LSYM(Lthumb1_div4) BranchToDiv #8, LSYM(Lthumb1_div8) BranchToDiv #12, LSYM(Lthumb1_div12) BranchToDiv #16, LSYM(Lthumb1_div16) LSYM(Lthumb1_div_large_positive): - mov result, #0xff - lsl divisor, divisor, #8 + movs result, #0xff + lsls divisor, divisor, #8 rev result, result - lsr curbit, dividend, #16 + lsrs curbit, dividend, #16 cmp curbit, divisor blo 1f - asr result, #8 - lsl divisor, divisor, #8 + asrs result, #8 + lsls divisor, divisor, #8 beq LSYM(Ldivbyzero_waypoint) -1: lsr curbit, dividend, #12 +1: lsrs curbit, dividend, #12 cmp curbit, divisor blo LSYM(Lthumb1_div12) b LSYM(Lthumb1_div16) LSYM(Lthumb1_div_loop): - lsr divisor, divisor, #8 + lsrs divisor, divisor, #8 LSYM(Lthumb1_div16): Dodiv #15 Dodiv #14 @@ -954,11 +958,11 @@ LSYM(Lthumb1_div3): LSYM(Lthumb1_div2): Dodiv #1 LSYM(Lthumb1_div1): - sub divisor, dividend, divisor + subs divisor, dividend, divisor bcs 1f cpy divisor, dividend -1: adc result, result +1: adcs result, result cpy dividend, result RET @@ -970,43 +974,43 @@ LSYM(Ldivbyzero_waypoint): THUMB1_Div_Positive except that the shift steps are in multiples of six bits. */ .macro THUMB1_Div_Negative - lsr result, divisor, #31 + lsrs result, divisor, #31 beq 1f - neg divisor, divisor + negs divisor, divisor -1: asr curbit, dividend, #32 +1: asrs curbit, dividend, #32 bcc 2f - neg dividend, dividend + negs dividend, dividend -2: eor curbit, result - mov result, #0 +2: eors curbit, result + movs result, #0 cpy ip, curbit BranchToDiv #4, LSYM(Lthumb1_div_negative4) BranchToDiv #8, LSYM(Lthumb1_div_negative8) LSYM(Lthumb1_div_large): - mov result, #0xfc - lsl divisor, divisor, #6 + movs result, #0xfc + lsls divisor, divisor, #6 rev result, result - lsr curbit, dividend, #8 + lsrs curbit, dividend, #8 cmp curbit, divisor blo LSYM(Lthumb1_div_negative8) - lsl divisor, divisor, #6 - asr result, result, #6 + lsls divisor, divisor, #6 + asrs result, result, #6 cmp curbit, divisor blo LSYM(Lthumb1_div_negative8) - lsl divisor, divisor, #6 - asr result, result, #6 + lsls divisor, divisor, #6 + asrs result, result, #6 cmp curbit, divisor blo LSYM(Lthumb1_div_negative8) - lsl divisor, divisor, #6 + lsls divisor, divisor, #6 beq LSYM(Ldivbyzero_negative) - asr result, result, #6 + asrs result, result, #6 b LSYM(Lthumb1_div_negative8) LSYM(Lthumb1_div_negative_loop): - lsr divisor, divisor, #6 + lsrs divisor, divisor, #6 LSYM(Lthumb1_div_negative8): DoDiv #7 DoDiv #6 @@ -1017,28 +1021,28 @@ LSYM(Lthumb1_div_negative4): DoDiv #2 bcs LSYM(Lthumb1_div_negative_loop) DoDiv #1 - sub divisor, dividend, divisor + subs divisor, dividend, divisor bcs 1f cpy divisor, dividend 1: cpy curbit, ip - adc result, result - asr curbit, curbit, #1 + adcs result, result + asrs curbit, curbit, #1 cpy dividend, result bcc 2f - neg dividend, dividend + negs dividend, dividend cmp curbit, #0 2: bpl 3f - neg divisor, divisor + negs divisor, divisor 3: RET LSYM(Ldivbyzero_negative): cpy curbit, ip - asr curbit, curbit, #1 + asrs curbit, curbit, #1 bcc LSYM(Ldiv0) - neg dividend, dividend + negs dividend, dividend .endm #endif /* ARM Thumb version. */ @@ -1056,8 +1060,8 @@ LSYM(Ldivbyzero_negative): cmp divisor, #0 beq LSYM(Ldiv0) LSYM(udivsi3_skip_div0_test): - mov curbit, #1 - mov result, #0 + movs curbit, #1 + movs result, #0 push { work } cmp dividend, divisor @@ -1065,7 +1069,7 @@ LSYM(udivsi3_skip_div0_test): THUMB_DIV_MOD_BODY 0 - mov r0, result + movs r0, result pop { work } RET @@ -1184,7 +1188,7 @@ ARM_FUNC_START aeabi_uidivmod cmp divisor, #0 beq LSYM(Ldiv0) - mov curbit, #1 + movs curbit, #1 cmp dividend, divisor bhs LSYM(Lover10) RET @@ -1263,7 +1267,7 @@ LSYM(Lover12): #else LSYM(divsi3_skip_div0_test): cpy curbit, dividend - orr curbit, divisor + orrs curbit, divisor bmi LSYM(Lthumb1_div_negative) LSYM(Lthumb1_div_positive): @@ -1395,11 +1399,11 @@ ARM_FUNC_START aeabi_idivmod FUNC_START modsi3 - mov curbit, #1 + movs curbit, #1 cmp divisor, #0 beq LSYM(Ldiv0) bpl LSYM(Lover10) - neg divisor, divisor @ Loops below use unsigned. + negs divisor, divisor @ Loops below use unsigned. LSYM(Lover10): push { work } @ Need to save the sign of the dividend, unfortunately, we need @@ -1408,7 +1412,7 @@ LSYM(Lover10): push { dividend } cmp dividend, #0 bpl LSYM(Lover11) - neg dividend, dividend + negs dividend, dividend LSYM(Lover11): cmp dividend, divisor blo LSYM(Lgot_result) @@ -1418,7 +1422,7 @@ LSYM(Lover11): pop { work } cmp work, #0 bpl LSYM(Lover12) - neg dividend, dividend + negs dividend, dividend LSYM(Lover12): pop { work } RET @@ -1540,12 +1544,12 @@ LSYM(Lover12): address, so just clear pc..pc+1. */ #if defined __thumb__ && !defined __thumb2__ push {r7} - mov r7, #0xf - lsl r7, #16 - add r7, #2 + movs r7, #0xf + lsls r7, #16 + adds r7, #2 adr r0, . + 4 - add r1, r0, #1 - mov r2, #0 + adds r1, r0, #1 + movs r2, #0 svc 0 pop {r7} #else @@ -1595,17 +1599,17 @@ LSYM(Lover12): FUNC_ALIAS aeabi_llsr lshrdi3 #ifdef __thumb__ - lsr al, r2 - mov r3, ah - lsr ah, r2 + lsrs al, r2 + movs r3, ah + lsrs ah, r2 mov ip, r3 - sub r2, #32 - lsr r3, r2 - orr al, r3 - neg r2, r2 + subs r2, #32 + lsrs r3, r2 + orrs al, r3 + negs r2, r2 mov r3, ip - lsl r3, r2 - orr al, r3 + lsls r3, r2 + orrs al, r3 RET #else subs r3, r2, #32 @@ -1627,21 +1631,21 @@ LSYM(Lover12): FUNC_ALIAS aeabi_lasr ashrdi3 #ifdef __thumb__ - lsr al, r2 - mov r3, ah - asr ah, r2 - sub r2, #32 + lsrs al, r2 + movs r3, ah + asrs ah, r2 + subs r2, #32 @ If r2 is negative at this point the following step would OR @ the sign bit into all of AL. That's not what we want... bmi 1f mov ip, r3 - asr r3, r2 - orr al, r3 + asrs r3, r2 + orrs al, r3 mov r3, ip 1: - neg r2, r2 - lsl r3, r2 - orr al, r3 + negs r2, r2 + lsls r3, r2 + orrs al, r3 RET #else subs r3, r2, #32 @@ -1664,17 +1668,17 @@ LSYM(Lover12): FUNC_ALIAS aeabi_llsl ashldi3 #ifdef __thumb__ - lsl ah, r2 - mov r3, al - lsl al, r2 + lsls ah, r2 + movs r3, al + lsls al, r2 mov ip, r3 - sub r2, #32 - lsl r3, r2 - orr ah, r3 - neg r2, r2 + subs r2, #32 + lsls r3, r2 + orrs ah, r3 + negs r2, r2 mov r3, ip - lsr r3, r2 - orr ah, r3 + lsrs r3, r2 + orrs ah, r3 RET #else subs r3, r2, #32 @@ -1695,26 +1699,26 @@ LSYM(Lover12): #ifdef L_clzsi2 #ifdef NOT_ISA_TARGET_32BIT FUNC_START clzsi2 - mov r1, #28 - mov r3, #1 - lsl r3, r3, #16 + movs r1, #28 + movs r3, #1 + lsls r3, r3, #16 cmp r0, r3 /* 0x10000 */ bcc 2f - lsr r0, r0, #16 - sub r1, r1, #16 -2: lsr r3, r3, #8 + lsrs r0, r0, #16 + subs r1, r1, #16 +2: lsrs r3, r3, #8 cmp r0, r3 /* #0x100 */ bcc 2f - lsr r0, r0, #8 - sub r1, r1, #8 -2: lsr r3, r3, #4 + lsrs r0, r0, #8 + subs r1, r1, #8 +2: lsrs r3, r3, #4 cmp r0, r3 /* #0x10 */ bcc 2f - lsr r0, r0, #4 - sub r1, r1, #4 + lsrs r0, r0, #4 + subs r1, r1, #4 2: adr r2, 1f ldrb r0, [r2, r0] - add r0, r0, r1 + adds r0, r0, r1 bx lr .align 2 1: @@ -1757,34 +1761,49 @@ ARM_FUNC_START clzsi2 # ifdef NOT_ISA_TARGET_32BIT FUNC_START clzdi2 push {r4, lr} -# else + cmp xxh, #0 + bne 1f +# ifdef __ARMEB__ + movs r0, xxl + bl __clzsi2 + adds r0, r0, #32 + b 2f +1: + bl __clzsi2 +# else + bl __clzsi2 + adds r0, r0, #32 + b 2f +1: + movs r0, xxh + bl __clzsi2 +# endif +2: + pop {r4, pc} +# else /* NOT_ISA_TARGET_32BIT */ ARM_FUNC_START clzdi2 do_push {r4, lr} -# endif cmp xxh, #0 bne 1f -# ifdef __ARMEB__ +# ifdef __ARMEB__ mov r0, xxl bl __clzsi2 add r0, r0, #32 b 2f 1: bl __clzsi2 -# else +# else bl __clzsi2 add r0, r0, #32 b 2f 1: mov r0, xxh bl __clzsi2 -# endif +# endif 2: -# ifdef NOT_ISA_TARGET_32BIT - pop {r4, pc} -# else RETLDM r4 -# endif FUNC_END clzdi2 +# endif /* NOT_ISA_TARGET_32BIT */ #else /* defined (__ARM_FEATURE_CLZ) */ @@ -1803,28 +1822,28 @@ ARM_FUNC_START clzdi2 #ifdef L_ctzsi2 #ifdef NOT_ISA_TARGET_32BIT FUNC_START ctzsi2 - neg r1, r0 - and r0, r0, r1 - mov r1, #28 - mov r3, #1 - lsl r3, r3, #16 + negs r1, r0 + ands r0, r0, r1 + movs r1, #28 + movs r3, #1 + lsls r3, r3, #16 cmp r0, r3 /* 0x10000 */ bcc 2f - lsr r0, r0, #16 - sub r1, r1, #16 -2: lsr r3, r3, #8 + lsrs r0, r0, #16 + subs r1, r1, #16 +2: lsrs r3, r3, #8 cmp r0, r3 /* #0x100 */ bcc 2f - lsr r0, r0, #8 - sub r1, r1, #8 -2: lsr r3, r3, #4 + lsrs r0, r0, #8 + subs r1, r1, #8 +2: lsrs r3, r3, #4 cmp r0, r3 /* #0x10 */ bcc 2f - lsr r0, r0, #4 - sub r1, r1, #4 + lsrs r0, r0, #4 + subs r1, r1, #4 2: adr r2, 1f ldrb r0, [r2, r0] - sub r0, r0, r1 + subs r0, r0, r1 bx lr .align 2 1: diff --git a/libgcc/config/arm/libunwind.S b/libgcc/config/arm/libunwind.S index 176ba5e..08e0fcc 100644 --- a/libgcc/config/arm/libunwind.S +++ b/libgcc/config/arm/libunwind.S @@ -63,28 +63,28 @@ /* r0 points to a 16-word block. Upload these values to the actual core state. */ FUNC_START restore_core_regs - mov r1, r0 - add r1, r1, #52 - ldmia r1!, {r3, r4, r5} - sub r3, r3, #4 - mov ip, r3 - str r5, [r3] - mov lr, r4 + movs r1, r0 + adds r1, r1, #52 + ldmia r1!, {r3, r4, r5} + subs r3, r3, #4 + mov ip, r3 + str r5, [r3] + mov lr, r4 /* Restore r8-r11. */ - mov r1, r0 - add r1, r1, #32 - ldmia r1!, {r2, r3, r4, r5} - mov r8, r2 - mov r9, r3 - mov sl, r4 - mov fp, r5 - mov r1, r0 - add r1, r1, #8 - ldmia r1!, {r2, r3, r4, r5, r6, r7} - ldr r1, [r0, #4] - ldr r0, [r0] - mov sp, ip - pop {pc} + movs r1, r0 + adds r1, r1, #32 + ldmia r1!, {r2, r3, r4, r5} + mov r8, r2 + mov r9, r3 + mov sl, r4 + mov fp, r5 + movs r1, r0 + adds r1, r1, #8 + ldmia r1!, {r2, r3, r4, r5, r6, r7} + ldr r1, [r0, #4] + ldr r0, [r0] + mov sp, ip + pop {pc} FUNC_END restore_core_regs UNPREFIX restore_core_regs @@ -132,38 +132,38 @@ FUNC_START gnu_Unwind_Save_WMMXC FUNC_START \name /* Create a phase2_vrs structure. */ /* Save r0 in the PC slot so we can use it as a scratch register. */ - push {r0} - add r0, sp, #4 - push {r0, lr} /* Push original SP and LR. */ + push {r0} + add r0, sp, #4 + push {r0, lr} /* Push original SP and LR. */ /* Make space for r8-r12. */ - sub sp, sp, #20 + sub sp, sp, #20 /* Save low registers. */ - push {r0, r1, r2, r3, r4, r5, r6, r7} + push {r0, r1, r2, r3, r4, r5, r6, r7} /* Save high registers. */ - add r0, sp, #32 - mov r1, r8 - mov r2, r9 - mov r3, sl - mov r4, fp - mov r5, ip - stmia r0!, {r1, r2, r3, r4, r5} + add r0, sp, #32 + mov r1, r8 + mov r2, r9 + mov r3, sl + mov r4, fp + mov r5, ip + stmia r0!, {r1, r2, r3, r4, r5} /* Restore original low register values. */ - add r0, sp, #4 - ldmia r0!, {r1, r2, r3, r4, r5} + add r0, sp, #4 + ldmia r0!, {r1, r2, r3, r4, r5} /* Restore orginial r0. */ - ldr r0, [sp, #60] - str r0, [sp] + ldr r0, [sp, #60] + str r0, [sp] /* Demand-save flags, plus an extra word for alignment. */ - mov r3, #0 - push {r2, r3} + movs r3, #0 + push {r2, r3} /* Point r1 at the block. Pass r[0..nargs) unchanged. */ - add r\nargs, sp, #4 + add r\nargs, sp, #4 - bl SYM (__gnu\name) + bl SYM (__gnu\name) - ldr r3, [sp, #64] - add sp, sp, #72 - bx r3 + ldr r3, [sp, #64] + add sp, sp, #72 + bx r3 FUNC_END \name UNPREFIX \name diff --git a/libgcc/config/arm/unwind-arm.h b/libgcc/config/arm/unwind-arm.h index 1c82855..e77b769 100644 --- a/libgcc/config/arm/unwind-arm.h +++ b/libgcc/config/arm/unwind-arm.h @@ -43,19 +43,15 @@ extern "C" { #endif _Unwind_Ptr __attribute__((weak)) __gnu_Unwind_Find_got (_Unwind_Ptr); -static inline _Unwind_Ptr gnu_Unwind_Find_got (_Unwind_Ptr ptr) +static inline _Unwind_Ptr _Unwind_gnu_Find_got (_Unwind_Ptr ptr) { _Unwind_Ptr res; if (__gnu_Unwind_Find_got) - res = __gnu_Unwind_Find_got (ptr); + res = __gnu_Unwind_Find_got (ptr); else - { - asm volatile ("mov %[result], r" XSTR(FDPIC_REGNUM) - : [result]"=r" (res) - : - :); - } + __asm volatile ("mov %[result], r" XSTR(FDPIC_REGNUM) + : [result] "=r" (res)); return res; } @@ -75,7 +71,7 @@ static inline _Unwind_Ptr gnu_Unwind_Find_got (_Unwind_Ptr ptr) #if __FDPIC__ /* For FDPIC, we store the offset of the GOT entry. */ /* So, first get GOT from dynamic linker and then use indirect access. */ - tmp += gnu_Unwind_Find_got (ptr); + tmp += _Unwind_gnu_Find_got (ptr); tmp = *(_Unwind_Word *) tmp; #elif (defined(linux) && !defined(__uClinux__)) || defined(__NetBSD__) \ || defined(__FreeBSD__) || defined(__fuchsia__) diff --git a/libgcc/config/frv/frvbegin.c b/libgcc/config/frv/frvbegin.c index 8ab1a1b..0f54bf1 100644 --- a/libgcc/config/frv/frvbegin.c +++ b/libgcc/config/frv/frvbegin.c @@ -59,8 +59,8 @@ __asm__ (".section " SECTION "," FLAGS "\n\t" \ /* Beginning of .ctor/.dtor sections that provides a list of constructors and destructors to run. */ -INIT_SECTION_NEG_ONE (".ctors", "\"aw\"", "__CTOR_LIST__"); -INIT_SECTION_NEG_ONE (".dtors", "\"aw\"", "__DTOR_LIST__"); +INIT_SECTION_NEG_ONE (".ctors", "\"a\"", "__CTOR_LIST__"); +INIT_SECTION_NEG_ONE (".dtors", "\"a\"", "__DTOR_LIST__"); /* Beginning of .eh_frame section that provides all of the exception handling tables. */ diff --git a/libgcc/config/frv/frvend.c b/libgcc/config/frv/frvend.c index eb3494c..d2b83b2 100644 --- a/libgcc/config/frv/frvend.c +++ b/libgcc/config/frv/frvend.c @@ -52,8 +52,8 @@ __asm__ (".section " SECTION "," FLAGS "\n\t" \ /* End of .ctor/.dtor sections that provides a list of constructors and destructors to run. */ -FINI_SECTION_ZERO (".ctors", "\"aw\"", "__CTOR_END__"); -FINI_SECTION_ZERO (".dtors", "\"aw\"", "__DTOR_END__"); +FINI_SECTION_ZERO (".ctors", "\"a\"", "__CTOR_END__"); +FINI_SECTION_ZERO (".dtors", "\"a\"", "__DTOR_END__"); /* End of .eh_frame section that provides all of the exception handling tables. */ diff --git a/libgcc/config/i386/shadow-stack-unwind.h b/libgcc/config/i386/shadow-stack-unwind.h index a0244d2e..201b2153 100644 --- a/libgcc/config/i386/shadow-stack-unwind.h +++ b/libgcc/config/i386/shadow-stack-unwind.h @@ -49,3 +49,46 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see } \ } \ while (0) + +/* Linux CET kernel places a restore token on shadow stack for signal + handler to enhance security. The restore token is 8 byte and aligned + to 8 bytes. It is usually transparent to user programs since kernel + will pop the restore token when signal handler returns. But when an + exception is thrown from a signal handler, now we need to pop the + restore token from shadow stack. For x86-64, we just need to treat + the signal frame as normal frame. For i386, we need to search for + the restore token to check if the original shadow stack is 8 byte + aligned. If the original shadow stack is 8 byte aligned, we just + need to pop 2 slots, one restore token, from shadow stack. Otherwise, + we need to pop 3 slots, one restore token + 4 byte padding, from + shadow stack. */ +#ifndef __x86_64__ +#undef _Unwind_Frames_Increment +#define _Unwind_Frames_Increment(context, frames) \ + if (_Unwind_IsSignalFrame (context)) \ + do \ + { \ + _Unwind_Word ssp, prev_ssp, token; \ + ssp = _get_ssp (); \ + if (ssp != 0) \ + { \ + /* Align shadow stack pointer to the next \ + 8 byte aligned boundary. */ \ + ssp = (ssp + 4) & ~7; \ + do \ + { \ + /* Look for a restore token. */ \ + token = (*(_Unwind_Word *) (ssp - 8)); \ + prev_ssp = token & ~7; \ + if (prev_ssp == ssp) \ + break; \ + ssp += 8; \ + } \ + while (1); \ + frames += (token & 0x4) ? 3 : 2; \ + } \ + } \ + while (0); \ + else \ + frames++; +#endif diff --git a/libgcc/config/mips/crti.S b/libgcc/config/mips/crti.S index 3347a78..6705642 100644 --- a/libgcc/config/mips/crti.S +++ b/libgcc/config/mips/crti.S @@ -21,6 +21,9 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ +/* An executable stack is *not* required for these functions. */ +#include "gnustack.h" + /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack. Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */ diff --git a/libgcc/config/mips/crtn.S b/libgcc/config/mips/crtn.S index 7f46829..ceede64 100644 --- a/libgcc/config/mips/crtn.S +++ b/libgcc/config/mips/crtn.S @@ -21,6 +21,9 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ +/* An executable stack is *not* required for these functions. */ +#include "gnustack.h" + /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack. Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */ diff --git a/libgcc/config/mips/gnustack.h b/libgcc/config/mips/gnustack.h new file mode 100644 index 0000000..561b348 --- /dev/null +++ b/libgcc/config/mips/gnustack.h @@ -0,0 +1,7 @@ +#include "config.h" +#if defined(__ELF__) && defined(__linux__) +#if defined (TARGET_LIBC_GNUSTACK) || defined (__mips_soft_float) + .section .note.GNU-stack,"",%progbits + .previous +#endif +#endif diff --git a/libgcc/config/mips/mips16.S b/libgcc/config/mips/mips16.S index 396285e..5c3678b 100644 --- a/libgcc/config/mips/mips16.S +++ b/libgcc/config/mips/mips16.S @@ -21,6 +21,9 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ +/* An executable stack is *not* required for these functions. */ +#include "gnustack.h" + #include "auto-host.h" #if defined(__mips_micromips) || defined(__mips_soft_float) \ diff --git a/libgcc/config/mips/vr4120-div.S b/libgcc/config/mips/vr4120-div.S index 92226b5..2999c77 100644 --- a/libgcc/config/mips/vr4120-div.S +++ b/libgcc/config/mips/vr4120-div.S @@ -22,6 +22,9 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ +/* An executable stack is *not* required for these functions. */ +#include "gnustack.h" + /* This file contains functions which implement divsi3 and modsi3 for -mfix-vr4120. div and ddiv do not give the correct result when one of the operands is negative. */ diff --git a/libgcc/config/nios2/elf-lib.h b/libgcc/config/nios2/elf-lib.h new file mode 100644 index 0000000..4d718d9 --- /dev/null +++ b/libgcc/config/nios2/elf-lib.h @@ -0,0 +1,24 @@ +/* Target macros for the Nios II port of GCC. + Copyright (C) 2015-2020 Free Software Foundation, Inc. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +#define CRT_GET_RFIB_DATA(dbase) \ + ({ extern void *_gp_got; (dbase) = &_gp_got; }) diff --git a/libgcc/config/s390/t-tpf b/libgcc/config/s390/t-tpf new file mode 100644 index 0000000..50da223 --- /dev/null +++ b/libgcc/config/s390/t-tpf @@ -0,0 +1,7 @@ +DFP_ENABLE = true + +# Override t-slibgcc-elf-ver to export some libgcc symbols with +# the symbol versions that glibc used. +SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/s390/libgcc-glibc.ver + +HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mtpf-trace-skip diff --git a/libgcc/configure b/libgcc/configure index 97cbad3..093036a 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -705,6 +705,7 @@ enable_gcov enable_vtable_verify with_aix_soname enable_version_specific_runtime_libs +with_toolexeclibdir with_slibdir enable_maintainer_mode with_build_libsubdir @@ -1369,6 +1370,9 @@ Optional Packages: --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX + --with-toolexeclibdir=DIR + install libraries built with a cross compiler within + DIR --with-slibdir=DIR shared libraries in DIR LIBDIR --with-build-libsubdir=DIR Directory where to find libraries for build system --with-system-libunwind use installed libunwind @@ -2464,6 +2468,22 @@ fi $as_echo "$version_specific_libs" >&6; } +# Check whether --with-toolexeclibdir was given. +if test "${with_toolexeclibdir+set}" = set; then : + withval=$with_toolexeclibdir; case ${with_toolexeclibdir} in + /) + ;; + */) + with_toolexeclibdir=`echo $with_toolexeclibdir | sed 's,/$,,'` + ;; +esac +else + with_toolexeclibdir=no +fi + + + + # Check whether --with-slibdir was given. if test "${with_slibdir+set}" = set; then : withval=$with_slibdir; slibdir="$with_slibdir" @@ -2471,7 +2491,14 @@ else if test "${version_specific_libs}" = yes; then slibdir='$(libsubdir)' elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then - slibdir='$(exec_prefix)/$(host_noncanonical)/lib' + case ${with_toolexeclibdir} in + no) + slibdir='$(exec_prefix)/$(host_noncanonical)/lib' + ;; + *) + slibdir=${with_toolexeclibdir} + ;; + esac else slibdir='$(libdir)' fi @@ -2701,7 +2728,14 @@ case ${version_specific_libs} in test x"$with_cross_host" != x"no"; then # Install a library built with a cross compiler in tooldir, not libdir. toolexecdir='$(exec_prefix)/$(target_noncanonical)' - toolexeclibdir='$(toolexecdir)/lib' + case ${with_toolexeclibdir} in + no) + toolexeclibdir='$(toolexecdir)/lib' + ;; + *) + toolexeclibdir=${with_toolexeclibdir} + ;; + esac else toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)' toolexeclibdir='$(libdir)' @@ -3519,11 +3553,11 @@ done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - +#include <stdio.h> int main () { - +printf ("hello world\n"); ; return 0; } diff --git a/libgcc/configure.ac b/libgcc/configure.ac index 2d22f05..85979da9 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -2,6 +2,7 @@ dnl Process this file with autoconf to produce a configure script. sinclude(../config/enable.m4) sinclude(../config/tls.m4) +sinclude(../config/toolexeclibdir.m4) sinclude(../config/acx.m4) sinclude(../config/no-executables.m4) sinclude(../config/lib-ld.m4) @@ -113,16 +114,25 @@ AC_ARG_ENABLE(version-specific-runtime-libs, [version_specific_libs=no]) AC_MSG_RESULT($version_specific_libs) +GCC_WITH_TOOLEXECLIBDIR + AC_ARG_WITH(slibdir, [ --with-slibdir=DIR shared libraries in DIR [LIBDIR]], slibdir="$with_slibdir", -if test "${version_specific_libs}" = yes; then +[if test "${version_specific_libs}" = yes; then slibdir='$(libsubdir)' elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then - slibdir='$(exec_prefix)/$(host_noncanonical)/lib' + case ${with_toolexeclibdir} in + no) + slibdir='$(exec_prefix)/$(host_noncanonical)/lib' + ;; + *) + slibdir=${with_toolexeclibdir} + ;; + esac else slibdir='$(libdir)' -fi) +fi]) AC_SUBST(slibdir) # Command-line options. @@ -168,7 +178,14 @@ case ${version_specific_libs} in test x"$with_cross_host" != x"no"; then # Install a library built with a cross compiler in tooldir, not libdir. toolexecdir='$(exec_prefix)/$(target_noncanonical)' - toolexeclibdir='$(toolexecdir)/lib' + case ${with_toolexeclibdir} in + no) + toolexeclibdir='$(toolexecdir)/lib' + ;; + *) + toolexeclibdir=${with_toolexeclibdir} + ;; + esac else toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)' toolexeclibdir='$(libdir)' diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c index cdb611d..fb32073 100644 --- a/libgcc/libgcov-driver.c +++ b/libgcc/libgcov-driver.c @@ -219,17 +219,12 @@ static struct gcov_fn_buffer *fn_buffer; static void prune_topn_counter (gcov_type *counters, gcov_type all) { - if (counters[1] == -1) - return; - for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++) - { - if (counters[2 * i + 1] < all) - { - counters[2 * i] = 0; - counters[2 * i + 1] = 0; - } - } + if (counters[2 * i + 1] < all) + { + counters[2 * i] = 0; + counters[2 * i + 1] = 0; + } } /* Prune counters so that they are ready to store or merge. */ diff --git a/libgcc/libgcov-interface.c b/libgcc/libgcov-interface.c index 49b44d5..048b902 100644 --- a/libgcc/libgcov-interface.c +++ b/libgcc/libgcov-interface.c @@ -52,7 +52,6 @@ void __gcov_dump (void) {} { src (); } extern __gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN; -extern __gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN; #ifdef L_gcov_flush #ifdef __GTHREAD_MUTEX_INIT diff --git a/libgcc/libgcov-merge.c b/libgcc/libgcov-merge.c index b658aec..c0785b0 100644 --- a/libgcc/libgcov-merge.c +++ b/libgcc/libgcov-merge.c @@ -86,35 +86,48 @@ __gcov_merge_time_profile (gcov_type *counters, unsigned n_counters) #ifdef L_gcov_merge_topn +/* To merging of TOPN profiles. + counters[0] is the number of executions + for i in 0 ... TOPN-1 + counters[2 * i + 1] is target + counters[2 * i + 2] is corresponding hitrate counter. + + Because we prune counters only those with probability >= 1/TOPN are + present now. + + We use sign of counters[0] to track whether the number of different + targets exceeds TOPN. */ + static void merge_topn_values_set (gcov_type *counters) { /* First value is number of total executions of the profiler. */ - gcov_type all = gcov_get_counter_ignore_scaling (-1); - counters[0] += all; + gcov_type all = gcov_get_counter (); + gcov_type *total = &counters[0]; ++counters; + /* Negative value means that counter is missing some of values. */ + if (all < 0) + *total = -(*total); + + *total += all; + /* Read all part values. */ gcov_type read_counters[2 * GCOV_TOPN_VALUES]; - for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++) { read_counters[2 * i] = gcov_get_counter_target (); read_counters[2 * i + 1] = gcov_get_counter_ignore_scaling (-1); } - if (read_counters[1] == -1) - { - counters[1] = -1; - return; - } - for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++) { if (read_counters[2 * i + 1] == 0) - return; + continue; unsigned j; + int slot = 0; + for (j = 0; j < GCOV_TOPN_VALUES; j++) { if (counters[2 * j] == read_counters[2 * i]) @@ -122,19 +135,33 @@ merge_topn_values_set (gcov_type *counters) counters[2 * j + 1] += read_counters[2 * i + 1]; break; } - else if (counters[2 * j + 1] == 0) - { - counters[2 * j] += read_counters[2 * i]; - counters[2 * j + 1] += read_counters[2 * i + 1]; - break; - } + else if (counters[2 * j + 1] < counters[2 * slot + 1]) + slot = j; } - /* We haven't found a slot, bail out. */ if (j == GCOV_TOPN_VALUES) { - counters[1] = -1; - return; + gcov_type slot_count = counters[2 * slot + 1]; + /* We found an empty slot. */ + if (slot_count == 0) + { + /* If we found empty slot, add the value. */ + counters[2 * slot] = read_counters[2 * i]; + counters[2 * slot + 1] = read_counters[2 * i + 1]; + } + else + { + /* Here we are loosing some values. */ + if (*total >= 0) + *total = -(*total); + if (read_counters[2 * i + 1] > slot_count) + { + counters[2 * slot] = read_counters[2 * i]; + counters[2 * slot + 1] = read_counters[2 * i + 1]; + } + else + counters[2 * slot + 1] -= read_counters[2 * i + 1]; + } } } } diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c index 58784d1..6043ac4 100644 --- a/libgcc/libgcov-profiler.c +++ b/libgcc/libgcov-profiler.c @@ -199,8 +199,9 @@ struct indirect_call_tuple __gcov_indirect_call; as a pointer to a function. */ /* Tries to determine the most common value among its inputs. */ -void -__gcov_indirect_call_profiler_v4 (gcov_type value, void* cur_func) +static inline void +__gcov_indirect_call_profiler_body (gcov_type value, void *cur_func, + int use_atomic) { /* If the C++ virtual tables contain function descriptors then one function may have multiple descriptors and we need to dereference @@ -208,10 +209,26 @@ __gcov_indirect_call_profiler_v4 (gcov_type value, void* cur_func) if (cur_func == __gcov_indirect_call.callee || (__LIBGCC_VTABLE_USES_DESCRIPTORS__ && *(void **) cur_func == *(void **) __gcov_indirect_call.callee)) - __gcov_topn_values_profiler_body (__gcov_indirect_call.counters, value, 0); + __gcov_topn_values_profiler_body (__gcov_indirect_call.counters, value, + use_atomic); __gcov_indirect_call.callee = NULL; } + +void +__gcov_indirect_call_profiler_v4 (gcov_type value, void *cur_func) +{ + __gcov_indirect_call_profiler_body (value, cur_func, 0); +} + +#if GCOV_SUPPORTS_ATOMIC +void +__gcov_indirect_call_profiler_v4_atomic (gcov_type value, void *cur_func) +{ + __gcov_indirect_call_profiler_body (value, cur_func, 1); +} +#endif + #endif #ifdef L_gcov_time_profiler diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index bc7e308..023293e 100644 --- a/libgcc/libgcov.h +++ b/libgcc/libgcov.h @@ -274,6 +274,7 @@ extern void __gcov_pow2_profiler_atomic (gcov_type *, gcov_type); extern void __gcov_topn_values_profiler (gcov_type *, gcov_type); extern void __gcov_topn_values_profiler_atomic (gcov_type *, gcov_type); extern void __gcov_indirect_call_profiler_v4 (gcov_type, void *); +extern void __gcov_indirect_call_profiler_v4_atomic (gcov_type, void *); extern void __gcov_time_profiler (gcov_type *); extern void __gcov_time_profiler_atomic (gcov_type *); extern void __gcov_average_profiler (gcov_type *, gcov_type); diff --git a/libgcc/unwind-arm-common.inc b/libgcc/unwind-arm-common.inc index 3c774b8..31a072b 100644 --- a/libgcc/unwind-arm-common.inc +++ b/libgcc/unwind-arm-common.inc @@ -419,7 +419,7 @@ get_eit_entry (_Unwind_Control_Block *ucbp, _uw return_address) UCB_PR_ADDR (ucbp) = selfrel_offset31 (ucbp->pr_cache.ehtp); #if __FDPIC__ UCB_PR_GOT (ucbp) - = (unsigned int) gnu_Unwind_Find_got ((_Unwind_Ptr) UCB_PR_ADDR (ucbp)); + = (unsigned int) _Unwind_gnu_Find_got ((_Unwind_Ptr) UCB_PR_ADDR (ucbp)); #endif } return _URC_OK; @@ -462,7 +462,7 @@ unwind_phase2 (_Unwind_Control_Block * ucbp, phase2_vrs * vrs) #if __FDPIC__ /* r9 could have been lost due to PLT jump. Restore correct value. */ - vrs->core.r[FDPIC_REGNUM] = gnu_Unwind_Find_got (VRS_PC (vrs)); + vrs->core.r[FDPIC_REGNUM] = _Unwind_gnu_Find_got (VRS_PC (vrs)); #endif uw_restore_core_regs (vrs, &vrs->core); @@ -562,7 +562,7 @@ unwind_phase2_forced (_Unwind_Control_Block *ucbp, phase2_vrs *entry_vrs, #if __FDPIC__ /* r9 could have been lost due to PLT jump. Restore correct value. */ - saved_vrs.core.r[FDPIC_REGNUM] = gnu_Unwind_Find_got (VRS_PC (&saved_vrs)); + saved_vrs.core.r[FDPIC_REGNUM] = _Unwind_gnu_Find_got (VRS_PC (&saved_vrs)); #endif uw_restore_core_regs (&saved_vrs, &saved_vrs.core); @@ -698,7 +698,7 @@ __gnu_Unwind_Resume (_Unwind_Control_Block * ucbp, phase2_vrs * entry_vrs) /* Upload the registers to enter the landing pad. */ #if __FDPIC__ /* r9 could have been lost due to PLT jump. Restore correct value. */ - entry_vrs->core.r[FDPIC_REGNUM] = gnu_Unwind_Find_got (VRS_PC (entry_vrs)); + entry_vrs->core.r[FDPIC_REGNUM] = _Unwind_gnu_Find_got (VRS_PC (entry_vrs)); #endif uw_restore_core_regs (entry_vrs, &entry_vrs->core); diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c index d3a09ce..6e50405 100644 --- a/libgcc/unwind-dw2-fde-dip.c +++ b/libgcc/unwind-dw2-fde-dip.c @@ -329,7 +329,7 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr) return 1; #ifdef CRT_GET_RFIB_DATA -# ifdef __i386__ +# if defined __i386__ || defined __nios2__ data->dbase = NULL; if (p_dynamic) { diff --git a/libgcc/unwind-pe.h b/libgcc/unwind-pe.h index a336127..a6b4bff 100644 --- a/libgcc/unwind-pe.h +++ b/libgcc/unwind-pe.h @@ -267,7 +267,7 @@ read_encoded_value_with_base (unsigned char encoding, _Unwind_Ptr base, into account. */ if ((encoding & DW_EH_PE_pcrel) && (encoding & DW_EH_PE_indirect)) { - result += gnu_Unwind_Find_got ((_Unwind_Ptr) u); + result += _Unwind_gnu_Find_got ((_Unwind_Ptr) u); result = *(_Unwind_Internal_Ptr *) result; } else |