相关疑难解决方法(0)

Why are global variables in x86-64 accessed relative to the instruction pointer?

I have tried to compile c code to assembly code using gcc -S -fasm foo.c. The c code declare global variable and variable in the main function as shown below:

int y=6;
int main()
{
        int x=4;
        x=x+y;
        return 0;
}
Run Code Online (Sandbox Code Playgroud)

now I looked in the assembly code that has been generated from this C code and I saw, that the global variable y is stored using the value of the rip instruction pointer.

I thought that only const …

c compiler-construction assembly x86-64

4
推荐指数
2
解决办法
340
查看次数

标签 统计

assembly ×1

c ×1

compiler-construction ×1

x86-64 ×1