[Top][All Lists]

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

Re: [Tinycc-devel] BUG: code generation problem in i386-gen.c:gcall_or_j

From: 张博洋
Subject: Re: [Tinycc-devel] BUG: code generation problem in i386-gen.c:gcall_or_jmp()
Date: Sat, 9 Sep 2017 20:55:46 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

OK, I will push my modifications to the mob branch.

在 2017年09月09日 18:26, Christian Jullien 写道:
Hello Zhang

First I'm not an official maintainer of tcc but a regular user and observer of 
its evolutions. I also check that it does not regress on the platforms I use.

That said, your recent proposals seem strongly argumented with associated 
tests. Since no one commented your proposal (that sad!).
I suggest you to push them in mod so that we can see if we have regression or 
not with them. Please make one commit at a time for a given fix so that we can 
better insulate regression (if any).

I any cases, many thanks to participate to this project and to try to make it 


-----Original Message-----
From: Tinycc-devel [mailto:address@hidden On Behalf Of ???
Sent: samedi 9 septembre 2017 05:03
To: address@hidden
Subject: [Tinycc-devel] BUG: code generation problem in 


I found 3 problems in i386-gen.c:gcall_or_jmp().

(1) There is a fix for extending return value to whole register, however, this 
fix is in the constant case only, if a call is indirect, this fix will not be 
applied and the result will be wrong.

(2) The fix is for 'call' and if 'is_jmp' == 1, it will generate redundant code.

(3) Calling constant should use the indirect way. For example, if someone write "((void 
(*)(void)) 0x12345678)()" in a DLL, the generated code will be "CALL 0x12345678". 
However, because the imm in CALL instruction is PC related, when the DLL is relocated, the call 
target will be wrong.

I provided a patch and two testcase.

'test-movzx-movsx.c' is for problem (1) and (2).
run it with:
    tcc -run test-movzx-movsx.c

expected output is:
    0000ABCE 0000ABCE
    000000CE 000000CE

    0000ABCE 0000ABCE
    000000CE 000000CE

the other two files are for problem (3).
run it with:

# set DLL base at 0x400000 to force a relocation tcc -shared 
-Wl,-Ttext=0x00400000 test-call-constant-dll.c

tcc -L. -ltest-call-constant-dll -run test-call-constant-run.c

expected output is:
    by pointer variable: FEEDBEEF
    by pointer constant: FEEDBEEF

Zhang Boyang

Tinycc-devel mailing list

张博洋 - 复旦大学2014级计算机科学与技术
我的手机: 18600020982
我的个人网站: http://www.zbyzbyzby.com

reply via email to

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