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.

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.

There are many implementations of libc with different resource requirements, security goals, etc. With a typical tool chain the libc, compiler and OS work together to achieve some ISO, Posix or custom features/standards. Some libc implementation are only a subset of the ISO standard, but still full featured enough to be used in many applications.

Specific libc tags:

  • - the full Gnu Libc found on most GCC installs.
  • - a smaller micro-controller libc for resource constrained devices
  • - Android libc
  • - unhosted libc
  • - more modern lighter foot print libc

Websites

See also:

Do not confuse with , which is for the C++ programming language.

1076 questions
8
votes
1 answer

On Linux, is TLS set up by the kernel or by libc (or other language runtime)?

I'm just studying how TLS (thread-local storage) is implemented on Linux systems. The document ELF Handling for Thread-Local Storage explains how a program's requirements for thread-local variables can be encoded in an ELF binary, and how the…
Alex D
  • 29,755
  • 7
  • 80
  • 126
8
votes
3 answers

multi-byte characters in libc regcomp and regexec

Is there anyway to get libc6's regexp functions regcomp and regexec to work properly with multi-byte characters? For instance, if my pattern is the utf8 characters 猫机+猫, finding a match on the utf8 encoded string 猫机机机猫 will fail, where it should…
bill_e
  • 930
  • 2
  • 12
  • 24
8
votes
2 answers

Dangers of compiling with GNU Libc and running on eglibc in Linux?

I have an executable which pretty much only depends on libc. the output of ldd is: libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b53156b9000) libutil.so.1 => /lib64/libutil.so.1 (0x00002b53158d5000) librt.so.1 => /lib64/librt.so.1…
shoosh
  • 76,898
  • 55
  • 205
  • 325
8
votes
1 answer

How to create backwards-compatible dynamic linkage?

It seems that glibc 2.14 introduced a new version of memcpy (to fix bug 12518). Programs compiled against glibc 2.14+, then, will contain a dynamic link to memcpy@GLIBC_2.14, which is clearly not available in older versions of glibc. However, glibc…
Dolda2000
  • 25,216
  • 4
  • 51
  • 92
8
votes
2 answers

Why don't I get a link error when I provide my own malloc and free?

I'm trying to implement a simple fit first memory management algorithm. So I've got a C file with my own void* malloc(size_t) and void free(void*) When generating a .out file with gcc, I'm expecting a link error because it'll conflict with…
lang2
  • 11,433
  • 18
  • 83
  • 133
8
votes
1 answer

ANR in random usage of application

I have an VOIP application and the engine part is C(NDK) Level.On random usage of application i end with an ANR pointing to " at android.os.MessageQueue.nativePollOnce(Native Method)". Using android-ndk-r5 ANR Traces: ----- pid 13735 at 2013-05-23…
8
votes
5 answers

function address in libc?

I am trying to obtain the address (in hex) of function exit() provided in libc, but I am not sure where and how to find it. Anyone knows the way to find it please share some idea. Thank you!
Allan Jiang
  • 11,063
  • 27
  • 104
  • 165
8
votes
1 answer

mmap() with LD_PRELOAD and boost::interprocess does not work

I am trying to replace the original mmap() system call on a pre-identified fd via LD_PRELOAD, so that the process calling it can read a shared memory object created previously by another process with boost::interprocess. Everything goes well, except…
Martin
  • 9,089
  • 11
  • 52
  • 87
8
votes
1 answer

Implementing thread-local storage in custom libc

I'm implementing a small subset of libc for very small and statically linked programs, and I figured that adding TLS support would be a good learning experience. I use Ulrich Drepper's TLS document as a reference. I have two strings set up to try…
haste
  • 1,441
  • 1
  • 10
  • 21
8
votes
3 answers

realloc but only first few bytes is meaningful

Assume I have used ptr = malloc(old_size); to allocate a memory block with old_size bytes. Only the first header_size bytes is meaningful. I'm going to increase the size to new_size. new_size is greater than old_size and old_size is greater than…
lqs
  • 1,434
  • 11
  • 20
8
votes
2 answers

Android libc.so crash?

I'm using AndEngine with the PhysicsBox2DExtension to make a game. My game keeps crashing and I get this in the unfiltered LogCat: 07-06 13:25:27.266: I/DEBUG(19582): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 07-06…
rphello101
  • 1,671
  • 5
  • 31
  • 59
8
votes
1 answer

Installing a prebuilt binary on Android: "not found"

I'm trying to install a prebuilt binary in a custom Android image. For that I have copied it to a new directory in prebuilt/android-arm/ with an Android.mk file similar to this one: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES…
Jaime Soriano
  • 7,309
  • 2
  • 33
  • 45
7
votes
1 answer

call gettid witin glibc

I am working in glibc and I need to get the id of the current thread. For this i use syscall(SYS_gettid); Issue is, i am forced to include bits/syscall.h instead of ideal case i.e sys/syscall.h. sys/syscall.h internally calls bits/syscall.h but…
Kapil
  • 836
  • 2
  • 8
  • 20
7
votes
2 answers

Startup code of a statically-linked executable issues so many system calls?

I am experimenting by statically compiling a minimal program and examining the system calls that are issued: $ cat hello.c #include int main (void) { write(1, "Hello world!", 12); return 0; } $ gcc hello.c -static $ objdump -f…
Blagovest Buyukliev
  • 42,498
  • 14
  • 94
  • 130
7
votes
1 answer

Do any functions in the C standard library implicitly use `stderr`?

The C spec mandates all C programs have 3 streams open and available to them: stdout, stdin, stderr. The users can use these streams as they see fit, e.g.: fprintf(stdout, "lol"); fputs("oops", stderr); fgets(buffer, 20, stdin); Some functions in…
Pod
  • 3,938
  • 2
  • 37
  • 45