4.1.3 Loading foreign language files
188.8.131.52 Restrictions when using the foreign loader The following rules apply when you are writing or compiling code that will be loaded or reloaded as foreign code:
- Writers of foreign code cannot assume that text, data, and bss address spaces have a particular layout in memory; with the dynamic loader, pieces of text and data are intermixed. If a module requires that all of the text (or all of the data) must lie in a continuous block, use the following command to make a single object file that follows the UNIX model:
ld -r file-names -o temp.o
- The text segment from an object file is never contiguous to the data segment from that object file, and it is unsafe to assume that text will lie below data. The information returned by
sbrk(0) is not useful.
malloc to manage memory, if possible; avoid using
- Define global variables in files that are separate from those containing the definitions of functions referring to these variables. If this is not possible and a function must be redefined in one of these files, reload new definitions for all of the variables and functions in the file that changed.
- Do not use the
-pic option when you compile C object files; loading such a file signals an error.
- Avoid functions with multiple entry points. For example, do not write C code with references like the following:
temp = &function +10; /* C code to avoid. */
The Advanced User's Guide - 9 SEP 1996
Generated with Harlequin WebMaker