Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
My question is whether Linux kernel contains libc.so.6? After googling and going through different links, we found that libc.so.6, is not a part of Linux kernel, as the kernel has same libraries implemented for its own use in kernel space. libc.so.6 is a userspace library. But, still, the question was left, if the libc.so.6 is removed from "/lib", it crashes, as all the basic applications of Linux crashes.
So, the basic questions were left on:
Can Linux run without libc.so.6? If yes, where such implementation is used?
Who provides libc.so.6? Is it provided by Linux distributions only?
Does Linux internally supports threading or not?
Yes. For example, I could write an application in assembly that did not use libc. Here are some examples: https://stackoverflow.com/questions/284797/hello-world-in-less-than-20-bytes
On Linux, glibc is a common implementation of libc: https://www.gnu.org/software/libc/
Yes. The threading options that glibc provides are a shim layer over a kernel interface.
Can Linux run without libc.so.6? If yes, where is this the case?
Compiling the code with option -nostdlib won't use standard libraries,
man GCC tells,
-nostdlib
Do not use the standard system startup files or libraries when linking. No
startup files and only the libraries you specify will be passed to the linker.
The compiler may generate calls to memcmp, memset, memcpy and memmove. These
entries are usually resolved by entries in libc. These entry points should be
supplied through some other mechanism when this option is specified.
Check webpage for good glibc free implementation.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to know how can I see the functions and the contents of a library in C language?
is nm libconfig.a | c++filt what you are looking for?
In general, you cannot see the source code of functions of a library (e.g. some libfoo.a or libfoo.so.* Linux files) compiled from C source code.
You should ask for the documentation of that library. If it is developed in house, you may need to discuss with colleagues.
I do like open source libraries like GNU libc or GTK. Because you are allowed to download their source code and study it.
Be aware of code obfuscation techniques and of Rice's theorem. Decompilation of binary libraries is legally forbidden in some countries.
But a lot of libraries are not open source.
On Linux, tools like objdump(1) or readelf(1) could be helpful.
Notice that some libraries (e.g. GNU lightning) are generating new functions and machine code at runtime. Hence the notion of function might be not as easy as you think.
On Linux, programs like my manydl.c or Bismon, or RefPerSys, or SBCL, are generating code at runtime: for manydl.c and Bismon it generates C code and dlopen(3) it after having compiled it as a plugin.
Jacques Pitrat's book Artificial Beings: the conscience of a conscious machine ISBN 978-1-84821-101-8 explains the interest of generating code at runtime. A relevant concept is partial evaluation.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is Rust entirely independent of other languages and OSs like C is, or is it not?
Is Rust entirely independent of the OS and C?
Rust normally relies on the host system to support things like I/O. But it can be independent.
For OS development, you would use no_std: an environment for Rust without host support. This environment includes the core library (a subset of the std library) with no threads, no dynamic memory, no I/O. Implementing those would be part of developing the OS.
In C, there are a few constraints you should respect, such as not using any concurrency, limiting the use of the standard library, and such.
Not exactly. In freestanding C, there are a few standard library facilities that are guaranteed to be available.
Further, whether there may be several threads of execution is implementation-defined. When developing the usual OS with SMP etc, you will need a freestanding implementation with such support.
In Rust however, I have found that you should explicitly specify certain parts of your code to use C's linking implementation rather than Rust's, and taking many more aspects of your programming behaviour into consideration.
Not exactly either. One can program an operating system using only Rust's ABI to interface with assembly files and other bits. The problem is that such ABI is not going to be stable for the foreseeable future. Therefore, if you are willing to follow the changes, you could do it. But it is simpler to use C's instead.
Another possibility to avoid dealing with an ABI is trying to do everything with inline assembly instead.
So my question is, is Rust entirely independent of other languages and OSs like C is, or is it not?
Both can be, for freestanding purposes.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Let’s assume that I wrote a primitive bootloader using assembly language. The computer is still on real mode. Now I want to write a primitive kernel and shell using C language.
Questions:
1.Do I need to write a C Language compiler in assembly for this new OS or can I use a C compiler running on a different OS? I guess it could be both!
2.If I use a C compiler from a different OS, functions like printf () can be compiled to target the BIOS’s functions instead of the OS’s API to avoid dependencies?
3.If my bootloader switch the computer into protected mode the kernel will need to implement the equivalent to the BIOS functions?
4.Assuming a YES to question 3: If I use a C compiler from a different OS what is required to make it target the new OS kernel functions? Rewriting the headers files?
(EDIT) PD: These are theoretical questions. I don’t need specific details about the actual implementation. I just want to validate the concepts. Don’t feel obligated to answer all of them!
You can do either. I would strongly recommend to just use a standard compiler though. Writing a good compiler is very complex and time consuming.
As long as you do not have an implementation of the standard library just don't use it. You can tell C-compilers to assume that there is no standard library and write your own printf-like functions.
You lose access to the BIOS functions in real mode. If you need them you do need to reimplement them.
Not much change is required actually. Executables are incomplete and require to be linked against something that implements the used standard library functions and whatever other libraries used. All you need to do is link the executable against a (possible self-written) library that somehow implements the required functions.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I know that linux kernel source is in pure c. So I want to know how can I write simple Hello, World program in pure C without using printf api?
I know that linux kernel source is in pure c.
It is most certainly not. The Linux kernal is infamous for the frequent use of non-standard extensions from the GCC compiler.
So I want to know how can I write simple Hello, World program in pure C without using printf api?
printf is just a wrapper around the OS API functions. Do you mean to ask how to write printf using only Linux API functions? Becase "pure C" is defined in the C standard ISO 9899, which has nothing to do with the Linux OS.
When running in a process in any operating system, you have no direct access to hardware resources. So there's no way to print anything without asking the OS to do it for you.
Instead of printf, you can use a lower level API, such as write.
You can go further and issue a system call yourself, using the right machine instruction (which is OS and architecture dependent). This way you won't use any library, but will still rely on the OS.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to do some learning with Linux kernel and as you all know there is nothing better than playing with the code itself, Can you please let me know which one of the Linux distros is the easiest to work with? In other words, As far as I know Ubuntu for example modify the kernel for their distro, so the question again, which distro is using the Linux kernel as is with no modification?
Appreciate your guidance.
When it comes to no-frills (no external patches to the kernel) have a look at Slackware. Or follow "Linux from Scratch", that's as bare-bones as it gets.
If you want to start playing with the Linux kernel, I'd recommend a distribution which makes it particularily easy to compile the kernel yourself. Although I cannot provide detailed guidance, Gentoo seems to do so (although gentoo has other drawbacks, I don't know a single person in real life who actually used gentoo for more than two years).
I would not try and look for distributions not modifying the kernel, it's probably not worth the effort. Patches will probably be minor compared to the overall size of the kernel.
You can easily run Ubuntu for example with a vanilla kernel by following https://wiki.ubuntu.com/KernelTeam/GitKernelBuild.