Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GCC编译器、插件和结构_C_Gcc_Gcc Plugins - Fatal编程技术网

GCC编译器、插件和结构

GCC编译器、插件和结构,c,gcc,gcc-plugins,C,Gcc,Gcc Plugins,我有这样的场景: int open_ext2 () {} int close_ext2 () {} int read_ext2 () {} int write_ext2 () {} const struct fs_callbacks FS = { open_file: open_ext2, close_file: close_ext2, read_bytes: read_ext2, write_bytes: write_ext2 }; void main()

我有这样的场景:

int open_ext2 () {}
int close_ext2 () {}
int read_ext2 () {}
int write_ext2 () {}


const struct fs_callbacks FS = {
    open_file: open_ext2,
    close_file: close_ext2,
    read_bytes: read_ext2,
    write_bytes: write_ext2
};

void main(){
    FS.close_file();
}
D.1796 = close_ext2;
D.1796 ();
当我看gimple表示时(使用
-fdump tree all
编译) 我看到这样的情况:

int open_ext2 () {}
int close_ext2 () {}
int read_ext2 () {}
int write_ext2 () {}


const struct fs_callbacks FS = {
    open_file: open_ext2,
    close_file: close_ext2,
    read_bytes: read_ext2,
    write_bytes: write_ext2
};

void main(){
    FS.close_file();
}
D.1796 = close_ext2;
D.1796 ();
我没有得到的是分配在哪里发生
open\u文件:open\u ext2

我的问题

  • GCC是如何做到这一点的
  • 什么时候发生的
  • 有没有办法计算出映射标签->成员函数

找到了答案

gcc选项
-fdump tree original raw
转储信息

使用GCC插件:

  • 使用pass插件\u FINISH\u DECL
  • 在GCC源代码中查看文件:
    GCC/tree dfa.c

找到了答案

gcc选项
-fdump tree original raw
转储信息

使用GCC插件:

  • 使用pass插件\u FINISH\u DECL
  • 在GCC源代码中查看文件:
    GCC/tree dfa.c

它可能被优化了,因为它没有被使用。gimple向我展示了它被使用过。与其编辑问题以添加解决方案,不如将其作为答案发布!回答你自己的问题是不被禁止的(甚至在页面上有直接回答问题的选项)我修改了帖子并发布了一个答案。它可能被优化了,因为它没有被使用。gimple向我展示了它被使用过。与其编辑问题来添加解决方案,不如将它作为答案发布!回答你自己的问题是不被禁止的(甚至在页面上有直接回答问题的选项)。我修改了帖子并发布了答案。