newLISP Fan Club

Forum => newLISP and the O.S. => Topic started by: pjot on December 27, 2008, 01:00:03 PM

Title: 'link.lsp' does not work on MacOSX?
Post by: pjot on December 27, 2008, 01:00:03 PM
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
Title:
Post by: Lutz on December 27, 2008, 04:03:52 PM
In newlisp.c line 428 change to:


if(strncmp(linkOffset, "@@@@", 4) == 0)
Title:
Post by: pjot on December 27, 2008, 04:18:42 PM
That did the trick, thanks!



Peter
Title:
Post by: Lutz on December 27, 2008, 04:20:00 PM
I also left you a private message.
Title: alternate solution
Post by: cliffvick on January 08, 2009, 09:00:49 AM
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.