mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH libc-test] tls_local_exec.c: add a dynamic relocation test case
@ 2019-08-14  3:20 Fangrui Song
  2019-08-22 19:36 ` Szabolcs Nagy
  0 siblings, 1 reply; 2+ messages in thread
From: Fangrui Song @ 2019-08-14  3:20 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

commit 9d35fec9e1f391d56faee20b868ef4114bcc4d8a fixed a TLS bug introduced
in commit ffab43602b5900c86b7040abdda8ccf6cdec95f5.

% make B=/tmp/libc-test-x86_64 /tmp/libc-test-x86_64/functional/tls_local_exec.err
...
% cat /tmp/libc-test-x86_64/functional/tls_local_exec.err
FAIL /tmp/libc-test-x86_64/functional/tls_local_exec.exe [signal Segmentation fault]

static __thread const char *s1 = "s1";

produces a dynamic relocation against .tdata in a -pie build, which can
have caught the regression.

[-- Attachment #2: libc-test-tls_local_exec.patch --]
[-- Type: text/x-diff, Size: 1287 bytes --]

From 010b8ab803157adcbe5f9fa9a0df5d4017281b9e Mon Sep 17 00:00:00 2001
From: Fangrui Song <i@maskray.me>
Date: Wed, 14 Aug 2019 03:12:00 +0000
Subject: [PATCH] tls_local_exec.c: add a dynamic relocation test case

This can catch the bug fixed by musl commit
9d35fec9e1f391d56faee20b868ef4114bcc4d8a in a -fpie -pie build.
---
 src/functional/tls_local_exec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/functional/tls_local_exec.c b/src/functional/tls_local_exec.c
index c6ec558..af54c52 100644
--- a/src/functional/tls_local_exec.c
+++ b/src/functional/tls_local_exec.c
@@ -1,4 +1,5 @@
 #include <stdint.h>
+#include <string.h>
 #include <pthread.h>
 #include "test.h"
 
@@ -8,6 +9,7 @@ static __thread char d4096 __attribute__ ((aligned(4096))) = 33;
 static __thread char z1 = 0;
 static __thread char z64 __attribute__ ((aligned(64))) = 0;
 static __thread char z4096 __attribute__ ((aligned(4096))) = 0;
+static __thread const char *s1 = "s1";
 
 static int tnum;
 
@@ -39,6 +41,8 @@ static void *check(void *arg)
 
 	CHECK(ptrmod(&z64, 64) == 0, " address is %p, want 64 byte alignment", &z64);
 	CHECK(ptrmod(&z4096, 4096) == 0, " address is %p, want 4096 byte alignment", &z4096);
+
+	CHECK(!strcmp(s1, "s1"), " want s1 got %s", s1);
 	return 0;
 }
 
-- 
2.22.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH libc-test] tls_local_exec.c: add a dynamic relocation test case
  2019-08-14  3:20 [PATCH libc-test] tls_local_exec.c: add a dynamic relocation test case Fangrui Song
@ 2019-08-22 19:36 ` Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2019-08-22 19:36 UTC (permalink / raw)
  To: musl

* Fangrui Song <i@maskray.me> [2019-08-14 03:20:04 +0000]:
> commit 9d35fec9e1f391d56faee20b868ef4114bcc4d8a fixed a TLS bug introduced
> in commit ffab43602b5900c86b7040abdda8ccf6cdec95f5.
> 
> % make B=/tmp/libc-test-x86_64 /tmp/libc-test-x86_64/functional/tls_local_exec.err
> ...
> % cat /tmp/libc-test-x86_64/functional/tls_local_exec.err
> FAIL /tmp/libc-test-x86_64/functional/tls_local_exec.exe [signal Segmentation fault]
> 
> static __thread const char *s1 = "s1";
> 
> produces a dynamic relocation against .tdata in a -pie build, which can
> have caught the regression.

thanks committed


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-22 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14  3:20 [PATCH libc-test] tls_local_exec.c: add a dynamic relocation test case Fangrui Song
2019-08-22 19:36 ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).