On Tue, Sep 22, 2015 at 06:38:06PM +0300, Max Filippov wrote:
Hello,
I'm trying to build uClibc-based userspace for uclinux. It builds
and works as long as I keep uClibc single-threaded. If I enable
TLS and NPTL support first I face build errors (one caused by
reference to fork from libpthread/nptl/sysdeps/unix/sysv/linux/fork.c,
other outside uClibc, in the elf2flt, which cannot deal with .tbss
section overlapping .data section) and then runtime errors
(an attempt to allocate TLS memory with sbrk which doesn't
work in uclinux and then inability to initialize TLS data, which I
haven't tracked yet). All that makes me think that either I'm doing
something terribly wrong, or TLS + NPTL are not supported by
uClibc for uclinux.
As far as I can tell, the bFLT format and linker scripts used have no
way to represent the location/size of the TLS image, so inability to
initialize TLS makes sense. I think this could be solved by having the
linker script put symbols around the TLS image and referencing the
symbols rather than ELF headers to find it. Of course dropping bFLT
and using FDPIC or regular ELF would be the ideal solution.
I've looked at this all recently; see this and the containing thread:
http://lists.nommu.org/pipermail/nommu/2015-September/000037.html
So my questions are:
- are TLS and NPTL supported by uClibc for uclinux?
- if not, what are the supported threading options?
At this point, I think the answer is no, and it would probably be
considerable work to get it working. Nothing that's prohibitively
difficult for someone familiar with the code and linking/binfmt
topics, but still time-consuming.
The old LinuxThreads may or may not work (for some limited definition
of "work") on some NOMMU targets. It probably varies from one to
another so I don't think there's a single answer to your second
question without knowing which target(s) you care about.
What I would recommend if you need threads/TLS, but I'm naturally
biased: I'm presently working on FDPIC-based NOMMU support in musl
libc with thread and TLS support matching normal targets with MMU.
It's already mostly working and progressing rapidly, but the only
supported target so far is SH. Getting more NOMMU targets added would
be great.
Rich