linker

How to 'link' object file to executable/compiled binary?

可紊 提交于 2019-12-18 10:56:10
问题 Problem I wish to inject an object file into an existing binary. As a concrete example, consider a source Hello.c : #include <stdlib.h> int main(void) { return EXIT_SUCCESS; } It can be compiled to an executable named Hello through gcc -std=gnu99 -Wall Hello.c -o Hello . Furthermore, now consider Embed.c : func1(void) { } An object file Embed.o can be created from this through gcc -c Embed.c . My question is how to generically insert Embed.o into Hello in such a way that the necessary

Is there a downside to using -Bsymbolic-functions?

狂风中的少年 提交于 2019-12-18 10:52:52
问题 I recently discovered the linker option "-Bsymbolic-functions" in GNU ld: -Bsymbolic When creating a shared library, bind references to global symbols to the definition within the shared library, if any. Normally, it is possible for a program linked against a shared library to override the definition within the shared library. This option is only meaningful on ELF platforms which support shared libraries. -Bsymbolic-functions When creating a shared library, bind references to global function

How to correctly use a simple linker script? Executable gets SIGKILL when run

半城伤御伤魂 提交于 2019-12-18 10:37:16
问题 I'm trying to understand deeper linking process and linker scripts...looking at binutils doc i found a simple linker script implementation that i've improved by adding some commands: OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH(i386) ENTRY(mymain) SECTIONS { . = 0x10000; .text : { *(.text) } . = 0x8000000; .data : { *(.data) } .bss : { *(.bss) } } My program is a very simple program: void mymain(void) { int a; a++; } Now i tried to build an executable: gcc -c main.c ld

Duplicate symbol issues

假装没事ソ 提交于 2019-12-18 10:25:32
问题 During a refactor of an iOS project, I ran into this bear of a bug. During the linking phase, I get this message: ld: duplicate symbol _OBJC_IVAR_$_TinCanViewController.currentViewController in /path/to/TinCanViewController-E98A666B7AF2673A.o and /path/to/TinCanViewController-E98A666B7AF2673A.o As far as I can tell, it looks like it claims TinCanViewController-E98A666B7AF2673A.o is declaring the specified symbol twice; both paths are pointing to the exact same .o file. I ran nm on that

gcc linker errors on fedora: undefined reference

一曲冷凌霜 提交于 2019-12-18 09:48:26
问题 I'm trying to compile/run my program (which is working fine on Windows/MSVC) on Fedora/gcc. Compilation is fine now, linking seems to be a problem. Based on symptoms and this post undefined reference to `__gxx_personality_sj0, it seemed to me that the problem might be some mismatch in compiler/linker arch type. Anyway, I'm no expert so I just uninstalled everything I found with yum list | egrep gcc|g++|c++ using yum remove and then ran yum install gcc gcc-c++ . NOTES: All output you see below

How to get this simple assembly to run?

我的未来我决定 提交于 2019-12-18 09:04:12
问题 This is my first ever attempt at programming with assembly. I'm using a 64 bit Mac OS. I'm also using NASM. I've done a lot of looking around for a solution, but I can't find anything that works for my machine. Can anyone help me solve this problem? Here is the code and error, thanks! hello.asm global start section .text start: mov rax, 1 mov rdi, 1 mov rsi, message mov rdx, 13 syscall mov eax, 60 xor rdi, rdi syscall message: db "Hello, World", 10 my attempt at executing: nasm -f macho64

warning: cannot find entry symbol nable-stdcall-fixup; defaulting

倾然丶 夕夏残阳落幕 提交于 2019-12-18 08:47:55
问题 This mingw contains gcc 4.6.3 , with name - i686-w64-mingw32. On Windows, a Qt's .pro file w.r.t a hello world program: QT += core gui TEMPLATE = app TARGET = ef SOURCES = ef.cpp DEPENDPATH += . INCLUDEPATH += . INCLUDEPATH += c:/R-2.15.1/include INCLUDEPATH += c:/R-2.15.1/library/Rcpp/include INCLUDEPATH += c:/R-2.15.1/library/RInside/include LIBS += -L c:/R-2.15.1/bin/i386 -lR LIBS += -L c:/R-2.15.1/library/Rcpp/libs/i386 -lRcpp LIBS += -L c:/R-2.15.1/library/RInside/libs/i386 -lRInside The

Undefined symbols for architecture i386:

我的梦境 提交于 2019-12-18 08:26:20
问题 I've recently moved over to a mac, and am struggling using the command line compilers. I'm using g++ to compile, and this builds a single source file fine. if I try to add a custom header file, when I try to compile using g++ I get undefined symbols for architecture i386. The programs compile fine in xCode however. Am I missing something obvious? tried using g++ -m32 main.cpp... didn't know what else to try. Okay, The old code compiled... Have narrowed it down to my constructors. class Matrix

C++: Undefined reference to instance in Singleton class

天涯浪子 提交于 2019-12-18 07:46:10
问题 I'm currently trying to implement a factory as a singleton. I practically used the textbook example of the Singleton pattern. Here's the .h file: namespace oxygen{ class ImpFactory{ public: static boost::shared_ptr<ImpFactory> GetInstance(); private: static boost::shared_ptr<ImpFactory> mInstance; }; and here's the .cpp file: #include "impfactory.h" using namespace oxygen; using namespace boost; shared_ptr<ImpFactory> ImpFactory::GetInstance(){ if (mInstance.get() == 0) mInstance = shared_ptr

LNK2022 Error When Using /clr

北城余情 提交于 2019-12-18 07:45:14
问题 I'm having a problem linking a C++ project in VS2008 when using the /clr compile option. I am getting the following build errors: Class1.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEA): (0x0200046f). Class1.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEW): (0x02000473). Class2.obj : error LNK2022: metadata operation failed (8013118D