From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14575 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Fangrui Song Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH libc-test] tls_local_exec.c: add a dynamic relocation test case Date: Wed, 14 Aug 2019 03:20:04 +0000 Message-ID: <20190814032004.y7tdnx5pwftuzsos@gmail.com> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="smcxll5qspen4aua" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="30292"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: NeoMutt/20180223-112-0c5bf3 To: musl@lists.openwall.com Original-X-From: musl-return-14591-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 14 05:20:29 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hxjps-0007hp-3g for gllmg-musl@m.gmane.org; Wed, 14 Aug 2019 05:20:28 +0200 Original-Received: (qmail 30443 invoked by uid 550); 14 Aug 2019 03:20:20 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30411 invoked from network); 14 Aug 2019 03:20:19 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=z8JkZxh2johE+KpibnZTcjzPdV5FvEQepVsuNbBSi8Q=; b=uQgfiFAYtP7bk4qjnQ+CdWO0OC+8koIEKf0py3LWUdQ5dI4n5+NXfRS35Es5666fTW 00G7oXFgR4zCXC9PMNSsn+Sg57RRWkl1xhcDx20Y9d+8oq/hQekxZNoTW+zHasgtBwYV sJvcYlSmAOYV22JRUzD/L11aH8bnm2SSzLzuCUHqLrAw0ilzxFEz5N6JlVDHWlzhaOEx QntNt+sKHfpr5pt44a2FmCopYeOznVYsvLEVk2fDYFDoYbH+bWHhPEGG/29AEXicPffw u4tI867QTFhGqOuHf+n6CQkr8eHUdux+HmmVe/u4kD1bQIske6X3gUjGmLvzDqsS0ezu Pa+g== X-Gm-Message-State: APjAAAX2ymED1gDTbxPFR6iodafw9l7dDpQzjaFvUt8OAj3N76ARD4+I 4a07LtTvz93g1iMI8UDBejDIkhtHTxU= X-Google-Smtp-Source: APXvYqwfiSgFZpInje1ZpwdoMdFHhZsi+aIVvY5HBCZSg8L/Sfc4uxy34rXf2obWKHFp2g05AKXpKQ== X-Received: by 2002:a17:902:760e:: with SMTP id k14mr21512282pll.161.1565752807781; Tue, 13 Aug 2019 20:20:07 -0700 (PDT) Content-Disposition: inline Xref: news.gmane.org gmane.linux.lib.musl.general:14575 Archived-At: --smcxll5qspen4aua Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline 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. --smcxll5qspen4aua Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="libc-test-tls_local_exec.patch" >From 010b8ab803157adcbe5f9fa9a0df5d4017281b9e Mon Sep 17 00:00:00 2001 From: Fangrui Song 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 +#include #include #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 --smcxll5qspen4aua--