public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bob Plantz <plantz@cds1.net>
To: Qing Wang <qinggwang@hotmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: How to compile and link 32 bit c code with 64 bit c  code‏
Date: Tue, 05 Jan 2010 17:59:00 -0000	[thread overview]
Message-ID: <1262714313.2003.25.camel@bob-desktop> (raw)
In-Reply-To: <BAY125-W4449C7366C9FF39E48FCEA6730@phx.gbl>

On Tue, 2010-01-05 at 11:47 +0800, Qing Wang wrote:
> Hi, 
>  
> I am making a 32 bit project to call some 64 bit functions.
> So, I have most of c files which will be compiled and linked into 32 bit binary.And I have some c files including those functions which will be compiled into 64 bit binary.
> Of course, I will call into assembly first to set up 64 bit mode, and then call those 64 bit functions, finally I will return to assembly to get back to 32 bit mode. 
>  
> Now I have a problem how to compile and link those 32 bit code with those 64 bit code together into one object file (like xxx.gz) 
> Unlike assembly, which is easy to embed ".code32" or ".code64" in assembly to distinguish 32 bit code and 64 bit code, (see the document "Using as The GNU Assembler"), how can I achieve this for c files? Or are there any examples to tell me to achieve this? 
>  
> Thanks.
> Qing  		 	   		  

What architecture?

What do you mean by "32 bit c code" versus "64 bit c code"? If I compile
with the -m32 option I get 32-bit code, and with -m64 I get 64-bit code.

If you are using the x86 architecture, mixing 32-bit functions with
64-bit functions simply does not work. Arguments are passed on the stack
in 32-bit, but in registers (the first six arguments) in 64-bit.

--Bob


  reply	other threads:[~2010-01-05 17:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-05  3:47 Qing Wang
2010-01-05 17:59 ` Bob Plantz [this message]
2010-01-06  6:21   ` Qing Wang
2010-01-06  6:29   ` Qing Wang
2010-01-06  9:17     ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1262714313.2003.25.camel@bob-desktop \
    --to=plantz@cds1.net \
    --cc=gcc-help@gcc.gnu.org \
    --cc=qinggwang@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).