Capriccio (study of uclibc)

[Disclaimer: All rights reserved, welcome to reprint, please do not use for commercial purposes. Contact email: feixiaoxing @163.com


    For cross toolchains, uclibc is generally included in the toolchain. Through uclibc, you can develop applications on other CPUs just like developing x86 user programs. Compared with glibc, uclibc contains fewer files, and the functions are also deleted, and each directory represents a dynamic library, which basically does not encounter any problems when reading.


1. What about the code of uclibc?

It is recommended to find a uclibc directly on github, such as https://github.com/klee/klee-uclibc


2. What does uclibc watch?

It is recommended to look at the source code of ld.so and libc.so in the early stage, and the code of other dynamic libraries in the later stage.


3. What is the role of ld.so and libc.so?

ld.so is mainly responsible for dynamic library loading, .got.plt filling, libc.so is mainly responsible for memory allocation, signal, character processing and other functions


4. Are ld.so and libc.so user programs?

Like hello_world, all resources depend on syscall


5. What is the relationship between ld.so, libc.so and syscall?

ld.so and libc.so may or may not use syscall

For example, the memory allocation in malloc must use syscall, but strlen is not used

Also, a dynamic library api may involve several syscalls, which are all possible


6. How ld.so, libc.so and kernel interact

First, execve executes the function, and after handing it over to ld.so, continue to complete the rest of the work, and then jump to the main function in libc.so

If other dynamic library functions are found in the user app, ld is responsible for .got.plt loading


7. What tools are required for a complete program?

First, the linker is responsible for .got.plt, .plt creation

Then the operating system is responsible for fork, execve, open, read, and write operations, mainly reading the file into memory, and passing parameters to the loader at the same time

Finally, the loader completes the execution of the executable file


8. When linking statically, is it not necessary to use uclibc?

No, when static linking, the functions in dynamic libraries such as ld.so and libc.so are all left in the executable file, which can be seen by disassembly


9. Why does uclibc share some data structures with the kernel?

The kernel needs to process some data when the user syscalls, and the data format must be consistent


10. What are the benefits of knowing uclibc?

Overcome the fear of embedded, debugging software is more handy




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324521043&siteId=291194637