linker

How to extend a ELF binary

有些话、适合烂在心里 提交于 2020-03-28 03:55:00
问题 I am writing a small instrumentation tool. I must insert the instrumentation routine within the binary file. A good approach should be to insert those routines in a separate code segment and a separate data segment, could you explain how to accomplish this? Furthemore how can I modify the size of the code segment in the original file? Best, 回答1: I must insert the instrumentation routine within the binary file. A good approach should be to insert those routines in a separate code segment and a

Using cmake to build a static library of static libraries

前提是你 提交于 2020-03-19 06:30:33
问题 I'm trying to create a static library of static libraries. Here's my CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(myRtspClient) add_subdirectory(../third_party/Base64_live555 base64_live555) add_subdirectory(../third_party/md5 md5) add_subdirectory(../third_party/JRTPLIB jrtplib) include_directories(include) include_directories(../third_party/Base64_live555/include) include_directories(../third_party/md5/include) include_directories(jrtplib/src) include_directories(../third

Enabling link-time optimizations causes a linker error?

耗尽温柔 提交于 2020-03-19 02:41:09
问题 I have code which compiles and links fine. I'm now trying to enable link-time optimizations, but adding -flto to my compiler and linker flags is causing a linker error: /usr/local/lib/libboost_thread.a(thread.o): \ In function `void boost::throw_exception<boost::bad_lexical_cast>(boost::bad_lexical_cast const&)': thread.cpp:(.text._ZN5boost15throw_exceptionINS_16bad_lexical_castEEEvRKT_[_ZN5boost15throw_exceptionINS_16bad_lexical_castEEEvRKT_]+0x124): \ undefined reference to `vtable for

Enabling link-time optimizations causes a linker error?

不打扰是莪最后的温柔 提交于 2020-03-19 02:41:05
问题 I have code which compiles and links fine. I'm now trying to enable link-time optimizations, but adding -flto to my compiler and linker flags is causing a linker error: /usr/local/lib/libboost_thread.a(thread.o): \ In function `void boost::throw_exception<boost::bad_lexical_cast>(boost::bad_lexical_cast const&)': thread.cpp:(.text._ZN5boost15throw_exceptionINS_16bad_lexical_castEEEvRKT_[_ZN5boost15throw_exceptionINS_16bad_lexical_castEEEvRKT_]+0x124): \ undefined reference to `vtable for

How exactly does linking work?

北慕城南 提交于 2020-03-17 05:00:25
问题 The way I understand the compilation process: 1) Preprocessing: All of your macros are replaced with their actual values, all comments are removed, etc. Replaces your #include statements with the literal text of the files you've included. 2) Compilation: Won't drill down too deep here, but the result is an assembly file for whatever architecture you are on. 3) Assembly: Takes the assembly file and converts it into binary instructions, i.e., machine code. 4) Linking: This is where I'm confused

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++

会有一股神秘感。 提交于 2020-03-16 07:34:24
问题 why am i getting this error? g++ -m32 func.o test.o -o prgram /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++ collect2: error: ld returned 1 exit status my code is as follows: #include<stdio.h> 2 3 4 extern "C" int calcsum(int a, int b, int c); 5 6 int main(int argc,char* argv[]) 7 { 8 int a =

Can't link a shared library from an x86-64 object from assembly because of PIC

女生的网名这么多〃 提交于 2020-03-14 14:50:35
问题 I'm porting a shared library from 32-bit to 64-bit. It's composed of some assembly (written for NASM) that exports several procedures and a little bit of higher-level C glue code. I'm building on a 64-bit Debian machine with NASM 2.10.01 and GNU ld 2.22. Having fixed all the push/pop issues (pushing 32-bit parts of registers obviously won't work in 64-bit mode), I've got the object to assemble, but now I'm halted by the linking stage. Here are my command lines - assembly: nasm -Ox -dPTC_ARCH

Can't link a shared library from an x86-64 object from assembly because of PIC

依然范特西╮ 提交于 2020-03-14 14:47:27
问题 I'm porting a shared library from 32-bit to 64-bit. It's composed of some assembly (written for NASM) that exports several procedures and a little bit of higher-level C glue code. I'm building on a 64-bit Debian machine with NASM 2.10.01 and GNU ld 2.22. Having fixed all the push/pop issues (pushing 32-bit parts of registers obviously won't work in 64-bit mode), I've got the object to assemble, but now I'm halted by the linking stage. Here are my command lines - assembly: nasm -Ox -dPTC_ARCH

Can't link a shared library from an x86-64 object from assembly because of PIC

六眼飞鱼酱① 提交于 2020-03-14 14:45:05
问题 I'm porting a shared library from 32-bit to 64-bit. It's composed of some assembly (written for NASM) that exports several procedures and a little bit of higher-level C glue code. I'm building on a 64-bit Debian machine with NASM 2.10.01 and GNU ld 2.22. Having fixed all the push/pop issues (pushing 32-bit parts of registers obviously won't work in 64-bit mode), I've got the object to assemble, but now I'm halted by the linking stage. Here are my command lines - assembly: nasm -Ox -dPTC_ARCH

How do I access arguments for a new Main Function in C++?

半世苍凉 提交于 2020-03-05 02:55:07
问题 I have a new main function that I asked the linker to point to in the Visual Studio. I can correctly execute this function. However the command line arguments that I am getting is not correct. Currently this is my signature int NewMain(int argc, const char* argv[]) { cout << "New Main" << endl; for (int i = 0; i < argc; ++i) { cout << argv[i] << "\n"; } return 0; } However when I use the same function with the standard main, I am getting all the arguments. 回答1: When you specify an entry point