dynamic-linking

Getting VBox Guest Addtions for Android x86

╄→гoц情女王★ 提交于 2019-12-04 03:18:49
I am running Android x86 on VirtualBox, and I want the pointer integration enabled, which needs VirtualBox Guest Additions to be installed on the guest OS. I have searched a lot, but what I have found is that one has to compile Guest Additions with Android-x86 kernel headers. Can anyone please share how to do this? Thanks in advance. Graveen The VMs provided by Genymotion have theses features integrated (at least for the mouse pointer capture/release which is automagically done). So I don't have the solution, but it's at least completed on a commercial software providing VirtualBox-compatible

How lazy can C++ global initialization be?

假装没事ソ 提交于 2019-12-04 02:43:11
I'm used to thinking of all initialization of globals/static-class-members as happening before the first line of main(). But I recently read somewhere that the standard allows initialization to happen later to "assist with dynamic loading of modules." I could see this being true when dynamic linking: I wouldn't expect a global initialized in a library to be initialized before I dlopen'ed the library. However, within a grouping of statically linked together translation units (my app's direct .o files) I would find this behavior very unintuitive. Does this only happen lazily when dynamically

Why do some DLL files need an additional .lib file for linking?

Deadly 提交于 2019-12-04 00:53:26
I have a question about library linking and .lib files... this is the context: OS = Windows IDE = QT I have created a DLL: MyLib.dll. To use that library in my QT project, I only have to include an include path, a link to the library and use the header files: LIBS += "C:\myPath\MyLib.dll" INCLUDEPATH += "C:\myPath" HEADERS += \ ../myPath/MyLib_global.h \ ../myPath/mylib.h I am using a third party dll in my project: third.dll If I do the same as in the above example, it does not work: LIBS += "C:\myPath\third.dll" The third party DLL comes with a .lib file "third.lib", which I apparently need

Download and execute iOS code dynamically at runtime

前提是你 提交于 2019-12-03 16:26:36
As an academic and mental exercise, how would one download a precompiled binary file and execute methods in it on an iOS device? I understand this violates Apple's License Agreement, section 3.2.2, but I am asking for personal projects and to learn more about the iOS runtime. Goal Download http://someexample.com/MyCoolBinary.a Save downloaded binary to device disk. Call a known method that exists in the binary. What I've tried I haven't attempted anything concrete, but I would imagine that it would be possible to do something along the lines of... void *myDownloadedLibrary = dlopen("/path/to

About the -ldl flag while compiling and linking C++ files

左心房为你撑大大i 提交于 2019-12-03 14:43:18
With reference to the following code test_linker.cpp int main() { srand(time(0)); for (int i = 0; i < 10; ++i) { cout << rand() % 10 << endl; } return 0; } urandom.cpp #include <iostream> using std::cout; using std::endl; #include <dlfcn.h> int rand() throw() { // get the original rand() function static auto original_rand = (decltype(&rand)) dlsym(RTLD_NEXT,"rand"); cout << "Call made to rand()" << endl; return original_rand(); } When I try to compile the code with the following command g++ -std=c++11 -Wall -Werror -Wextra -Wvla -pedantic -O3 urandom.cpp -c g++ -std=c++11 -Wall -O3 test_linker

Destructor of a global static variable in a shared library is not called on dlclose

China☆狼群 提交于 2019-12-03 13:44:11
In a main program, I dlopen and dlclose ( LoadLibrary and FreeLibrary respectively) a shared library. The shared library contains a static variable that is instantiated upon dlopen , and destroyed upon dlclose . This behavior is consistent on MSVC 2008 and 2013, GCC 3.4.6, and Sunstudio 12.1. With GCC 4.9.1 and GCC 5.2.1 however, the destructor was no longer called on dlclose . Instead, it was called before program exit. The particularity of the static variable's class, is that in the constructor, there is a call to a templated function get (of global scope) that returns a local static

Patching code/symbols into a dynamic-linked ELF binary

谁都会走 提交于 2019-12-03 13:41:41
Suppose I have an ELF binary that's dynamic linked, and I want to override/redirect certain library calls. I know I can do this with LD_PRELOAD , but I want a solution that's permanent in the binary, independent of the environment, and that works for setuid/setgid binaries, none of which LD_PRELOAD can achieve. What I'd like to do is add code from additional object files (possibly in new sections, if necessary) and add the symbols from these object files to the binary's symbol table so that the newly added version of the code gets used in place of the shared library code. I believe this should

@rpath for a dynamic library embedded in a framework

北城余情 提交于 2019-12-03 12:33:56
I have an app, call it Animal.app . Inside its Contents/Frameworks folder is a framework, say Mammal.framework . And inside the Versions/A/Frameworks folder of the framework, I have dog.dylib . The install name of dog.dylib is @rpath/dog.dylib. For the "Runpath Search Paths" setting of the framework, I have specified @loader_path/../Frameworks . (My reasoning for that last setting is that the "loader" of the dylib would be the binary of the framework, at the path Mammal.framework/Versions/A/Mammal .) I get an error message at runtime: Dyld Error Message: Library not loaded: @rpath/dog.dylib

why do we need the shared library during compile time

孤者浪人 提交于 2019-12-03 12:21:49
Why we need the presence of the shared library during the compile time of my executable? My reasoning is that since shared library is not included into my executable and is loaded during the runtime, it is not supposed to be needed during compile time. Or Am I missing something? #include<stdio.h> int addNumbers(int, int); //prototype should be enough, no? int main(int argc, char* argv[]){ int sum = addNumbers(1,2); printf("sum is %d\n", sum); return 0; } I had the libfoo.so in my current dir but I changed its name to libfar.so to find that shared lib is needed at compile or it doesn't compile.

Problems with LD_PRELOAD and calloc() interposition for certain executables

风流意气都作罢 提交于 2019-12-03 08:04:50
Relating to a previous question of mine I've successfully interposed malloc , but calloc seems to be more problematic. That is with certain hosts, calloc gets stuck in an infinite loop with a possible internal calloc call inside dlsym . However, a basic test host does not exhibit this behaviour, but my system's "ls" command does. Here's my code: // build with: g++ -O2 -Wall -fPIC -ldl -o libnano.so -shared Main.cc #include <stdio.h> #include <dlfcn.h> bool gNanoUp = false;// global // Function types typedef void* (*MallocFn)(size_t size); typedef void* (*CallocFn)(size_t elements, size_t size)