The other function calls described in the linked answer give a synopsis of what needs to happen; the actual implementation details in the GNU C library are different, either using “constructors” (_dl_start_user), or explicitly in __libc_start_main. __libc_start_main also takes care of calling the user’s main, which is why you don’t see it called in your ...
The problem isn’t that the dynamic linker can’t resolve function_b, it’s that your second call to dlopen is incorrect: you need to include either RTLD_LAZY or RTLD_NOW, the other flags are complementary to those two.
One of the following two values must be included in flags:
Changing your b.so load to
handle_b = dlopen("./b.so", RTLD_NOW | ...
Depending on the cpu, the code in the .text section for calling the some_function() will be some kind of indirect call. It will compute the address at runtime, possibly caching the result for efficiency. This allows the .text to be unchanged and therefore it can be shared. The code is usually very slightly bigger and slower.
The assumption is false, ...
Two features of ELF are missing from your diagram and are used for dynamic linking: the global offset table (GOT) and the procedure linkage table (PLT). The GOT is a table of offsets used for a variety of purposes, and the PLT is a table of procedure stubs used for indirect jumps. The GOT is typically read-write; the PLT can be either read-write, or read-...
You can build the component objects of a shared library separately:
gcc -fpic -c addvec.c multvec.c
gcc -shared -fpic -o libvector.c addvec.o multvec.o
Note however that all compilation and linking steps must use the same flags. I suspect this is the main reason behind the approach used in your textbook. The static library doesn’t need position-independent ...
The Linux kernel source tree has Makefiles (many of them actually) which contain all the flags you're looking for, including -O2 which you can remove or replace with -O0.
Here's how you can change the compilation flags for all of them (which might be risky according to Stephen Kitt):
find . -name Makefile -print0 | xargs -0 sed -i 's/-O2/-O0/g'
For Linux Ubuntu (or other Debian)
sudo apt-get install python3-dev
or for CENTOS (RHEL)
(or in my case Amazon Linux 2)
sudo yum install python3-dev
ALso, I found similar answers everywhere, difference being instead of
python-dev and installing python3-dev
would result into solving my problem.
Other dependencies were also important like,
sudo yum install ...