I am creating assembly code from C code with gcc.exe -S -masm=intel -o filename.S filename.c. I declared some variables as extern to allow later linking. I expected something like extern variable in nasm, but the variable is never mentioned in the assembly file.
Is there a way to check if a variable is extern or not? Or can I force gcc to add this information to the assembly file?
If your extern variable is not mentioned in the assembly file, you're likely not using this variable. However, even if you were using it, you wouldn't see anything like .extern varname in assembly as well. GNU assembler treats all undefined symbols as external ones. GCC knows this and doesn't emit .extern directives. So look for, uhm, "PC-relative" variables (like in mov eax, DWORD PTR varname[rip]). That's your extern vars.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With