libc

Understanding the gcc version and the GLIBC, GLIBCXX versions in more detail

大兔子大兔子 提交于 2021-02-05 05:04:41
问题 Assume I have the following local gcc, g++ version: $ gcc -v $ g++ -v gcc version 6.3.1 I don't understanding the relation and meaning of the following compared to my compiler version: What is this referring to? /usr/lib64/libstdc++.so.6 Trying to run a binary and I get this error, what is GLIBCXX_3.4.20 referring to? why is the number starting with 3? /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found What is all this? $ strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX GLIBCXX_3.4

Are dev_t and ino_t required to be integer types?

老子叫甜甜 提交于 2020-12-08 06:39:50
问题 The documentation for glibc stays they are integer types (no narrower than unsigned int), but I'm not finding a standards reference that says they have to be an integer type (see also time_t). So in the end, the question becomes: Is #include <stdio.h> #include <stdint.h> struct stat st; if (stat("somefile", &st) == 0) { printf("%ju %ju\n", (uintmax_t)st.st_dev, (uintmax_t)st.st_ino); } portable. 回答1: POSIX standard requires dev_t to be an integer type and ino_t to be an unsigned integer. dev

Linking a program using printf with ld?

浪尽此生 提交于 2020-11-29 08:33:15
问题 I'm getting a undefined reference to _printf when building an assembly program that defines its own _start instead of main , using NASM on x86-64 Ubuntu Build commands: nasm -f elf64 hello.asm ld -s -o hello hello.o hello.o: In function `_start': hello.asm:(.text+0x1a): undefined reference to `_printf' MakeFile:4: recipe for target 'compile' failed make: *** [compile] Error 1 nasm source: extern _printf section .text global _start _start: mov rdi, format ; argument #1 mov rsi, message ;

Linking a program using printf with ld?

喜夏-厌秋 提交于 2020-11-29 08:32:05
问题 I'm getting a undefined reference to _printf when building an assembly program that defines its own _start instead of main , using NASM on x86-64 Ubuntu Build commands: nasm -f elf64 hello.asm ld -s -o hello hello.o hello.o: In function `_start': hello.asm:(.text+0x1a): undefined reference to `_printf' MakeFile:4: recipe for target 'compile' failed make: *** [compile] Error 1 nasm source: extern _printf section .text global _start _start: mov rdi, format ; argument #1 mov rsi, message ;

How to check libc version?

最后都变了- 提交于 2020-07-09 05:25:19
问题 This question is related to Why does pclose return prematurely?. I'd like to find out what version of libc is used for a cross-compiled executable. There are limitations, described below, that make the answers at Check glibc version for a particular gcc compiler not apply. One proposed way to check the libc version is to use the gnu_get_libc_version() function declared in gnu/libc-version.h . My cross-toolchain does not include libc-version.h . Another proposed solution is to use the -print

How to check libc version?

独自空忆成欢 提交于 2020-07-09 05:24:39
问题 This question is related to Why does pclose return prematurely?. I'd like to find out what version of libc is used for a cross-compiled executable. There are limitations, described below, that make the answers at Check glibc version for a particular gcc compiler not apply. One proposed way to check the libc version is to use the gnu_get_libc_version() function declared in gnu/libc-version.h . My cross-toolchain does not include libc-version.h . Another proposed solution is to use the -print

Is it possible to check whether a C macro is defined on your system in Rust?

匆匆过客 提交于 2020-05-26 09:15:09
问题 I'm aware that the libc crate in Rust contains much of C's standard macros and functions for use in Rust, but it also states that it is not concerned with portability between systems. I'm porting some code that uses C's preprocessor macros extremely heavily from C to Rust, and only includes some code if a given macro is defined: in this case O_BINARY . Is it possible to check whether the O_BINARY macro is defined on my system in Rust, and if so, what does this look like? I'm looking for a

Is it possible to check whether a C macro is defined on your system in Rust?

天涯浪子 提交于 2020-05-26 09:14:22
问题 I'm aware that the libc crate in Rust contains much of C's standard macros and functions for use in Rust, but it also states that it is not concerned with portability between systems. I'm porting some code that uses C's preprocessor macros extremely heavily from C to Rust, and only includes some code if a given macro is defined: in this case O_BINARY . Is it possible to check whether the O_BINARY macro is defined on my system in Rust, and if so, what does this look like? I'm looking for a

How to override standard libc functions?

混江龙づ霸主 提交于 2020-03-13 06:18:42
问题 For example, if I want to override malloc(), what's the best way to do it? Currently the simplest way I know of is: malloc.h #include <stdlib.h> #define malloc my_malloc void* my_malloc (size_t size); foobar.c #include "malloc.h" void foobar(void) { void* leak = malloc(1024); } The problem with this approach is that we now have to use "malloc.h" and can never use "stdlib.h". Is there a way around this? I'm particularly interested in importing 3rd party libraries without modifying them at all,

How to override standard libc functions?

故事扮演 提交于 2020-03-13 06:18:28
问题 For example, if I want to override malloc(), what's the best way to do it? Currently the simplest way I know of is: malloc.h #include <stdlib.h> #define malloc my_malloc void* my_malloc (size_t size); foobar.c #include "malloc.h" void foobar(void) { void* leak = malloc(1024); } The problem with this approach is that we now have to use "malloc.h" and can never use "stdlib.h". Is there a way around this? I'm particularly interested in importing 3rd party libraries without modifying them at all,