Comment 9 for bug 185263

Revision history for this message
Josh Haberman (jhaberman) wrote :

I know it's been a couple years since the bug was closed, but I found it today when wishing for a similar thing (and wondering if anyone had taken up Knuth on his idea).

FWIW I think you are significantly overstating what it would take to do this. I think this is comparable in scope to the -malign-double flag, which likewise changes the ABI slightly, but doesn't require a new ABI document, a new GNU triple, or changes to binutils.

GCC already knows how to compile for x86-64, the only difference would be that it would only allocate 32 bits for pointers in structs, and it would load/store those pointers using DWORD PTR instead of QWORD PTR. Besides that, the ABI would remain unchanged (for example, there would be no impact on calling conventions).

It's true that you'd need to get the kernel to allocate the stack and vdso within 4GB, but since the kernel already does this for compatibility mode binaries (ie. 32-bit binaries run on a 64-bit OS), I can't imagine it would be too difficult to accomplish.

The only big problem I can see is compatibility with kernel/glibc structures that have pointers in them, like "struct iovec"

           struct iovec {
               void *iov_base; /* Starting address */
               size_t iov_len; /* Number of bytes to transfer */

To use structures like this you'd need to compile a separate glibc that uses 32-bit pointers. I'm not sure how -malign-double gets around this problem; maybe there just aren't any glibc/OS structs that have doubles in them. But I don't think too many of the structs that are exchanged between user code and glibc/kernel have pointers in them, so perhaps this problem wouldn't be too wide-spread.

Anyway, I'm not commenting on whether Ubuntu is the right place to make this feature request, I'm just commenting on the feasibility of doing this. I think it's a lot easier than you're making it sound.