Accessing global variable defined in C from Asm
问题 I have a C file which contain a global variable foo. How I can access foo from another assemby program. I am using i586-elf-as (GNU assembler) and i586-elf-gcc (gnu compiler) for building. 回答1: You can just use the symbol name; as treats all undefined symbols as external. Check compiler output ( gcc -S ) and/or documentation to find out if C variable names get a leading _ prepended or not. ( int myglobal becomes asm _myglobal on many non-ELF platforms, but still myglobal on Linux/ELF.) And of