5

In an attempt to build 64-bit PicoLisp on Mac OS X (10.6.7) it seems I've encountered a problem with the OSX Dev. Tools GNU assembler ('as'), which is version 1.38. My Xcode is version 3.2.4. The lines in my (generated) x86-64.darwin.base.s that cause the problems typically look like this:

call foo@plt

... and they give me error messages like this:

x86-64.darwin.base.s:41694:junk `@plt' after expression

64-bit PicoLisp builds without problems on Linux and SunOS. These platforms probably have more capable (newer) versions of GNU assemblers. I don't know if newer GNU assemblers are avilable for OSX/Darwin ... or could there be other solutions?

If you'd like to try this yourself on OSX/Darwin, I can give you some files that are needed.

Jon K
  • 327
  • 2
  • 9
  • What version of the Developer Tools are you using ? Xcode 3.2.x ? Xcode 4.x ? – Paul R Jun 17 '11 at 11:20
  • 1
    At some point I had very similar problems – with my own code. Swapping the order of some input registers, weirdly enough, seemed to fix it. Then again it seemed like it broke by itself in the first place. –  Jun 17 '11 at 11:21
  • Not sure why this doesn't work on OSX. See http://stackoverflow.com/questions/5469274/what-does-plt-mean-here/5469334#5469334 for a description of how the PLT works - you may need a later assembler to allow the `@` in symbol names, though the doco seems to indicate it's not allowed, even now. – paxdiablo Jun 17 '11 at 11:37
  • My Xcode is Version 3.2.4 (1708). – Jon K Jun 17 '11 at 12:20

2 Answers2

7

Unfortunately, I think there are at least two significant issues here:

  1. "PLT" is an ELF concept, but OS X uses a completely different object / executable file format - Mach-O. Mach-O uses a similar mechanism but with a different name.
  2. MacOS prefixes asm symbol names with a leading underscore. So you want call _foo. call foo would assemble but not link. As on GNU/Linux (ELF), the linker indirects through dyld_stub entries for you when you call a symbol that turns out to be in a dynamic library.
    (Non-interposable symbols are the default even when building shared libraries, unlike on ELF systems)
  3. Apple's as appears to be derived from a fork of a much earlier version of the GNU assembler, and, in some places, the syntax (and command line options) are rather different from recent versions (even where the concepts are the same).

It looks like there has been some work on i386 and x86-64 Mach-O support quite recently in binutils; it might be worth investigating the most recent version (2.21). But if the generated assembly code is trying to do clever things which are ELF-specific, you're probably going to have some major problems anyway...

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Matthew Slattery
  • 45,290
  • 8
  • 103
  • 119
  • 1
    Thanks! Anything that can help spread to great tool PicoLisp is good in my book. :) – Prof. Falken Jun 23 '11 at 09:08
  • 1
    I think current MacOS uses clang as their `as` assembler. – Peter Cordes Jan 20 '20 at 09:54
  • The article referenced in "a similar mechanism but with a different name" can be found via the wayback machine. Here's a link: https://web.archive.org/web/20220310101910/http://timetobleed.com/dynamic-linking-elf-vs-mach-o/ – Chris Sep 17 '22 at 21:23
-1

PicoLisp has been supported on Mac for quite some time now. Just go to the standard download site.

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173