[all-commits] [llvm/llvm-project] e39c13: [ELF] Implement TLSDESC for x86-32
Fangrui Song via All-commits
all-commits at lists.llvm.org
Thu Oct 28 17:52:15 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e39c138f4522baef5cd060fd8b5e715d72e77a6a
https://github.com/llvm/llvm-project/commit/e39c138f4522baef5cd060fd8b5e715d72e77a6a
Author: Fangrui Song <i at maskray.me>
Date: 2021-10-28 (Thu, 28 Oct 2021)
Changed paths:
M lld/ELF/Arch/X86.cpp
M lld/ELF/InputSection.cpp
M lld/ELF/Relocations.cpp
M lld/ELF/Relocations.h
M lld/ELF/Writer.cpp
M lld/docs/ReleaseNotes.rst
A lld/test/ELF/i386-tlsdesc-gd.s
A lld/test/ELF/i386-tlsdesc-ld.s
A lld/test/ELF/invalid/i386-tlsdesc-gd.s
Log Message:
-----------
[ELF] Implement TLSDESC for x86-32
`-z rela` is also supported.
Tested with:
```
cat > ./a.c <<eof
#include <assert.h>
int foo();
int bar();
int main() {
assert(foo() == 2);
assert(foo() == 4);
assert(bar() == 2);
assert(bar() == 4);
}
eof
cat > ./b.c <<eof
#include <stdio.h>
__thread int tls0;
extern __thread int tls1;
int foo() { return ++tls0 + ++tls1; }
static __thread int tls2, tls3;
int bar() { return ++tls2 + ++tls3; }
eof
echo '__thread int tls1;' > ./c.c
sed 's/ /\t/' > ./Makefile <<'eof'
.MAKE.MODE = meta curDirOk=true
CC := gcc -m32 -g -fpic -mtls-dialect=gnu2
LDFLAGS := -m32 -Wl,-rpath=.
all: a0 a1 a2
run: all
./a0 && ./a1 && ./a2
c.so: c.o; ${LINK.c} -shared $> -o $@
bc.so: b.o c.o; ${LINK.c} -shared $> -o $@
b.so: b.o c.so; ${LINK.c} -shared $> -o $@
a0: a.o b.o c.o; ${LINK.c} $> -o $@
a1: a.o b.so; ${LINK.c} $> -o $@
a2: a.o bc.so; ${LINK.c} $> -o $@
eof
```
and glibc `elf/tst-gnu2-tls1`.
`/usr/local/bin/ld` points to the freshly built `lld`.
`bmake run && bmake CFLAGS=-O1 run` => ok.
Differential Revision: https://reviews.llvm.org/D112582
More information about the All-commits
mailing list