-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[x86-64] Implement TLSGD to TLSIE relaxation
If we know that the .so file we are creating will not be dlopen'ed, we can relax __tls_get_addr function calls to GOT loads.
- Loading branch information
Showing
7 changed files
with
90 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
. $(dirname $0)/common.inc | ||
|
||
cat <<EOF | $GCC -fPIC -c -o $t/a.o -xc - -mcmodel=large | ||
#include <stdio.h> | ||
__attribute__((tls_model("global-dynamic"))) static _Thread_local int x1 = 1; | ||
__attribute__((tls_model("global-dynamic"))) _Thread_local int x2 = 2; | ||
__attribute__((tls_model("global-dynamic"))) _Thread_local int x3; | ||
int foo() { | ||
x3 = 3; | ||
printf("%d %d %d\n", x1, x2, x3); | ||
return 0; | ||
} | ||
EOF | ||
|
||
cat <<EOF | $CC -fPIC -c -o $t/b.o -xc - | ||
int foo(); | ||
int main() { foo(); } | ||
EOF | ||
|
||
$CC -B. -shared -o $t/c.so $t/a.o | ||
$CC -B. -o $t/exe1 $t/b.o $t/c.so | ||
$QEMU $t/exe1 | grep -q '1 2 3' | ||
|
||
$CC -B. -shared -o $t/d.so $t/a.o -Wl,-no-relax | ||
$CC -B. -o $t/exe2 $t/b.o $t/d.so | ||
$QEMU $t/exe2 | grep -q '1 2 3' | ||
|
||
$CC -B. -shared -o $t/e.so $t/a.o -Wl,-z,nodlopen | ||
$CC -B. -o $t/exe3 $t/b.o $t/e.so | ||
$QEMU $t/exe3 | grep -q '1 2 3' | ||
|
||
$CC -B. -shared -o $t/f.so $t/a.o -Wl,-z,nodlopen -Wl,-no-relax | ||
$CC -B. -o $t/exe4 $t/b.o $t/f.so | ||
$QEMU $t/exe4 | grep -q '1 2 3' |