[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] x86-64 TCC / GCC ABI mismatch when returning bool/char/sh
From: |
Mart Gerrits |
Subject: |
[Tinycc-devel] x86-64 TCC / GCC ABI mismatch when returning bool/char/short |
Date: |
Sun, 15 Apr 2018 21:05:20 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
Hi.
I have been using a mix of a library compiled by TCC and
an executable compiled by GCC on a linux/x86-64 platform,
this worked great until I ran into an ABI mismatch.
When returning bool, char or short GCC does not clear the
upper bits of the eax register. But TCC assumes these bits
are cleared.
I have attached a small bash script which illustrates this
difference, and two patches.
The bash script creates a shared library compiled using GCC
and two executables one compiled by TCC and another by GCC
that use the library. They call some test functions from
the library and print the results.
The first patch expands bool/char/short return values to int
for the x86-64 target. This is essentially a duplicate of the
code that was already present for the PE target [1].
The second patch adds an extra case to handle this expansion
for bools for the PE target. I have not tested this, but
noticed it was missing.
Regards,
Mart Gerrits
1. http://repo.or.cz/tinycc.git/blob/d348a9a5:/x86_64-gen.c#l930
test.sh
Description: application/shellscript
0001-x86-64-expand-bool-char-short-return-values-to-int.patch
Description: Text Data
0002-x86-64-expand-bool-return-values-to-int-for-PE-targe.patch
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Tinycc-devel] x86-64 TCC / GCC ABI mismatch when returning bool/char/short,
Mart Gerrits <=