Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 8.2.28.2.2. Finding Your Local Data Items ------------------------------------ Having got the GOT, you can then use it to obtain the addresses of your data items. Most variables will reside in the sections you have declared; they can be accessed using the `..gotoff' special `WRT' type. The way this works is like this: lea eax,[ebx+myvar wrt ..gotoff] The expression `myvar wrt ..gotoff' is calculated, when the shared library is linked, to be the offset to the local variable `myvar' from the beginning of the GOT. Therefore, adding it to `EBX' as above will place the real address of `myvar' in `EAX'. If you declare variables as `GLOBAL' without specifying a size for them, they are shared between code modules in the library, but do not get exported from the library to the program that loaded it. They will still be in your ordinary data and BSS sections, so you can access them in the same way as local variables, using the above `..gotoff' mechanism. Note that due to a peculiarity of the way BSD `a.out' format handles this relocation type, there must be at least one non-local symbol in the same section as the address you're trying to access. automatically generated by info2www version 1.2.2.9 |