Questions tagged [libc]
The C standard library consists of a set of sections of the ISO C standard which describe a collection of headers and library routines used to implement common operations, such as input/output and string handling, in the C programming language.
libc
1,127
questions
3
votes
2
answers
85
views
Interpreting the format specifier in printf("%.-1f", 34.14)
Consider the following invocation of printf():
printf("%.-1f", 34.14);
it specifies a negative precision value of -1. Making this call with glibc, we get:
%0.-1f
is this correct? If so, ...
5
votes
1
answer
78
views
Intercept open syscall in C, when called via fopen
I'm trying to code up a (limited) in-memory file system redirects via libc/syscall interception and returning memfd_create-produced file descriptors for the files that are virtualized. As a ...
0
votes
1
answer
79
views
Is there anyway to compile a Rust program without a dependency on a libc for Linux?
Is there anyway I could compile a Rust program to a binary which does not depend on a libc for runtime and for Linux?
1
vote
0
answers
30
views
Self build toolchains for RISC-V lacking correct libc
I'm trying to bootstrap compile the toolchains for Vortex, which is an open source GPGPU based on RISC-V ISA. I followed the README.vortex in the pocl source file pulled from https://github.com/...
0
votes
0
answers
115
views
What is the difference between libgcc and libc?
I need to use the C standard to compile with my POSIX implementation. I downloaded the precompiled lib of gcc-11.2, but after unzipping, I am facing libgcc.a and libc.a libraries.
I tried to compile ...
0
votes
0
answers
16
views
Questions on tls.offset calculation in musl libc
I am reading musl libc source code.
In load_library function in ldso/dynlink.c, I noticed a formula calculating p->tls.offset, here is the snippet:
#ifdef TLS_ABOVE_TP
p->tls.offset = ...
2
votes
1
answer
102
views
Can I point CMake to use the (older) libc of a different rootfs?
I'm moving this here from the CMake Discourse. I’m trying to set up CMake to cross compile an application that will run on an old (Debian stretch ~2017) Linux system (functioning, but slow, so I'd ...
0
votes
1
answer
110
views
C++ and syscalls: ignoring return value and checking errno instead
Error checking in C is a task that is very verbose and makes the code unreadable. In C++ you have exceptions, but when I use C++ to call C functions, the headaches come back. I wish there was a "...
4
votes
0
answers
87
views
Why is the argument `nelp` in POSIX's `lfind` function (search.h) not `const`?
POSIX Issue 7, 2018 defines the prototype of function lfind in search.h as:
void *lfind(const void *, const void *, size_t *,
size_t, int (*)(const void *, const void *));
Or, more ...
0
votes
0
answers
117
views
How to install libc debug symbols (libc6-dbg) on Ubuntu 20.04? /usr/lib/debug empty after installing libc6-dbg
I need the debug symbols for libc on Ubuntu 20.04 for performance profiling in gperftools (or perf). I checked how to install them and used:
sudo apt-get install libc6-dbg
After successfull ...
0
votes
1
answer
75
views
Extra Bytes Added to Packet When Sending via Raw Socket
Description
I'm currently trying to send packets via a raw socket in Rust. I'm currently using libc to manage the socket.
I've had success with sending the packet but the packet sent is never the same ...
0
votes
1
answer
88
views
Segfault on calling function pointer obtained with dlopen() in Rust
I am currently playing with POSIX functions defined in dlfcn.h with Rust, with the goal of calling a function in a separated .so file.
The project actually contains 2 crates:
The binary loading the ...
0
votes
2
answers
75
views
Why "all warnings being treated as errors" occurs even added "set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)" to CMakeLists.txt?
I'm building the llvm-18.1.3 and facing the all warnings being treated as errors error as follows:
/home/pi/llvm-project-llvmorg-18.1.3/libc/src/stdlib/bsearch.cpp:16:28: error: ‘void* ...
0
votes
1
answer
67
views
attempting to link libc statically with clang, ldd showing dynamic linking?
I'd like to compile a C program with system libraries (such as libc) linked statically, with all my other custom libraries (such as openssl) linked dynamically. When I compile a "Hello World"...
1
vote
1
answer
75
views
Compiling without a standard library but with the _start label (entry point)
I am building my own 32-bit x86 OS in which I load user programs from ELF files. When compiling the user C programs I use -nostdlib to exclude GLIBC and link my own LIBC instead. The problem is that ...