编译一个独立的静态可执行文件

我正在尝试编译不使用动态加载程序的可执行文件(ELF 文件).我构建了一个交叉编译器,它从 linux 编译 mips,以在我制作的模拟器上使用.我在编译我的 hello.cpp 文件(hello world 程序)时声明了标志 -static-libgcc.显然这还不够.因为我的可执行文件中还有一个包含动态加载器的名称/路径的段.我使用哪些标志来生成包含需要运行的所有内容的可执行文件?我需要重建我的交叉编译器吗?

I'm trying to compile an executable (ELF file) that does not use a dynamic loader. I built a cross compiler that compiles mips from linux to be used on a simulator I made. I asserted the flag -static-libgcc on compilation of my hello.cpp file (hello world program). Apparently this is not enough though. Because there is still a segment in my executable which contains the name/path of the dynamic loader. What flags do I use to generate an executable which contains EVERYTHING needed to be run? Do I need to rebuild my cross compiler?

推荐答案

尝试使用 -static 标志?

相关文章