glibc

call gettid witin glibc

。_饼干妹妹 提交于 2019-12-05 08:21:54
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 that is wrapped with #ifndef _LIBC macro. i.e #ifndef _LIBC /* The Linux kernel header file defines macros `__NR_<name>', but some programs expect the traditional form `SYS_<name>'. So in building libc we scan the kernel's list and produce <bits/syscall.h> with macros for all the `SYS_' names. */ # include <bits/syscall.h> #endif also bits/syscall.h

The program cannot find correct version of glibc/libstdc++, although it was statically linked

不羁的心 提交于 2019-12-05 07:50:48
I am trying to link my program statically with glibc, because version of the glibc on the target machine is pretty much unpredictable. I used linker flags -static-libgcc and -static-libstdc++ and it worked fine. The executable is big, but I can live with it. Unfortunately, when I run my executable on the target machine (it is named 'mytest' in the example below) I get the following error: ./mytest: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by libboost_log.so.1.53.0) ./mytest: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by libboost_log

Is `asprintf` thread-safe?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 07:47:15
Is the GNU function asprintf (print to allocated string) thread-safe? (IIC, basically, this boils down to the question whether malloc is thread-safe.) Consider the example code: #define _GNU_SOURCE #include <stdio.h> #include "getValue.h" char * getValue(int key) { char * value; asprintf(&value, "%d", key); // TODO: No error handling! // If memory allocation wasn't possible, or some other error occurs, these functions will // return -1, and the contents of strp is undefined. return value; } Here, I do not touch any global variables. What if my getValue gets called in concurrent threads? No bad

What corner cases must we consider when parsing $PATH on Linux?

安稳与你 提交于 2019-12-05 04:52:06
I'm working on a C application that has to walk $PATH to find full pathnames for binaries, and the only allowed dependency is glibc (i.e. no calling external programs like which). In the normal case, this just entails splitting getenv("PATH") by colons and checking each directory one by one, but I want to be sure I cover all of the possible corner cases. What gotchas should I look out for? In particular, are relative paths, paths starting with ~ meant to be expanded to $HOME, or paths containing the : char allowed? One thing that once surprised me is that the empty string in PATH means the

Is there a libc in kernel space?

落爺英雄遲暮 提交于 2019-12-05 03:45:06
问题 Is there a libc in kernel space? I mean you have to build kernel against some libc right? So Is there a libc (probably statically-linked) sitting within kernel space? If yes, how is this related to userland glibc? Must they be the same version? 回答1: There is actually no libc in kernel space. Libc is user-space library, and you can't use it from kernel-space. But almost all functions from libc that make sense in kernel space are ported. You can find headers in include/linux/ usually. As far as

Library path order for alternate glibc dynamic linker (ld.so)

我与影子孤独终老i 提交于 2019-12-05 01:46:27
I need to use an alternate glibc version, newer than the one installed on my system ( 2.18 vs 2.15 ). Several related issues are covered here and here . The specific question I'm asking here is the following: I set up the library path of the new dynamic linker ( ld-2.18.so ) so that the new libc ( libc-2.18.so ) is found ahead of the old libc ( libc-2.15.so ). However, when I try to run a program with the new ld , the old version of libc is picked up, generating a SEGV . Why is that happening? Note: I know this can be fixed by using --rpath at compile time or LD_LIBRARY_PATH at run time.

移植linux4.14内核到4412开发板

回眸只為那壹抹淺笑 提交于 2019-12-04 23:59:46
最近法师收到了很多留言,其中有一部分问法师什么时候更新,还有一大部分问法师我是买 迅为的IMX6UL精英版好呢还是买4412精英版好呢 ,因为我们这俩个都不贵。法师的建议的是入手4412!为什么呢? 第一,4412是三星第一款经典处理器,为三星创造了辉煌,是当年在国内红得发紫的GalaxyS3手机的主控,他的出现,开启了手机和平板的四核时代,让手机和平板变得流畅,可以说,到目前为止,4412上用到的技术,仍是当前的主流技术,其他的处理器并没有质的飞跃,同样,经过7年以上各行各业的考验,已经非常的稳定。而且四核处理器系统可以实现动态调频调压,所以,我们一个板子不仅可以学习uboot,linux,裸机,还可学习安卓,一个板子就足够了。 第二,经过多年的累积,4412已经积累了海量的开发资料。 第三,也是最重要的一点!!! 2017 年 6 月份左右,迅为电子 iTOP 系列开发平台 iTOP-4412 的 SCP 核心板,得到世界最大开源软件 Linux 的官方支持,这意味着从linux官方www.kernel.orrg下载的最新内核稍加修改就可以直接在ITOP4412上运行,极大方便用户产品的技术升级。 所以,一个既能运行安卓,ubuntu,QT系统,还被linux官方支持的开发板四五百元就可以入手,他不香嘛~~ 另外如果是迅为的老用户,再次在官方店购买我的产品

十问 Linux 虚拟内存管理 (glibc) (二)

僤鯓⒐⒋嵵緔 提交于 2019-12-04 23:41:07
版权声明:本文由陈福荣原创文章,转载请注明出处: 文章原文链接: https://www.qcloud.com/community/article/184 来源:腾云阁 https://www.qcloud.com/community 接上篇: 十问 Linux 虚拟内存管理 (glibc) (一) 五.free 的内存真的释放了吗(还给 OS ) ? 前面所有例子都有一个很严重的问题,就是分配的内存都没有释放,即导致内存泄露。原则上所有 malloc/new 分配的内存,都需 free/delete 来释放。但是, free 了的内存真的释放了吗? 要说清楚这个问题,可通过下面例子来说明。 初始状态:如图 (1) 所示,系统已分配 ABCD 四块内存,其中 ABD 在堆内分配, C 使用 mmap 分配。为简单起见,图中忽略了如共享库等文件映射区域的地址空间。 E=malloc(100k) :分配 100k 内存,小于 128k ,从堆内分配,堆内剩余空间不足,扩展堆顶 (brk) 指针。 free(A) :释放 A 的内存,在 glibc 中,仅仅是标记为可用,形成一个内存空洞 ( 碎片 ) ,并没有真正释放。如果此时需要分配 40k 以内的空间,可重用此空间,剩余空间形成新的小碎片。 free(C) : C 空间大于 128K ,使用 mmap 分配,如果释放 C ,会调用

解决strings: '/lib/libc.so.6': No such file

余生长醉 提交于 2019-12-04 21:12:09
[root@uranuspreapp30 opt]# strings /lib64/libc.so.6 | grep GLIBC |tail -n 8 strings: '/lib64/libc.so.6': No such file [root@uranuspreapp30 opt]# 首先想到的是不是系统安装的时候没有装libc,于是执行 [root@localhost ~]# rpm -qa | grep libc 执行结果: libcurl-7.19.7-26.el6_2.4.x86_64 libcap-2.16-5.5.el6.x86_64 libcgroup-0.37-4.el6.x86_64 glibc-2.12-1.166.el6_7.7.i686 libcom_err-devel-1.41.12-12.el6.x86_64 libcroco-0.6.2-5.el6.x86_64 libcap-ng-0.6.4-3.el6_0.1.x86_64 libcanberra-0.22-1.el6.x86_64 glibc-common-2.12-1.166.el6_7.7.x86_64 glibc-devel-2.12-1.166.el6_7.7.x86_64 libcurl-devel-7.19.7-26.el6_2.4.x86_64 libcom_err-1.41

工作日常之安装MySQL5.6.16

三世轮回 提交于 2019-12-04 20:00:24
前言 需要安装MySQL5.6.16,的确没有安装过,找安装包都找了很久。还是安装成功了。记录下,方便以后再次安装有文档。 如果已经安装了MySQL,请把所有库导出来,并把一些不兼容的地方去掉 通过MySQL用户删除/var/lib/mysql/目录下所有文件 su mysql rm -fr /var/lib/mysql/* exit 安装MySQL yum install -y wget wget https://cdn.mysql.com/archives/mysql-5.6/MySQL-5.6.16-1.linux_glibc2.5.x86_64.rpm-bundle.tar yum remove mariadb-libs-1:5.5.60-1.el7_5.x86_64 yum install -y perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker tar -xvf MySQL-5.6.16-1.linux_glibc2.5.x86_64.rpm-bundle.tar rpm -ivh MySQL-server-5.6.16-1.linux_glibc2.5.x86_64.rpm rpm -ivh MySQL-client-5.6.16-1.linux_glibc2.5.x86_64.rpm rpm -ivh MySQL-devel