Bug 28152 - elf: clang integrated assembler and ld.lld do not support .tls_common
Summary: elf: clang integrated assembler and ld.lld do not support .tls_common
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2021-07-28 21:00 UTC by Fangrui Song
Modified: 2021-08-16 17:08 UTC (History)
0 users

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-07-28 21:00:44 UTC
The integrated assembler does not support the obsoleted .tls_common directive

% clang -c -x assembler =(printf '.tls_common x,4,4\n')
/tmp/zsh5QvAWt:1:1: error: unknown directive
.tls_common x,4,4

ld.lld doesn't support it (there is no point supporting the obsoleted feature)

% clang -c -x assembler -fno-integrated-as =(printf '.tls_common x,4,4\n') -o a.o && ld.lld a.o
ld.lld: warning: cannot find entry symbol _start; defaulting to 0x201158
ld.lld: error: a.o has an STT_TLS symbol but doesn't have an SHF_TLS section

elf/tls-macros.h COMMON_INT_DEF uses .tls_common and therefore some tests can be built/linked with clang or ld.lld

Testing assembling and linking of .tls_common is binutils gas/ld's responsibility, not glibc's.

https://sourceware.org/pipermail/libc-alpha/2021-July/129451.html (elf: Replace .tls_common with .tbss definition) can make the tests buildable with clang and ld.lld

(There is a long way for clang to build glibc itself. https://sourceware.org/bugzilla/show_bug.cgi?id=27220 (nested functions in elf/) is the main one.)
Comment 1 Fangrui Song 2021-07-28 21:02:29 UTC
> can be built/linked with clang or ld.lld

can => cannot

.tls_common and .tbss definition are almost identical after linking. So glibc tests can just use .tbss
Comment 2 Fangrui Song 2021-08-16 17:08:09 UTC
(elf: Drop elf/tls-macros.h in favor of __thread and tls_model attributes [BZ #28152] [BZ #28205])

Fixed for 2.35.