ldso: move hashcode handling code to a separate header file

Move the hashcode handling code inside the ldso/fdpic/dl-inlines.h
to a header file (include/inline-hashtab.h), without any functional
changes.

This is in preparation for supporting TLS descriptors, which also
uses that code.

Signed-off-by: Chris Zankel <chris@zankel.net>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
ldso: make hashcode handling more generic

The hashcode handling code never accesses the underlying structure
'struct funcdesc_value', but only operates on pointer to pointers,
so we can use void** instead.

Also, pass in the functions to generate and compare a hash entry.
This is a minor functional change to inject function pointers
instead of using it inline functions.

This change is in preparation to support tls descriptors, which
require a different hash and compare function.

Signed-off-by: Chris Zankel <chris@zankel.net>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
ldso: add dynamic TLS descriptors support

This is a port from glibc. It add support to TLS descriptors.
For more information about TLS descriptors, see alexandre Oliva's RFCs:

http://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-x86.txt
http://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-ARM.txt

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
ldso: add a 'try' function for allocating TLS memory

Add _dl_try_allocate_static_tls to return an error value when it cannot
allocate memory for a static TLS relocation.

It is a copy of _dl_allocate_static_tls, which intentionally signals an
error when it fails.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa/nptl: add relocation entries for tls descriptors

Define relocation entries R_XTENSA_TLSDESC_FN, R_XTENSA_TLSDESC_ARG, and
R_XTENSA_TLS_TPOFF

Signed-off-by: Chris Zankel <chris@zankel.net>
ldso/xtensa: add support for tls descriptors for Xtensa

Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa/nptl: add support for TLS in clone, fork, jmpbuf-unwind

Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa/nptl: add support for NPTL for Xtensa

These are the architecture specific files under libpthread/nptl for Xtensa.
Is add support for NPTL for Xtensa based on TLS descriptors.

Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa/nptl: add file names of generated files to .gitignore

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
test: add TLS support for xtensa

Add macros required for TLS tests.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
ldso: xtensa: fix static TLS allocation attempt

CHECK_STATIC_TLS and TRY_STATIC_TLS are mutually exclusive. Use the first only
when shared libraries are not supported.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: fix duplicate fork definition when building with NPTL

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: fix elf_machine_type_class() for TLS

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: fix _dl_tlsdesc_return

The _dl_tlsdesc_return() argument is the thread pointer offset itself, not a
pointer to this offset. Also, we need to add the thread pointer before
returning.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: tlsdesc: fix _dl_tlsdesc_dynamic argument type

_dl_tlsdesc_dynamic() accepts pointer to struct tlsdesc_dynamic_arg. Fix the
code accordingly.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: fix the declaration of TLS relocation handlers

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: fix clone(2) when NPTL is enabled

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: fix vfork(2) with NPTL

Mostly copied from glibc/xtensa with some fixes.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: fix pthread_spin_{try,}lock

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Chris Zankel <chris@zankel.net>