Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 8.2.38.2.3. Finding External and Common Data Items --------------------------------------------- If your library needs to get at an external variable (external to the _library_, not just to one of the modules within it), you must use the `..got' type to get at it. The `..got' type, instead of giving you the offset from the GOT base to the variable, gives you the offset from the GOT base to a GOT _entry_ containing the address of the variable. The linker will set up this GOT entry when it builds the library, and the dynamic linker will place the correct address in it at load time. So to obtain the address of an external variable `extvar' in `EAX', you would code mov eax,[ebx+extvar wrt ..got] This loads the address of `extvar' out of an entry in the GOT. The linker, when it builds the shared library, collects together every relocation of type `..got', and builds the GOT so as to ensure it has every necessary entry present. Common variables must also be accessed in this way. automatically generated by info2www version 1.2.2.9 |