public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Intermixing powerpc-eabi and powerpc-linux C code
@ 2006-06-01 18:32 Ron McCall
  2006-06-01 18:45 ` Paul Brook
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ron McCall @ 2006-06-01 18:32 UTC (permalink / raw)
  To: gcc

Hi!

Does anyone happen to know if it is possible to link
(and run) C code compiled with a powerpc-eabi targeted
gcc with C code compiled with a powerpc-linux targeted
gcc?  The resulting program would be run on a PowerPC
Linux system (ELDK 4.0).

In this case, main() would be compiled by
powerpc-linux-gcc while a test driver and all code to
be tested would be compiled by powerpc-eabi-gcc. 
Everything would be linked using powerpc-linux-gcc.  

The call from Linux-land to eabi-land would not need
to pass arguments nor return anything and nothing
would need to be shared between the two pieces of
code.

None of the powerpc-eabi code will depend on any
libraries or other external code, it will all be
completely self-contained.

Thanks!

Ron McCall

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Intermixing powerpc-eabi and powerpc-linux C code
  2006-06-01 18:32 Intermixing powerpc-eabi and powerpc-linux C code Ron McCall
@ 2006-06-01 18:45 ` Paul Brook
  2006-06-01 19:10   ` Ron McCall
  2006-06-01 23:08 ` Mike Stump
  2006-06-23 19:29 ` Meissner, Michael
  2 siblings, 1 reply; 6+ messages in thread
From: Paul Brook @ 2006-06-01 18:45 UTC (permalink / raw)
  To: gcc; +Cc: Ron McCall

> The call from Linux-land to eabi-land would not need
> to pass arguments nor return anything and nothing
> would need to be shared between the two pieces of
> code.

So basically you can replace the whole thing with sleep(1); and noone would be 
any the wiser.

Paul

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Intermixing powerpc-eabi and powerpc-linux C code
  2006-06-01 18:45 ` Paul Brook
@ 2006-06-01 19:10   ` Ron McCall
  0 siblings, 0 replies; 6+ messages in thread
From: Ron McCall @ 2006-06-01 19:10 UTC (permalink / raw)
  To: gcc

I guess I should have also mentioned that the
resultant program will be run under gdb, with a script
setting breakpoints, running, examining variables,
etc.

--- Paul Brook <paul@codesourcery.com> wrote:

> > The call from Linux-land to eabi-land would not
> need
> > to pass arguments nor return anything and nothing
> > would need to be shared between the two pieces of
> > code.
> 
> So basically you can replace the whole thing with
> sleep(1); and noone would be 
> any the wiser.
> 
> Paul
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Intermixing powerpc-eabi and powerpc-linux C code
  2006-06-01 18:32 Intermixing powerpc-eabi and powerpc-linux C code Ron McCall
  2006-06-01 18:45 ` Paul Brook
@ 2006-06-01 23:08 ` Mike Stump
  2006-06-06 16:05   ` Ron McCall
  2006-06-23 19:29 ` Meissner, Michael
  2 siblings, 1 reply; 6+ messages in thread
From: Mike Stump @ 2006-06-01 23:08 UTC (permalink / raw)
  To: Ron McCall; +Cc: gcc

On Jun 1, 2006, at 11:32 AM, Ron McCall wrote:
> Does anyone happen to know if it is possible to link
> (and run) C code compiled with a powerpc-eabi targeted
> gcc with C code compiled with a powerpc-linux targeted
> gcc?

This is a linker question, we don't do linkers here.  In particular,  
the relocs have to be compatible, if you want to do reloc  
processing.  You can use ld and resolve all the relocs and just slam  
in the bytes, but then, you're not using gcc to link per se.

Why not just try it out and see?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Intermixing powerpc-eabi and powerpc-linux C code
  2006-06-01 23:08 ` Mike Stump
@ 2006-06-06 16:05   ` Ron McCall
  0 siblings, 0 replies; 6+ messages in thread
From: Ron McCall @ 2006-06-06 16:05 UTC (permalink / raw)
  To: gcc

You make a good point about the linker aspect but I was first most
concerned about the code generation differences, if any. 

However, you are absolutely correct!  A test is in order.  I whipped up
a quick test program and was able to successfully compile, link and run
it, so it does indeed work!  Thanks!

On Thu, Jun 01, 2006 at 04:08:14PM -0700, Mike Stump wrote:
> This is a linker question, we don't do linkers here.  In particular,
> the relocs have to be compatible, if you want to do reloc  processing.
> You can use ld and resolve all the relocs and just slam  in the bytes,
> but then, you're not using gcc to link per se.
> 
> Why not just try it out and see?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Intermixing powerpc-eabi and powerpc-linux C code
  2006-06-01 18:32 Intermixing powerpc-eabi and powerpc-linux C code Ron McCall
  2006-06-01 18:45 ` Paul Brook
  2006-06-01 23:08 ` Mike Stump
@ 2006-06-23 19:29 ` Meissner, Michael
  2 siblings, 0 replies; 6+ messages in thread
From: Meissner, Michael @ 2006-06-23 19:29 UTC (permalink / raw)
  To: Ron McCall, gcc

> -----Original Message-----
> From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On Behalf
Of
> Ron McCall
> Sent: Thursday, June 01, 2006 2:33 PM
> To: gcc@gcc.gnu.org
> Subject: Intermixing powerpc-eabi and powerpc-linux C code
> 
> Hi!
> 
> Does anyone happen to know if it is possible to link
> (and run) C code compiled with a powerpc-eabi targeted
> gcc with C code compiled with a powerpc-linux targeted
> gcc?  The resulting program would be run on a PowerPC
> Linux system (ELDK 4.0).

When I last played with the powerpc many years ago, the main differences
between Linux and eabi was some details that you may or may not run into
(note these are from memory, so you probably need to check what the
current reality is):
1) eabi had different stack alignments than Linux;
2) eabi uses 2 small data registers (r2, r13) and Linux only 1 (r13?).
3) There are eabi relocations not officially in Linux and vice versa,
but the GNU linker should support any relocations the compiler uses.
4) eabi can be little endian, Linux is only big endian.
5) different system libraries were linked in by default. 

--
Michael Meissner
AMD, MS 83-29
90 Central Street
Boxborough, MA 01719



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-06-23 18:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-01 18:32 Intermixing powerpc-eabi and powerpc-linux C code Ron McCall
2006-06-01 18:45 ` Paul Brook
2006-06-01 19:10   ` Ron McCall
2006-06-01 23:08 ` Mike Stump
2006-06-06 16:05   ` Ron McCall
2006-06-23 19:29 ` Meissner, Michael

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).