[Top][All Lists]

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

Re: [Tinycc-devel] Strange issue with 64bit section offsets

From: Andrew Mulbrook
Subject: Re: [Tinycc-devel] Strange issue with 64bit section offsets
Date: Sun, 26 Feb 2012 19:10:35 -0600

Hi grischka,

Looks like this rabbit hole went a bit further than I expected.  After a bit of work, I managed to have (what appears) to be a valid test linked file located in an address space using the top word bits.  I pushed "64bit_fixes:mob".  However, I'm guessing more work needs done for the 64bit side of life on windows. This patch attempts to be fairly small in the changes it makes.

Best Regards,

On Sat, Feb 25, 2012 at 8:18 AM, grischka <address@hidden> wrote:
Andrew Mulbrook wrote:

I'm using tcc to develop a "toy" operating system kernel.  In adding 64bit support, I discovered what appears to be a bug in tcc.

Several fields in "tcc.h" structures are defined as "unsigned long".  In a MingW32 environmebr, these appear to break when generating a text section with a high load offset. I'm using "-Wl,-Ttext=0xffffff8000000000".  Also, the link_option parsing inside libtcc.c uses "strtol" as opposed to "strtoll". On 64 bit linux, the binary image works as expected.  On 64bit windows, the long only holds a 32bit offset and things go 'splody.

Current approach in TCC is using 'uplong' for absolute addresses,
which is for win64
       #ifdef _WIN64
       # define uplong unsigned long long
and otherwise
       #ifndef uplong
       #define uplong unsigned long

(We might use uintptr_t eventually)

For relative addresses (offsets) 32 bits are generally sufficient
even on 64 bit platforms.

This appears on first glance to be fixable via changing the "long" references in the structure to long long /int64 types.  However, before I start venturing into the maze of writing a bugfix, I was curious if anyone was looking at / developing the 64bit portions of tcc, or if submitted patches would even be seen by someone.  Was this a known issue with larger implications? I also noticed objdump is currently choking on the resulting binary as well (linux 64bit testing).

I'd assume that 64 bit works except where it doesn't.

I noticed the tinycc website says this compiler isn't being actively maintained, but there is a steady (extremely light) stream of commits.  Has someone taken over this project?  tcc has the nice benefit for me of running on windows & linux without huge headaches in bringing up a proper cross toolchain.

You're welcome to push patches on out 'mob' branch.  See instructions:

- Assume that your patch will go into next release without further checking.
- "Smaller patches are better patches."
- "Fix your problem at hand, try not to cause other problems."
- (... more stuff you already know).

Next release (0.9.26) is overdue but not urgent.


--- grischka

Best Regards,

Tinycc-devel mailing list

reply via email to

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