Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 6.5.36.5.3. `elf' Extensions to the `GLOBAL' Directive ------------------------------------------------- `ELF' object files can contain more information about a global symbol than just its address: they can contain the size of the symbol and its type as well. These are not merely debugger conveniences, but are actually necessary when the program being written is a shared library. NASM therefore supports some extensions to the `GLOBAL' directive, allowing you to specify these features. You can specify whether a global variable is a function or a data object by suffixing the name with a colon and the word `function' or `data'. (`object' is a synonym for `data'.) For example: global hashlookup:function, hashtable:data exports the global symbol `hashlookup' as a function and `hashtable' as a data object. You can also specify the size of the data associated with the symbol, as a numeric expression (which may involve labels, and even forward references) after the type specifier. Like this: global hashtable:data (hashtable.end - hashtable) hashtable: db this,that,theother ; some data here .end: This makes NASM automatically calculate the length of the table and place that information into the `ELF' symbol table. Declaring the type and size of global symbols is necessary when writing shared library code. For more information, see *Note Section 8.2.4::. automatically generated by info2www version 1.2.2.9 |