tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] test failures on win32 x86-64


From: grischka
Subject: Re: [Tinycc-devel] test failures on win32 x86-64
Date: Fri, 14 Oct 2022 16:27:44 +0200
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 14.10.2022 11:24, avih via Tinycc-devel wrote:
So somehow, on win7 the address from malloc is always ~22 bits,
while on win10 msvc and new mingw gcc procude ~43 bits address,
while with tcc and old gcc malloc returns ~22 bits addresses.

and indeed, when tcc64 is compiled using tcc64 then on win10
s->sh_addr is ~22 bits, and all tests do pass _before_ d76e0323.

Well, maybe behavior of malloc on Win10 has to do with the image-base
of the process. (see objdump -x file.exe/dll | grep ImageBase)

The new gcc seems to set
   dll: ImageBase 00000003.20e90000
   exe: ImageBase 00000001.40000000

whereas the old defaults (as used by tcc) were (both win32/64)
   dll: ImageBase 00000000.10000000
   exe: ImageBase 00000000.00400000

These can be set using -Wl,-image-base=0x..., for example
$ gcc tcctest.c -g -I.. -O0 -w -o tcctest.exe -Wl,-image-base=0x400000
or
$ tcc tcctest.c -g -I.. -O0 -w -o tcctest.exe -Wl,-image-base=0x320000000

On win10 with gcc 12.2, the output ends with this:
  ./tcctest.gcc > test.ref
  make: *** [Makefile:110: test.ref] Error -1073741819
  make: Leaving directory 'D:/tmp/tcc2/tests'

and the last line at test.ref is "---- asm_test -"

Ok, so it seems that it is tcctest.c compiled by gcc that crashes.
Which means this problem specifically hasn't to do anything with tcc.

Then, at tcctest.c, I commented out /* RUN(asm_test); */
and the test passes.

I tried to find which line crashes at asm_test, and it's:
  strncat1(buf, " worldXXXXX", 3);

(adding exit(42) just before it exits with code 42, but exit(42)
after it is not reached).

No idea why the strncat1() asm stuff now suddenly should fail,
regardless whether with addresses hi or lo.  Of course, most
likely there is some reason ;)

Some useful command if you happen to want find out:

$ gdb tcctest.exe
  > run
  > bt
  > disass
  > info reg

--- grischka

I then tried also
  make -C tests clean
  make -C tests test3

and it's the same end of output as with test1, and same
diagnostics (pass if commenting out RUN(asm_test), else
crash at strncat1(buf, " worldXXXXX", 3)).


- avih



_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel





reply via email to

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