dynamic-loading

Is it safe to call dlclose(NULL)?

怎甘沉沦 提交于 2021-02-05 02:52:52
问题 I experience a crash when I pass a null pointer to dlclose . Should I check for null before calling dlclose ? POSIX tells nothing about this: http://pubs.opengroup.org/onlinepubs/7908799/xsh/dlclose.html Is it undefined behaviour or a bug in dlclose implementation? 回答1: This is tricky. POSIX states that if handle does not refer to an open object, dlclose() returns a non-zero value from which you could infer that it should detect, for an arbitrary pointer, whether that pointer refers to an

How can a shared library know where it resides?

拥有回忆 提交于 2021-01-28 00:44:31
问题 I'm developing a shared library for linux machines, which is dynamically loaded relative to the main executable with rpath. Now, the library itself tries to load other libraries dynamically relative to its location but without rpath (I use scandir to search for shared libraries in a certain folder - I don't know their names yet). This works only, if the working directory is set to the shared libraries location, as otherwise I look in a different directory as intended. Is there any practical,

How to understand the difference between Offset and VirAddr in Program Headers in elf?

旧街凉风 提交于 2020-06-28 05:43:18
问题 There is a shared library elf file, I use readelf -l to see the program headers, the output is: Elf file type is DYN (Shared object file) Entry point 0x0 There are 11 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x00000034 0x00000034 0x00100 0x00100 R 0x4 INTERP 0x000194 0x00000194 0x00000194 0x00013 0x00013 R 0x1 [Requesting program interpreter: /system/bin/linker] LOAD 0x000000 0x00000000 0x00000000 0x3aa8c4

How to compile runtime-generated Angular8 code?

风格不统一 提交于 2020-06-08 12:40:37
问题 I'm creating Angular code at runtime, in particular, I use a SVG library in order to create a vector graphic that contains Angular code directives like (click)='myMethod()' , which, in turn, call methods I've statically defined in the SVG-enclosing component. Being generated at runtime I need to compile the created template and add it to a component. I implemented such code back then with Angular 3 with the help of this post which was quite cumbersome. I tried to the copy the old code in an

How to compile runtime-generated Angular8 code?

白昼怎懂夜的黑 提交于 2020-06-08 12:40:28
问题 I'm creating Angular code at runtime, in particular, I use a SVG library in order to create a vector graphic that contains Angular code directives like (click)='myMethod()' , which, in turn, call methods I've statically defined in the SVG-enclosing component. Being generated at runtime I need to compile the created template and add it to a component. I implemented such code back then with Angular 3 with the help of this post which was quite cumbersome. I tried to the copy the old code in an

Static member variable for class that is dynamically loaded

强颜欢笑 提交于 2020-03-19 19:52:39
问题 If I were to load up some symbols using something like dlopen in C++ while other classes in that translation unit had static member variables what exactly is the behavior of those static member variables. Do they get initialized or no because the library isn't really loaded just the symbols that you looked up (which I'm thinking the latter is not true because if the symbol you looked up needs those they need to be loaded too)? 回答1: In short, there's no guarantee that static variables that

Static member variable for class that is dynamically loaded

余生颓废 提交于 2020-03-19 19:51:07
问题 If I were to load up some symbols using something like dlopen in C++ while other classes in that translation unit had static member variables what exactly is the behavior of those static member variables. Do they get initialized or no because the library isn't really loaded just the symbols that you looked up (which I'm thinking the latter is not true because if the symbol you looked up needs those they need to be loaded too)? 回答1: In short, there's no guarantee that static variables that

How is the attribute of the loader instance `cdll` created?

谁说胖子不能爱 提交于 2020-01-24 23:21:11
问题 From https://docs.python.org/3/library/ctypes.html#loading-shared-libraries Shared libraries can also be loaded by using one of the prefabricated objects, which are instances of the LibraryLoader class, either by calling the LoadLibrary() method , or by retrieving the library as attribute of the loader instance . I found an example for the first way Free the opened ctypes library in Python I was wondering how to use the second way? In particular, how is the attribute of the loader instance

compiling against a modified header file

时光总嘲笑我的痴心妄想 提交于 2020-01-06 07:42:31
问题 I have a header file with a class definition and some includes. The class contains some public functions and some private variables. The class gets compiled into an executable. Lets say that somebody takes this header file and creates a "public" copy. He removes all the includes and private variables (uses forward declarations for the undefined symbols). Then he compiles his own code (which calls the public functions of the class in question) against the "public" header file and creates an