Accessing Assembly Language Global Variables

Accessing variables from the .ebss or .bss section or a section named with .usect is straightforward:

  1. Use the .bss or .usect directive to define the variable.
  2. Use the .def or .global directive to make the definition external.
  3. Use the appropriate linkname in assembly language.
  4. In C/C++, declare the variable as extern and access it normally.

Example 4 and Example 3 show how you can access a variable defined in .ebss.