Thread View: comp.sys.mac.programmer.codewarrior
5 messages
5 total messages
Started by Paul Russell
Wed, 26 Jun 2002 16:51
Linking asm into Mach-O project ?
Author: Paul Russell
Date: Wed, 26 Jun 2002 16:51
Date: Wed, 26 Jun 2002 16:51
16 lines
1885 bytes
1885 bytes
I'm trying to integrate a chunk of gcc PowerPC assembler code into a CW
8 Mach-O project. I've tried two approaches, neither of which seem to
work. Has anyone else had more success than I have ?
(i) fix the syntax (by hand !) and put the code into an inline asm {}
function - this fails because CW complains that there aren't enough free
registers (despite teh fact that I'm only using about 12 GPR's)
(ii) assemble with gcc and try to link in the object file - the Mach-O
Importer barfs with an error about an unsupported relocation type or
some such
Surely it shouldn't be this hard to link is some very straightforward
asm functions, that already work with gcc ?
Paul
Re: Linking asm into Mach-O project ?
Author: MW Ron
Date: Fri, 28 Jun 2002 02:07
Date: Fri, 28 Jun 2002 02:07
30 lines
2280 bytes
2280 bytes
In article <3D19F129.B549F3E0@arc-software.com>,
Paul Russell <prussell@arc-software.com> wrote:
>I'm trying to integrate a chunk of gcc PowerPC assembler code into a CW
>8 Mach-O project. I've tried two approaches, neither of which seem to
>work. Has anyone else had more success than I have ?
>
>(i) fix the syntax (by hand !) and put the code into an inline asm {}
>function - this fails because CW complains that there aren't enough free
>registers (despite teh fact that I'm only using about 12 GPR's)
>
>(ii) assemble with gcc and try to link in the object file - the Mach-O
>Importer barfs with an error about an unsupported relocation type or
>some such
>
>Surely it shouldn't be this hard to link is some very straightforward
>asm functions, that already work with gcc ?
What linker are you using? the Apple GCC linker or Metrowerks Mach-O
linker, do you have a small example project (or code for a stationery
project) that you can send that I can forward on.
Ron
--
CodeWarrior, the ultimate development tools for Symbian OS
http://www.metrowerks.com/products/symbian/d4
Metrowerks, maker of CodeWarrior - "Software Starts Here"
Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com
Re: Linking asm into Mach-O project ?
Author: Paul Russell
Date: Fri, 28 Jun 2002 05:33
Date: Fri, 28 Jun 2002 05:33
39 lines
2945 bytes
2945 bytes
MW Ron wrote:
>
> In article <3D19F129.B549F3E0@arc-software.com>,
> Paul Russell <prussell@arc-software.com> wrote:
>
> >I'm trying to integrate a chunk of gcc PowerPC assembler code into a CW
> >8 Mach-O project. I've tried two approaches, neither of which seem to
> >work. Has anyone else had more success than I have ?
> >
> >(i) fix the syntax (by hand !) and put the code into an inline asm {}
> >function - this fails because CW complains that there aren't enough free
> >registers (despite teh fact that I'm only using about 12 GPR's)
> >
> >(ii) assemble with gcc and try to link in the object file - the Mach-O
> >Importer barfs with an error about an unsupported relocation type or
> >some such
> >
> >Surely it shouldn't be this hard to link is some very straightforward
> >asm functions, that already work with gcc ?
>
> What linker are you using? the Apple GCC linker or Metrowerks Mach-O
> linker, do you have a small example project (or code for a stationery
> project) that you can send that I can forward on.
>
I'm using the default MetroWerks "Mac OS X PowerPC Mach-O" linker, and
the default file mappings, which map object files to "Mach-O Importer",
which seems to be where the error message is coming from. I think I
tried changing the linker but it didn't make any difference.
If I make a small asm function that does nothing then I can link that in
OK - the problem seems to occur when the function has branches in it -
the Mach-O Importer doesn't like something about the relocation info in
the object file. Since these would be relative branches I can't imagine
what the problem would be.
As you suggest, I'll put together a demo which illustrates the problem.
Paul
Re: Linking asm into Mach-O project ?
Author: Paul Russell
Date: Fri, 28 Jun 2002 05:39
Date: Fri, 28 Jun 2002 05:39
13 lines
1573 bytes
1573 bytes
MW Ron wrote: > > What linker are you using? the Apple GCC linker or Metrowerks Mach-O > linker, do you have a small example project (or code for a stationery > project) that you can send that I can forward on. > P.S. Here's the exact error message: Error : Internal Mach-O Importer Error File 'ImportMachO.c' Line 1952 unsupported unknown reloc type Paul
Re: Linking asm into Mach-O project ? [solved]
Author: Paul Russell
Date: Fri, 28 Jun 2002 14:04
Date: Fri, 28 Jun 2002 14:04
44 lines
2644 bytes
2644 bytes
MW Ron wrote:
>
> In article <3D19F129.B549F3E0@arc-software.com>,
> Paul Russell <prussell@arc-software.com> wrote:
>
> >I'm trying to integrate a chunk of gcc PowerPC assembler code into a CW
> >8 Mach-O project. I've tried two approaches, neither of which seem to
> >work. Has anyone else had more success than I have ?
> >
> >(i) fix the syntax (by hand !) and put the code into an inline asm {}
> >function - this fails because CW complains that there aren't enough free
> >registers (despite teh fact that I'm only using about 12 GPR's)
> >
> >(ii) assemble with gcc and try to link in the object file - the Mach-O
> >Importer barfs with an error about an unsupported relocation type or
> >some such
> >
> >Surely it shouldn't be this hard to link is some very straightforward
> >asm functions, that already work with gcc ?
>
> What linker are you using? the Apple GCC linker or Metrowerks Mach-O
> linker, do you have a small example project (or code for a stationery
> project) that you can send that I can forward on.
>
I think I now have the solution to this. To keep the Mach-O Importer
happy you need at least one .globl directive in the source code. In
order to link with C code, your function names (labels) need to have a
preceding underscore. So, a minimal asm function would be:
//
// foo.S
//
// void foo(void);
//
.globl _foo
_foo:
nop
blr
//
Paul
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads