GNU Info

Info Node: (nasm.info)Section 8.2.3

(nasm.info)Section 8.2.3


Next: Section 8.2.4 Prev: Section 8.2.2 Up: Section 8.2
Enter node , (file) or (file)node

8.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