有没有什么办法让一个c函数的大小? [英] Is there any way to get the size of a c function?

查看:76
本文介绍了有没有什么办法让一个c函数的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法在运行时获得C函数的大小在内存中。

我用这个code,但它不工作:

 的#include<&stdio.h中GT;
#包括LT&;&stdlib.h中GT;
#包括LT&;&STDDEF.H GT;INT主要(无效)
{
    INT T [10];
    焦炭℃;
    offsetof(T,P);
    电话号码:
    返回0;
}


解决方案

答案通常是否定的。你不能。一个原因是因为功能不一定在存储器中连续。因此,他们没有大小。有时,编译器(即ICC)将跳出功能二进制的一个偏远地区,并在跳回来。

在这里看到一个相关的问题:

<一个href=\"http://stackoverflow.com/questions/7354507/how-to-find-function-boundaries-in-binary-$c$c/7354552#7354552\">how找到二进制code 函数边界

I want to know if there is a way to get the size of c function in memory at runtime.

I've used this code but it's not working:

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>

int main(void)
{
    int t[10];
    char c;
    offsetof(t, p);
    p: 
    return 0;
}

解决方案

The answer is generally no. You can't. One reason is because functions are not necessarily contiguous in memory. So they don't have a "size". Sometimes, compilers (namely ICC) will make jumps out of the function to a remote part of the binary and jump back in.

See a related question here:

how to find function boundaries in binary code

这篇关于有没有什么办法让一个c函数的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆