464 "return true, if aFilename looks ok for binary loading. |
464 "return true, if aFilename looks ok for binary loading. |
465 This checks only the extension - not its contents. |
465 This checks only the extension - not its contents. |
466 (So an attempt to load the file may fail due to format errors or unresolved symbols) |
466 (So an attempt to load the file may fail due to format errors or unresolved symbols) |
467 This is very machine specific." |
467 This is very machine specific." |
468 |
468 |
|
469 |fn| |
|
470 |
|
471 fn := aFilename asFilename. |
469 self validBinaryExtensions do:[:ext | |
472 self validBinaryExtensions do:[:ext | |
470 (aFilename endsWith:ext) ifTrue:[^ true]. |
473 (fn hasSuffix:ext) ifTrue:[^ true]. |
471 ]. |
474 ]. |
472 ^ false |
475 ^ false |
473 |
476 |
474 " |
477 " |
475 ObjectFileLoader hasValidBinaryExtension:'foo.st' |
478 ObjectFileLoader hasValidBinaryExtension:'foo.st' |
476 ObjectFileLoader hasValidBinaryExtension:'foo.o' |
479 ObjectFileLoader hasValidBinaryExtension:'foo.o' |
477 ObjectFileLoader hasValidBinaryExtension:'foo.so' |
480 ObjectFileLoader hasValidBinaryExtension:'foo.so' |
478 ObjectFileLoader hasValidBinaryExtension:'foo.dll' |
481 ObjectFileLoader hasValidBinaryExtension:'foo.dll' |
|
482 ObjectFileLoader hasValidBinaryExtension:'foo.DLL' |
479 ObjectFileLoader hasValidBinaryExtension:'foo.obj' |
483 ObjectFileLoader hasValidBinaryExtension:'foo.obj' |
480 ObjectFileLoader hasValidBinaryExtension:'foo.sl' |
484 ObjectFileLoader hasValidBinaryExtension:'foo.sl' |
481 " |
485 " |
482 |
486 |
483 "Modified: 29.4.1997 / 21:55:07 / cg" |
487 "Modified: / 1.10.1998 / 12:47:01 / cg" |
484 ! |
488 ! |
485 |
489 |
486 linkArgs |
490 linkArgs |
487 ^ LinkArgs ? '' "/ that default is ok for Unix |
491 ^ LinkArgs ? '' "/ that default is ok for Unix |
488 |
492 |
663 This is very machine specific." |
667 This is very machine specific." |
664 |
668 |
665 |os| |
669 |os| |
666 |
670 |
667 OperatingSystem isMSDOSlike ifTrue:[ |
671 OperatingSystem isMSDOSlike ifTrue:[ |
668 "/ includes all of win32s, win95, winNT & os/2 |
672 "/ includes all of win32s, win95, winNT & os/2 |
669 ^ #('.dll') |
673 ^ #('dll') |
670 ]. |
674 ]. |
671 OperatingSystem isVMSlike ifTrue:[ |
675 OperatingSystem isVMSlike ifTrue:[ |
672 ^ #('.exe') |
676 ^ #('exe') |
673 ]. |
677 ]. |
674 |
678 |
675 os := OperatingSystem getSystemType. |
679 os := OperatingSystem getSystemType. |
676 (os = 'sys5_4') ifTrue:[^ #('.so') ]. |
680 (os = 'sys5_4') ifTrue:[^ #('so') ]. |
677 (os = 'iris') ifTrue:[^ #('.so') ]. |
681 (os = 'iris') ifTrue:[^ #('so') ]. |
678 (os = 'osf') ifTrue:[^ #('.so') ]. |
682 (os = 'osf') ifTrue:[^ #('so') ]. |
679 (os = 'solaris') ifTrue:[^ #('.so') ]. |
683 (os = 'solaris') ifTrue:[^ #('so') ]. |
680 (os = 'sunos') ifTrue:[^ #('.o' '.obj' '.a') ]. |
684 (os = 'sunos') ifTrue:[^ #('o' 'obj' 'a') ]. |
681 (os = 'ultrix') ifTrue:[^ #('.o' '.obj' '.ld' '.obj.ld') ]. |
685 (os = 'ultrix') ifTrue:[^ #('o' 'obj' 'ld' 'obj.ld') ]. |
682 (os = 'linux') ifTrue:[ |
686 (os = 'linux') ifTrue:[ |
683 self loadableBinaryObjectFormat == #aout ifTrue:[ |
687 self loadableBinaryObjectFormat == #aout ifTrue:[ |
684 ^ #('.o' '.obj' '.a') |
688 ^ #('o' 'obj' 'a') |
685 ]. |
689 ]. |
686 ^ #('.so' '.o' '.obj' ) |
690 ^ #('so' 'o' 'obj' ) |
687 ]. |
691 ]. |
688 (os = 'aix') ifTrue:[^ #('.o' '.so') ]. |
692 (os = 'aix') ifTrue:[^ #('o' 'so') ]. |
689 (os = 'hpux') ifTrue:[^ #(" '.o' " '.sl') ]. |
693 (os = 'hpux') ifTrue:[^ #(" 'o' " 'sl') ]. |
690 |
694 |
691 "/ mhmh what is a useful default ? |
695 "/ mhmh what is a useful default ? |
692 |
696 |
693 ^ #('.o') |
697 ^ #('o') |
694 |
698 |
695 " |
699 " |
696 ObjectFileLoader validBinaryExtensions |
700 ObjectFileLoader validBinaryExtensions |
697 " |
701 " |
698 |
702 |
699 "Modified: / 4.5.1998 / 12:17:44 / cg" |
703 "Modified: / 1.10.1998 / 12:46:03 / cg" |
700 ! ! |
704 ! ! |
701 |
705 |
702 !ObjectFileLoader class methodsFor:'dynamic object loading'! |
706 !ObjectFileLoader class methodsFor:'dynamic object loading'! |
703 |
707 |
704 loadCPlusPlusObjectFile:aFileName |
708 loadCPlusPlusObjectFile:aFileName |
951 "load a library; search in some standard places and using |
955 "load a library; search in some standard places and using |
952 standard suffixes (i.e. no suffix should be given in the arg). |
956 standard suffixes (i.e. no suffix should be given in the arg). |
953 Returns a handle or nil. |
957 Returns a handle or nil. |
954 Use this to attach C-libraries." |
958 Use this to attach C-libraries." |
955 |
959 |
956 |s suffixes handle| |
960 |s suffixes handle libFilename| |
957 |
961 |
958 (s := aLibraryFileName asFilename suffix) isEmpty ifTrue:[ |
962 libFilename := aLibraryFileName asFilename. |
959 suffixes := self validBinaryExtensions |
963 (s := libFilename suffix) isEmpty ifTrue:[ |
|
964 suffixes := self validBinaryExtensions |
960 ] ifFalse:[ |
965 ] ifFalse:[ |
961 suffixes := Array with:'' |
966 suffixes := #('') |
962 ]. |
967 ]. |
963 |
968 |
964 "/ try each suffix ... |
969 "/ try each suffix ... |
965 suffixes do:[:aSuffix | |
970 suffixes do:[:aSuffix | |
966 |fn f| |
971 |fn f| |
967 |
972 |
968 fn := aLibraryFileName , aSuffix. |
973 fn := aLibraryFileName , '.' , aSuffix. |
969 |
974 |
970 (aLibraryFileName asFilename isAbsolute |
975 (libFilename isAbsolute |
971 or:[(aLibraryFileName startsWith:'./') |
976 or:[(aLibraryFileName startsWith:'./') |
972 or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[ |
977 or:[(aLibraryFileName startsWith:'../')]]) ifTrue:[ |
973 f := fn asFilename. |
978 f := fn asFilename. |
974 f exists ifTrue:[ |
979 f exists ifTrue:[ |
975 handle := self loadObjectFile:fn. |
980 handle := self loadObjectFile:fn. |
976 handle notNil ifTrue:[^ handle]. |
981 handle notNil ifTrue:[^ handle]. |
977 ] |
982 ] |
978 ] ifFalse:[ |
983 ] ifFalse:[ |
979 "/ try each directory |
984 "/ try each directory |
980 |
985 |
981 (LoadLibraryPath asCollectionOfSubstringsSeparatedBy:$:) |
986 (LoadLibraryPath asCollectionOfSubstringsSeparatedBy:$:) |
982 do:[:aDir | |
987 do:[:aDir | |
983 f := aDir asFilename construct:fn. |
988 f := aDir asFilename construct:fn. |
984 f exists ifTrue:[ |
989 f exists ifTrue:[ |
985 handle := self loadObjectFile:f pathName. |
990 handle := self loadObjectFile:f pathName. |
986 handle notNil ifTrue:[^ handle]. |
991 handle notNil ifTrue:[^ handle]. |
987 ] |
992 ] |
988 ] |
993 ] |
989 ] |
994 ] |
990 ]. |
995 ]. |
991 |
996 |
992 ^ nil |
997 ^ nil |
993 |
998 |
994 " |
999 " |
995 ObjectFileLoader loadLibrary:'libjpeg' |
1000 ObjectFileLoader loadLibrary:'libjpeg' |
996 " |
1001 " |
997 |
1002 |
998 "Modified: 11.4.1997 / 15:44:48 / cg" |
1003 "Modified: / 1.10.1998 / 14:38:18 / cg" |
999 ! |
1004 ! |
1000 |
1005 |
1001 loadMethodObjectFile:aFileName |
1006 loadMethodObjectFile:aFileName |
1002 "load an object file (.o-file) for a single method into the image; |
1007 "load an object file (.o-file) for a single method into the image; |
1003 This does a slightly different initialization. |
1008 This does a slightly different initialization. |
1802 |name suffixLen| |
1807 |name suffixLen| |
1803 |
1808 |
1804 " |
1809 " |
1805 first, expect the classes-name to be the fileName-base |
1810 first, expect the classes-name to be the fileName-base |
1806 " |
1811 " |
1807 name := aFileName asFilename baseName. |
1812 name := aFileName asFilename. |
1808 suffixLen := 0. |
1813 suffixLen := 0. |
1809 self validBinaryExtensions do:[:suffix | |
1814 self validBinaryExtensions do:[:suffix | |
1810 suffixLen == 0 ifTrue:[ |
1815 suffixLen == 0 ifTrue:[ |
1811 (name endsWith:suffix) ifTrue:[ |
1816 (name hasSuffix:suffix) ifTrue:[ |
1812 suffixLen := suffix size |
1817 suffixLen := suffix size + 1 |
1813 ] |
1818 ] |
1814 ] |
1819 ] |
1815 ]. |
1820 ]. |
|
1821 name := name baseName. |
1816 |
1822 |
1817 suffixLen ~~ 0 ifTrue:[ |
1823 suffixLen ~~ 0 ifTrue:[ |
1818 name := name copyWithoutLast:suffixLen |
1824 name := name copyWithoutLast:suffixLen |
1819 ]. |
1825 ]. |
1820 ^ name. |
1826 ^ name. |
1821 |
1827 |
1822 " |
1828 " |
1823 ObjectFileLoader initFunctionBasenameForFile:'libbasic.so' |
1829 ObjectFileLoader initFunctionBasenameForFile:'libbasic.so' |
1824 ObjectFileLoader initFunctionBasenameForFile:'demo.so' |
1830 ObjectFileLoader initFunctionBasenameForFile:'demo.so' |
1825 ObjectFileLoader initFunctionBasenameForFile:'demo.o' |
1831 ObjectFileLoader initFunctionBasenameForFile:'demo.o' |
1826 " |
1832 " |
1827 |
1833 |
1828 "Created: 13.7.1996 / 00:01:54 / cg" |
1834 "Created: / 13.7.1996 / 00:01:54 / cg" |
1829 "Modified: 30.10.1996 / 13:28:22 / cg" |
1835 "Modified: / 1.10.1998 / 12:47:50 / cg" |
1830 ! |
1836 ! |
1831 |
1837 |
1832 isCPlusPlusObject:handle |
1838 isCPlusPlusObject:handle |
1833 "return true, if the loaded object is a c++ object module. |
1839 "return true, if the loaded object is a c++ object module. |
1834 This is not yet fully implemented/supported." |
1840 This is not yet fully implemented/supported." |