context:
linux 64.
i way tell gcc keep structure when generating assembly gcc -o0 -s -g myprog.c
by that, mean: instead of referencing structure address, them referenced label. ease parsing without reading source code again.
so, example:
struct mystruct{ int32_t a; char * b; }
would become like:
label_mystruct: -4(label_mystruct) -12(label_mystruct)
and example, referenced by:
add $56, -4(label_mystruct)
currently, referenced like
.globl _main _main: lfb13: lm157: pushq %rbp # lcfi27: movq %rsp, %rbp#, lcfi28: subq $80, %rsp#, movl %edi,-68(%rbp) # argc, argc, movq %rsi,-80(%rbp) # argv, argv next line culprit: movq -56(%rbp), %rdx # list, d.3781 movq -16(%rbp), %rax # arr, d.3780 movq %rdx, %rsi # d.3781, movq %rax, %rdi # d.3780, call _myaddhu #
i
label_mystruct: -4(label_mystruct) -12(label_mystruct) .globl _main _main: lfb13: lm157: pushq %rbp # lcfi27: movq %rsp, %rbp#, lcfi28: subq $80, %rsp#, movl %edi,-68(%rbp) # argc, argc, movq %rsi,-80(%rbp) # argv, argv fine: movq label_mystruct, %rdx # list, d.3781 movq -16(%rbp), %rax # arr, d.3780 movq %rdx, %rsi # d.3781, movq %rax, %rdi # d.3780, call _myaddhu #
question:
is possible gcc , without using external tools?
you if put struct static storage. of course alters meaning of code. example, code
struct { int a, b; } test; int settest(int a, b) { test.a = a; test.b = b; }
compiles (cleaned up):
settest: movl %edi, test(%rip) movl %esi, test+4(%rip) ret .comm test,8,4
you try pass option -fverbose-asm
gcc instructs gcc add annotations might make assembly easier read.
Comments
Post a Comment