[Top][All Lists]

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

Re: [Tinycc-devel] Regarding Long double Constant

From: Ayush Varshney
Subject: Re: [Tinycc-devel] Regarding Long double Constant
Date: Thu, 11 Feb 2021 22:34:26 +0100

Hello guys,
I am sorry for the late response, my health hasn't been very good today.

What I wanted to discuss was in terms of reproducibility of tcc compiler, We know that we should focus more on reproducible builds, and even more so; security of reproducible builds can be of great importance. [1] suggest that we can use a trusted compiler to recompile the source code of a build twice to see if there is any backdoor in the binary, this helps with ensuring the reproducibility and security of the build. 
in if(f2==0.0)
"f2 has type long double, tcc eventually stores this 0.0 in memory as a long double value. The problem is that tcc’s “long double” uses only 10 bytes, but it is stored in 12 bytes, and tcc’s source code does not initialize the extra 2 bytes. The two excess “junk” bytes end up depending on the underlying environment, causing variations in the output. In normal operation these bytes are ignored and thus cause no problems. 

To resolve this, the value “0.0” was replaced with the _expression_ (f1-f1), since f1 is a long double variable known to have a finite value there (e.g., it is not a NaN). This is semantically the same and eliminated the problem. A better long-term solution for tcc would be to always set these “excess” values to constants (such as 0x00)"  [1]. 

Using (f1-f1) is a workaround for using 0.0. It would not affect the normal operations but would be useful for reproducibility and DDC test (for security).


On Thu, Feb 11, 2021 at 4:03 PM Kyryl Melekhin <k.melekhin@gmail.com> wrote:
"Christian Jullien" <eligis@orange.fr> wrote:

> No, I think he probably meant (1F-1F) to get 0.0F value?

Looking at the general context I think it should be

else if (vtop->c.ld == (vtop->c.ld - vtop->c.ld))


But as for my opinion I also think it's unnecessary and
should be reverted.

Tinycc-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]