mirror of
https://github.com/DynamoRIO/dynamorio.git
synced 2026-10-12 02:02:04 +00:00
For the targets we care about LIBGCC2_UNITS_PER_WORD == 4 (SImode in GCC parlance). Thus a double word is 8 bytes (DImode in GCC parlance). Previously, __moddi3 was using a mix of word and double word widths, causing a compilation failure on 32 bit linux with the Debian 13.2.0-4 compiler. The semantics were also incorrect: inputs and outputs should be 64 bits for the hosts we care about (x86, aarch, 32 and 64 bit, and riscv64). Fixes: #6524
These libgcc files were obtained from svn://gcc.gnu.org/svn/gcc r218764.
The GPL "GCC Runtime Library Exception" allows us to link these files into
our BSD library.
The file mappings are:
+ libgcc/config/arm/lib1funcs.S => third_party/libgcc/arm/lib1funcs.S
+ libgcc/config/arm/bpabi.S => third_party/libgcc/arm/bpabi.S
+ libgcc/config/arm/ieee754-sf.S => third_party/libgcc/arm/ieee754-sf.S
+ libgcc/config/arm/ieee754-df.S => third_party/libgcc/arm/ieee754-df.S
+ libgcc/libgcc2.c => third_party/libgcc/udivmoddi4.c
Each file was untabified and had trailing blank lines removed.
Beyond whitespace changes, two files were changed as described below.
Here are the changes to lib1funcs.S:
30a31,53
> /*--------------------------------------------------*/
> /* i#1566: for DynamoRIO we build separately for each main routine, with
> * TODEFINE set to the target we want to build.
> */
> #define __ARM_ARCH__ 7
> #define __ARM_ARCH_7__
> #define __prefer_thumb__
> #define @TODEFINE@
> #ifdef L_divsi3
> # define L_dvmd_tls /* for __aeabi_idiv0 */
> # define L_aeabi_uldivmod /* for __aeabi_uldivmod */
> # define L_aeabi_ldivmod /* for __aeabi_ldivmod */
> #endif
> #ifndef __thumb__
> # define __thumb__
> #endif
> #ifdef __ARM_ARCH_5T__
> # undef __ARM_ARCH_5T__
> #endif
> #ifdef __ARM_ARCH_5TE__
> # undef __ARM_ARCH_5TE__
> #endif
> /*--------------------------------------------------*/
>
Additionally, a single quote was removed from this comment line in lib1funcs.S
as it breaks some old assemblers:
< @ the sign bit into all of AL. That's not what we want...
> @ the sign bit into all of AL. That is not what we want...
For udivmoddi4.c, it contains the __udivmoddi4 and __moddi3 functions extracted from
libgcc2.c with the following lines added:
> /* This is extracted from gcc's libgcc/libgcc2.c with these typedefs added.
> Note that for current targets (x86, aarch, riscv - 32 and 64 bit)
> LIBGCC2_UNITS_PER_WORD == 4. Thus a double word is 8 bytes. */
> typedef int32_t Wtype;
> typedef int64_t DWtype;
> typedef uint32_t UWtype;
> typedef uint64_t UDWtype;
> #if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
> struct DWstruct {Wtype high, low;};
> #else
> struct DWstruct {Wtype low, high;};
> #endif
> typedef union {
> struct DWstruct s;
> DWtype ll;
> } DWunion;