Direct import of Dynamic Link Libraries

Care should be taken on importing DLLs. The mechanism is designed to replace the importation of "pure" import libraries. It is possible that the .LIB file contains loadable library code in addition to the imported symbol. In such cases, the loadable library code is missing from the DLL and so cannot be loaded. SALFLIBC.LIB is such a library, the DLL SALFLIBC.DLL cannot be loaded directly since it does not contain, for example, the symbol _SALFStartup which is necessary for initialisation and to provide the application's entry point.

Direct import of dynamic link libraries require that the exported names in the DLL follow the following rules

  1. _ _stdcall symbols

The exported name is created by removing the leading underscore and does not contain the appended @ and subsequent characters

e.g. _MessageBeep@4 will be exported as MessageBeep

  1. Symbols beginning with a leading underscore

The leading underscore is removed.

  1. Other symbols

All other symbols are assumed to be exported unchanged.

 

Archive and import library generation

Archives and import libraries may be generated without any objects being loaded with the load command.

For example the following SLINK script will generate a combined RLB and import library. Note that the file command is necessary to initiate the build. Ignore the comments in brackets

archive mylib  (archive file to be called mylib.LIB)
dll   
(module name set to mylib.DLL)
addobj func1.obj
addobj func2.obj
addobj func3.obj
addobj func4.obj
export functiona
export functionb
export functionc
export functiond
export functione
export functionf
export functiong
file

 

Entry Points

The executable file needs an entry point that is called by the system loader immediately after the program has been loaded. This entry point is not the main, WinMain or LibMain function as you may think, but library startup code. The Silverfrost entry point for all executables, including DLLs is _SALFStartup. Object files produced by other compilers will have a different entry point which you will have to set explicitly.

The entry point is specified with the entry command, omitting the leading underscore. SLINK will automatically set the entry point to be _SALFStartup unless you use the entry command before any objects files have been loaded. In command line mode the entry command can be placed anywhere in the command line or script file since commands are always processed first.

e.g. The following command will set the entry point to be _SALFStartup. This is redundant since SLINK will do this for you.

ENTRY SALFStartup

You cannot change the entry point after the first object file has been loaded or if an entry command has previously been used.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited