'link.lsp' does not work on MacOSX?

Started by pjot, December 27, 2008, 01:00:03 PM

Previous topic - Next topic

pjot

Hi Lutz,



It seems the link.lsp does not work?


Quote
[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

Lutz

#1
In newlisp.c line 428 change to:


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

pjot

#2
That did the trick, thanks!



Peter

Lutz

#3
I also left you a private message.

cliffvick

#4
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.