[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: GCC 4.4 run-time license and non-GPLv3 compilers



* Sylvain Le Gall:

>> byterun/ints.c, function caml_int64_div, the I64_div macro.  This is
>> expanded into a plain division operator, and that is compiled into a
>> run-time library call by GCC.
>>
>
> I64_div is a function defined either in byterun/int64_emul.h o
> byterun/int64_native.h. Reading both I64_div, I don't see any specific
> GCC usage. 
>
> Could you be more precise ? I must admit I don't understand at all this
> issue ! 

Here's a disassembly of the caml_int64_div function in ocaml 3.10.2

00000e19 <caml_int64_div>:
     e19:       55                      push   %ebp
     e1a:       89 e5                   mov    %esp,%ebp
     e1c:       83 ec 18                sub    $0x18,%esp
     e1f:       8b 45 0c                mov    0xc(%ebp),%eax
     e22:       8b 50 08                mov    0x8(%eax),%edx
     e25:       8b 40 04                mov    0x4(%eax),%eax
     e28:       89 d1                   mov    %edx,%ecx
     e2a:       09 c1                   or     %eax,%ecx
     e2c:       75 05                   jne    e33 <caml_int64_div+0x1a>
     e2e:       e8 fc ff ff ff          call   e2f <caml_int64_div+0x16>
                        e2f: R_386_PC32 caml_raise_zero_divide
     e33:       89 44 24 08             mov    %eax,0x8(%esp)
     e37:       89 54 24 0c             mov    %edx,0xc(%esp)
     e3b:       8b 4d 08                mov    0x8(%ebp),%ecx
     e3e:       8b 41 04                mov    0x4(%ecx),%eax
     e41:       8b 51 08                mov    0x8(%ecx),%edx
     e44:       89 04 24                mov    %eax,(%esp)
     e47:       89 54 24 04             mov    %edx,0x4(%esp)
     e4b:       e8 fc ff ff ff          call   e4c <caml_int64_div+0x33>
                        e4c: R_386_PC32 __divdi3
     e50:       89 04 24                mov    %eax,(%esp)
     e53:       89 54 24 04             mov    %edx,0x4(%esp)
     e57:       e8 fc ff ff ff          call   e58 <caml_int64_div+0x3f>
                        e58: R_386_PC32 caml_copy_int64
     e5c:       c9                      leave
     e5d:       c3                      ret

The actual division is carried out by calling __divdi3.  This function
is implemented in the GCC run-time library, and statically linked into
the executable.

Note that this is just an example.  Other, similar issues probably
exist on other architectures (particular RISCy ones).


Reply to: