🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #956

Re: Linking asm into Mach-O project ? [solved]

#956
From: Paul Russell
Date: Fri, 28 Jun 2002 14:04
44 lines
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
Technical Details
Message-ID: <3D1C6CF9.28C6F2A2@arc-software.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!unlnews.unl.edu!feed.news.sonic.net!typhoon.sonic.net!not-for-mail
References: <3D19F129.B549F3E0@arc-software.com> <mwron-1E3F2D.22075227062002@enews.newsguy.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bcce,ca141578f4efb1df
X-Google-Attributes: gid10bcce,public
X-Google-Thread: f635e,ca141578f4efb1df
X-Google-Attributes: gidf635e,public
X-Google-ArrivalTime: 2002-06-28 07:05:34 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!unlnews.unl.edu!feed.news.sonic.net!typhoon.sonic.net!not-for-mail
Message-ID: <3D1C6CF9.28C6F2A2@arc-software.com>
From: Paul Russell <prussell@arc-software.com>
Reply-To: prussell@arc-software.com
Organization: Coastal Software
X-Mailer: Mozilla 4.76 (Macintosh; U; PPC)
X-Accept-Language: en,pdf
MIME-Version: 1.0
Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.mac
Subject: Re: Linking asm into Mach-O project ? [solved]
References: <3D19F129.B549F3E0@arc-software.com> <mwron-1E3F2D.22075227062002@enews.newsguy.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 44
Date: Fri, 28 Jun 2002 14:04:43 GMT
NNTP-Posting-Host: 208.201.231.212
X-Complaints-To: abuse@sonic.net
X-Trace: typhoon.sonic.net 1025273083 208.201.231.212 (Fri, 28 Jun 2002 07:04:43 PDT)
NNTP-Posting-Date: Fri, 28 Jun 2002 07:04:43 PDT