Page 1 of 1

'link.lsp' does not work on MacOSX?

Posted: Sat Dec 27, 2008 9:00 pm
by pjot
Hi Lutz,

It seems the link.lsp does not work?
[peter:apps]$ cat test.lsp
(println "Hello world")
(exit)
[peter:apps]$
[peter:apps]$ newlisp test.lsp
Hello world
[peter:apps]$ newlisp /usr/share/newlisp/util/link.lsp
newLISP v.10.0.0 on OSX IPv4, execute 'newlisp -h' for more info.

> (link "/usr/bin/newlisp" "bla" "test.lsp")
true
> (exit)
[peter:apps]$
[peter:apps]$ chmod 755 bla
[peter:apps]$ ./bla
newLISP v.10.0.0 on OSX IPv4, execute 'newlisp -h' for more info.

>
>
So after executing the new binary the newLisp prompt appears.... Any idea what may be wrong here...?

Thanks, Peter

Posted: Sun Dec 28, 2008 12:03 am
by Lutz
In newlisp.c line 428 change to:

Code: Select all

if(strncmp(linkOffset, "@@@@", 4) == 0)

Posted: Sun Dec 28, 2008 12:18 am
by pjot
That did the trick, thanks!

Peter

Posted: Sun Dec 28, 2008 12:20 am
by Lutz
I also left you a private message.

alternate solution

Posted: Thu Jan 08, 2009 5:00 pm
by cliffvick
It took me some hard thinking and some playing around with the link.lsp source to come up with an alternative solution that doesn't require a recompile of newlisp.

If you replace this line in the function link in link.lsp
(search handle "@@@@@@@@")
with
(search handle "@@@@@@@@" true)
(search handle "@@@@@@@@")

this will cause link.lsp to replace the correct place holder in the binary.

I haven't tried this on another OS, but I'm assuming that it won't work, and this is a hack that will only work on a BSD binary. If I find out otherwise I'll post an update.