tinycc-devel
[Top][All Lists]
Advanced

[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: Tue, 28 Feb 2012 10:22:07 -0600

The goal is creating a 64bit ELF executable on Windows64. (The toy kernel reads ELF files only, not PE). I rant into a few issues along the way.  Much of the ELF writing code assumes that "long" is 64 bits, not true on Win64 with "long long" insanity.

The ELF executable sections were missing the high order bytes, followed by relocations not appearing to propagate the higher order bytes as well.  First, the parsed string dropped the remaining bits (leaving vaddr of 0x00000000ffff8000), modifying to parse the entire got me to dropping the high order to relocate everything to 0x0.  From there, it was trying to find all the places that appeared to not update the high words, resulting in portions of the executable located at 0xffff80000000 and looking at 0x0.

Fwiw, I'm not the most familiar with git (professionally stuck with svn and using hg), and this patch was very much a hatchet job following a couple chains of events until the executable looked ok-ish.  The toy kernel looks to be running ok, with only a couple headaches (ugh xmmX is used for varargs! - I might be writing a patch for this too).

I can give it another go around this weekend or separate it into a few if you want.  Fwiw, I think a much safer approach here would be killing the #define and switching to <stdint.h> with uint64_t and friends.  Of course, you'd need to provide that(or similar) header for non-standards compliant / older compilers.  While that wouldn't eliminate the other challenge of portable "strto*" functions, it'd mitigate the cross compilers overly relying on architecture type sizes.

Regards,
Andrew


After fixing this, it appeared that

On Tue, Feb 28, 2012 at 9:26 AM, grischka <address@hidden> wrote:
Andrew Mulbrook wrote:
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.

Still I don't understand the point of most of these changes.  Also the
patch doesn't seem to fix the central issue.   Was it not to make
   -Wl,-Ttext=0xffffff8000000000
work for windows-64, in the first place?

--- grischka



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


reply via email to

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