mismatches non-TLS reference

问题

/home/ffv/Downloads/tools/arm-2009q3/arm-none-linux-gnueabi/bin/../arm-none-linux-gnueabi/libc/lib/libc.so.6 section .tbss mismatches non-TLS reference in libz.a(gzio.o)

/home/ffv/Downloads/tools/arm-2009q3/arm-none-linux-gnueabi/bin/../arm-none-linux-gnueabi/libc/lib/libc.so.6: could not read symbols: Bad value

 

Thread-local storage (TLS)

TLS is a computer programming method that uses static or global memory local to a thread.

This is sometimes needed because normally all threads in a process share the same address space, which is sometimes undesirable. In other words, data in a static or global variable is normally always located at the same memory location, when referred to by threads from the same process. Variables on the call stack however are local to threads, because each thread has its own stack, residing in a different memory location.

Sometimes it is desirable that two threads referring to the same static or global variable are actually referring to different memory locations, thereby making the variable thread-local, a canonical example being the C error code variable errno.

If it is possible to make at least a memory address sized variable thread-local, it is in principle possible to make arbitrarily sized memory blocks thread-local, by allocating such a memory block and storing the memory address of that block in a thread-local variable.

 

解决方案

本项目中,部分变量errno(注意是errno, 不是error)这样声明:

extern int errno

但是多线程环境中errno并不一定都是int,改用:

#include <errno.h>

 

转载于:https://www.cnblogs.com/turtle-fly/archive/2013/03/13/2957809.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值