On 20/03/21 05:27, Gavin Shan wrote:
It's still possible that the wrong value is returned from the alias
of variable even if the program can be compiled without issue. This
improves the check by executing the binary to check the result.
If alias attribute can't be working properly, the @target_page in
exec-vary.c will always return zeroes when we have the following gcc
version.
# gcc --version
gcc (GCC) 11.0.0 20210210 (Red Hat 11.0.0-0)
This abstracts the code from exec-vary.c and use it as indicator to
enable gcc alias attribute or not.
+void write_x(int val);
+
+void write_x(int val)
+{
+ x = val;
+}
+
+int main(void)
+{
+ return read_y();
+}
I think this should be "read_y() == 1 ? 0 : 1".
I can reproduce it with -flto -O2 but not without -flto, do you agree?
Perhaps we can obtain the same optimization by wrapping reads of the
page size in an inline __attribute__((const)) function. Richard, what
do you think?
Paolo