libc

Runtime Library mis-matches and VC++ - Oh, the misery!

It seems that all my adult life I've been tormented by the VC++ linker complaining or balking because various libraries do not agree on which version of the Runtime library to use. I'm never in the mood to master that dismal subject. So I just try to mess with it until it works. The error messages are never useful. Neither is the Mic...

Faster math library than glibc on x86_64/linux?

Is there a drop-in replacement to glibc's libm (and headers?) for x86_64-linux that is faster? ...

On which platforms does libc store stack cookie values somewhere other than __stack_chk_guard?

e.g glibc on Linux/i386 stores the cookie at %gs:0x14. Are there any other platforms on which I need to look somewhere other than at the __stack_chk_guard symbol to find the cookie? (This is where the value that gcc -fstack-protector-generated code stores onto the stack in function prologues and checks before return to defend against st...

Compiling without libc

I want to compile my C-code without the (g)libc. How can I deactivate it and which functions depend on it? I tried -nostdlib but it doesn't help: The code is compilable and runs, but I can still find the name of the libc in the hexdump of my executable. ...

link to a different libc file

I want to supply the shared libs along with my program rather than using the target system's due to version differences: ldd says my program uses these shared libs: linux-gate.so.1 => (0xf7ef0000)(made by kernel) libc.so.6 => /lib32/libc.so.6 (0xf7d88000)(libc-2.7.so) /lib/ld-linux.so.2 (0xf7ef1000)(ld-2.7.so) I have successfully lin...

How can I link to a specific glibc version?

When I compile something on my Ubuntu Lucid 10.04 PC it gets linked against glibc. Lucid uses 2.11 of glibc. When I run this binary on another PC with an older glibc, the command fails saying there's no glibc 2.11... As far as I know glibc uses symbol versioning. Can I force gcc to link against a specific symbol version? In my concret...

Posix equivalent of LocalAlloc(LMEM_ZEROINIT, size)

I have code which works on windows, that calls LocalAlloc as follows: LocalAlloc(LMEM_ZEROINIT, size) I need the equivalent malloc or calloc call to get this to work on Unix systems, through Mono. Simple answer? ...

How does the pstack command work?

Hello, I am curious to find how does the pstack command prints the stack trace of all the threads running under the PID? It has to be someway different than the way gdb does since the process runs inside the gdb environment, but pstack is executed after the execution of the process. ...

Why is fseeko() faster with giant files than small ones?

I'm getting some strange performance results here and I'm hoping someone on stackoverflow.com can shed some light on this! My goal was a program that I could use to test whether large seek's were more expensive than small seek's... First, I created two files by dd'ing /dev/zero to seperate files... One is 1 mb, the other is 9.8gb... Th...

What's the difference between hard and soft floating point numbers?

When I compile C code with my cross toolchain, the linker prints pages of warnings saying that my executable uses hard floats but my libc uses soft floats. What's the difference? ...

Can I add a systemcall from a module?

Can I add a systemcall from a module? ...

Statically linking new libc symbols to use with a lower libc version

I have an app that uses eventfd and timerfd kernel syscalls. For that use you need a modern kernel and a libc that supports them, at least 2.8. My current situation is, I have a system with the proper kernel but a 2.7.11 libc version which obviously does not support the required functions for the new syscalls. But, as those 2 interfaces...

Question about libc_write()

I'm trying to determine what libc_write does exactly. I'm executing a binary on a processor simulator I designed in c++ and the program being run has jumped to the function call libc_write(). Now, there are 2 different types of write functions - write() which writes one large buffer to a stream, possibly comprised of many buffers that ...

Is there really no mremap in Darwin?

I'm trying to find out how to remap memory-mapped files on a Mac (when I want to expand the available space). I see our friends in the Linux world have mremap but I can find no such function in the headers on my Mac. /Developer/SDKs/MacOSX10.6.sdk/usr/include/sys/mman.h has the following: mmap mprotect msync munlock munmap but no mre...

How to reimplement (or wrap) a syscall function in linux ?

Suppose I want to completely take over the open() system call, maybe to wrap the actual syscall and perform some logging. One way to do this is to use LD_PRELOAD to load a (user-made) shared object library that takes over the open() entry point. The user-made open() routine then obtain the pointer to the glibc function open() by dlsym()i...

Do POSIX lfind()/lsearch() perform better than looping manually?

Do lfind/lsearch perform better than a typical looping solution that checks each item until it matches? Is there any special sauce/reason that these functions exist? ...

Determing the number of bytes ready to be recv()'d.

I can use select() to determine if a call to recv() would block, but once I've determined that their are bytes to be read, is their a way to query how many bytes are currently available before I actually call recv()? ...

strsep segmentation faults on different string pointer/array types

Platform: Linux, OSX Compiler: GCC I've got a simple program which is currently confounding me - I know that I'm messing with a couple different kinds of arrays/pointers to produce this problem - its intentional - I'm trying to understand it. The code as listed will compile and run as expected, but changing data4 in the call to strsep(...

Linking against an old version of libc to provide greater application coverage

Linux binaries are usually dynamically linked to the core system library (libc). This keeps the memory footprint of the binary quite small but binaries which are dependent on the latest libraries will not run on older systems. Conversely, binaries linked to older libraries will run happily on the latest systems. Therefore, in order to e...