- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试使用 ld
直接链接以隔离构建问题。
当我包含 /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so
时,我遇到了一些问题:
ac-aaa.o: In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.7/iostream:75: undefined reference to `__dso_handle'
ac-callback.o: In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.7/iostream:75: undefined reference to `__dso_handle'
...
正在搜索 __dso_handle
:
$ grep __dso_handle /usr/lib/gcc/x86_64-linux-gnu/4.7/*
Binary file /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus matches
Binary file /usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o matches
Binary file /usr/lib/gcc/x86_64-linux-gnu/4.7/crtbeginS.o matches
Binary file /usr/lib/gcc/x86_64-linux-gnu/4.7/crtbeginT.o matches
crtbegin.o
、crtbeginT.o
和 crtbeginS.o
有什么区别?
最佳答案
你会在这里找到很好的解释:http://dev.gentoo.org/~vapier/crt.txt
我将在后面引用它,以防该 URL 消失。
Some definitions:
PIC - position independent code (-fPIC)
PIE - position independent executable (-fPIE -pie)
crt - C runtime
crt0.o crt1.o etc...
Some systems use crt0.o, while some use crt1.o (and a few even use crt2.o
or higher). Most likely due to a transitionary phase that some targets
went through. The specific number is otherwise entirely arbitrary -- look
at the internal gcc port code to figure out what your target expects. All
that matters is that whatever gcc has encoded, your C library better use
the same name.
This object is expected to contain the _start symbol which takes care of
bootstrapping the initial execution of the program. What exactly that
entails is highly libc dependent and as such, the object is provided by
the C library and cannot be mixed with other ones.
On uClibc/glibc systems, this object initializes very early ABI requirements
(like the stack or frame pointer), setting up the argc/argv/env values, and
then passing pointers to the init/fini/main funcs to the internal libc main
which in turn does more general bootstrapping before finally calling the real
main function.
glibc ports call this file 'start.S' while uClibc ports call this crt0.S or
crt1.S (depending on what their gcc expects).
crti.o
Defines the function prologs for the .init and .fini sections (with the _init
and _fini symbols respectively). This way they can be called directly. These
symbols also trigger the linker to generate DT_INIT/DT_FINI dynamic ELF tags.
These are to support the old style constructor/destructor system where all
.init/.fini sections get concatenated at link time. Not to be confused with
newer prioritized constructor/destructor .init_array/.fini_array sections and
DT_INIT_ARRAY/DT_FINI_ARRAY ELF tags.
glibc ports used to call this 'initfini.c', but now use 'crti.S'. uClibc
also uses 'crti.S'.
crtn.o
Defines the function epilogs for the .init/.fini sections. See crti.o.
glibc ports used to call this 'initfini.c', but now use 'crtn.S'. uClibc
also uses 'crtn.S'.
Scrt1.o
Used in place of crt1.o when generating PIEs.
gcrt1.o
Used in place of crt1.o when generating code with profiling information.
Compile with -pg. Produces output suitable for the gprof util.
Mcrt1.o
Like gcrt1.o, but is used with the prof utility. glibc installs this as
a dummy file as it's useless on linux systems.
crtbegin.o
GCC uses this to find the start of the constructors.
crtbeginS.o
Used in place of crtbegin.o when generating shared objects/PIEs.
crtbeginT.o
Used in place of crtbegin.o when generating static executables.
crtend.o
GCC uses this to find the start of the destructors.
crtendS.o
Used in place of crtend.o when generating shared objects/PIEs.
General linking order:
crt1.o crti.o crtbegin.o [-L paths] [user objects] [gcc libs] [C libs] [gcc libs] crtend.o crtn.o
More references:
http://gcc.gnu.org/onlinedocs/gccint/Initialization.html
关于c++ - crtbegin.o、crtbeginT.o 和 crtbeginS.o 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22160888/
我正在尝试使用 ld 直接链接以隔离构建问题。 当我包含 /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so 时,我遇到了一些问题: ac-aaa.o: In
gcc 使用 crtbegin.o 和 crtend.o 的目的是什么? 最佳答案 这些文件包含处理 C++ 全局构造函数和析构函数的代码。 关于gcc crtbegin crtend,我们在Stac
当使用 Android x86 工具链调试链接错误(undefined reference to _dso_handle)时,我注意到它正在静态链接 crtbegin_dynamic.o。这个文件的用
我尝试使用gc-sections、ffunction-sections和fdata-sections来优化可执行文件。我还将带有 -u (未定义)的 init 函数提供给链接器。我的 init 函数和
我想安装 llvm-clang 但在工作时没有 root 权限。我们的许多软件包都已过时,因此我将所有内容都本地安装在我的主目录下。 我安装了 cmake 和 gcc,但现在在安装 llvm 时出现错
除了使用 -nostdlib 和自己链接 crt1.o -lc -lgcc 之外,还有什么简单的方法可以防止 gcc 链接 crtbegin[S] .o 和 crtend[S].o?这些文件不是那么大
当使用 GCC 编译大多数东西时,我得到这个错误: /..//bin/ld: cannot find crtbeginS.o: No such file or directory crtbeginS.
我是一名优秀的程序员,十分优秀!