From patchwork Tue Nov 22 22:02:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 24600 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2459191wrr; Tue, 22 Nov 2022 14:02:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kQisb2b+JeesxFi0ZBH4yVcFeC3A6zlpHpDXw+Rf7MoKxEZifpZpIDxmVLbdQR7aDCE14 X-Received: by 2002:a17:906:1484:b0:7ae:6746:f270 with SMTP id x4-20020a170906148400b007ae6746f270mr8018694ejc.728.1669154569726; Tue, 22 Nov 2022 14:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669154569; cv=none; d=google.com; s=arc-20160816; b=Gk7gcyKDesMlpKZS62zE592mlnYrcRqWg/KY8HRvvhYjU3NnAIfO8fx7gXKp74HOlT p1D5IFbQC6pmReZDS+OIvsiLRtbN2NA2PkZMjqkKsa1PeCwE4QP65og+rHqW4pkYe3N8 ZB8bVEedCJIYo10UeYBmNKcOMSh7GbR5u8XEVfThNhNlZucLPGHtQTe6Rhw6ZmmaxOH/ wMiRKwAsqMojla/BUQdp8NtvXA7R6ZS1+tKcKnHoyUi6ODbiqdNMzjlJTaI17QAw3j9W VDseS0O6nEbSfHGHLZbiUlWlxtOuWXmc7YTgtgOwKON/+gRprId4JTCjz7DS20fJ8OAq D90w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=gkjtESmzJpzXGLj1g149Z+DtduhgcIW6qtuUin55//4=; b=r3QpKXFlfyjuj7HmWg0MUMWXdiwXB4kixsH2AVamKoEj1sWH5YZClamSqLaS42nSd6 +10Uh+9CN4cEtQLYfm5yEmbJA2xWPqwbLq2LgUqsu7+49m1UaBYMr+tTiriuUZpzQkJD 7oH/U+u+1ORNOPz1o8asjqCyGMHS/pvlfhRynj7GDHAOjDb39yKQknbhB6ePp3z9u9xR 3y5SQHTyjcR6y9e+ZczF/f1eQn6dvEwVcmzDT2g3MybC+Nc0HgNx1pdjphSv1YF/Li+C jiWWNrj3xpAVkn6K/tVLeQlVrRRuCOzf651K9mZ3U2il77im1nC+31DqQCY5wvuxzAKJ ob/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ZwIUtN2Y; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id xb1-20020a170907070100b0078d8cc2006csi14718547ejb.697.2022.11.22.14.02.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 14:02:49 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ZwIUtN2Y; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8879C3858422 for ; Tue, 22 Nov 2022 22:02:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8879C3858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669154568; bh=gkjtESmzJpzXGLj1g149Z+DtduhgcIW6qtuUin55//4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZwIUtN2YblgAF2pVbYiJ8lvoY804k39DMxAq6LcTwk8GaDNXV18tuIlmcDRdOWGJZ e2gJPEKW9LchJnQjyAS3VnnC3YcpcwlLRzhAKMYMdl9fkq9E08rxSvCtyoklnP8DMO aXBKGFS1mpGPTNeS83bhzHdfc0rr3Z8yTNhrshFE= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id C8AFE3858D35 for ; Tue, 22 Nov 2022 22:02:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C8AFE3858D35 Received: by mail-pg1-x532.google.com with SMTP id f9so10989851pgf.7 for ; Tue, 22 Nov 2022 14:02:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gkjtESmzJpzXGLj1g149Z+DtduhgcIW6qtuUin55//4=; b=tu7E+aGHFB3mAMR+oN4u1LihYvQENd2o15QIhVhrBWI7pHdiG0VYaczO5wCGUsw9Z+ sM/HwziZCJSIx6qCWybKzb3ALKXNVu550QKdaOfrNUyBXsOIpj1rBL5WoUvpd4w2I1my NfEnaEsWXlfYbvyTuaUpKma6oJj4EohBC9enkhPvPBaQRdbneRr3FV554WZ1UHjM1NLY uwXpa+C5k3xZHGWZYhCZc6EHscnK/5TDGMGaLCP1gbvWb2PUOgzuuATMqcrH4I9e6X00 7seq8DFIoK/CTgIs2jcBeMaKR/LP64M9Hs67vzRiMTfacrefeez4mLcVHR9sjENcCO3P ZwZg== X-Gm-Message-State: ANoB5pmLfBTGV7FhEpmD4SniF7Qhp6VDxJi5zXtgD7kuwKUqciDfN2s5 AtdrgXYek93PnGXYQ+BeHxzQaMUnT0c= X-Received: by 2002:a63:4701:0:b0:476:d784:1c44 with SMTP id u1-20020a634701000000b00476d7841c44mr6782431pga.431.1669154558241; Tue, 22 Nov 2022 14:02:38 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.56.31.158]) by smtp.gmail.com with ESMTPSA id p22-20020a170902a41600b001869079d083sm7560840plq.90.2022.11.22.14.02.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 14:02:37 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 43938C0202 for ; Tue, 22 Nov 2022 14:02:36 -0800 (PST) To: binutils@sourceware.org Subject: [PATCH] x86: Don't define _TLS_MODULE_BASE_ for ld -r Date: Tue, 22 Nov 2022 14:02:36 -0800 Message-Id: <20221122220236.429230-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3026.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Binutils" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750235422012712346?= X-GMAIL-MSGID: =?utf-8?q?1750235422012712346?= bfd/ PR ld/29820 * elfxx-x86.c (_bfd_x86_elf_always_size_sections): Don't define _TLS_MODULE_BASE_ for ld -r. ld/ PR ld/29820 * testsuite/ld-x86-64/pr29820.d: New file. * testsuite/ld-x86-64/pr29820.s: Likewise. * testsuite/ld-x86-64/x86-64.ex: Run pr29820. --- bfd/elfxx-x86.c | 2 +- ld/testsuite/ld-x86-64/pr29820.d | 6 ++++++ ld/testsuite/ld-x86-64/pr29820.s | 12 ++++++++++++ ld/testsuite/ld-x86-64/x86-64.exp | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-x86-64/pr29820.d create mode 100644 ld/testsuite/ld-x86-64/pr29820.s diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index c48d0385485..bbf868826e5 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -2932,7 +2932,7 @@ _bfd_x86_elf_always_size_sections (bfd *output_bfd, { asection *tls_sec = elf_hash_table (info)->tls_sec; - if (tls_sec) + if (tls_sec && !bfd_link_relocatable (info)) { struct elf_link_hash_entry *tlsbase; diff --git a/ld/testsuite/ld-x86-64/pr29820.d b/ld/testsuite/ld-x86-64/pr29820.d new file mode 100644 index 00000000000..8dc5d6151c3 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr29820.d @@ -0,0 +1,6 @@ +#ld: -r +#readelf: -s -W + +#... + +[0-9]+: +0+ +0 +TLS +GLOBAL +DEFAULT +UND +_TLS_MODULE_BASE_ +#pass diff --git a/ld/testsuite/ld-x86-64/pr29820.s b/ld/testsuite/ld-x86-64/pr29820.s new file mode 100644 index 00000000000..7a4815ff7c5 --- /dev/null +++ b/ld/testsuite/ld-x86-64/pr29820.s @@ -0,0 +1,12 @@ + .text + leaq _TLS_MODULE_BASE_@tlsdesc(%rip), %rax + call *_TLS_MODULE_BASE_@tlscall(%rax) + movl %fs:a@dtpoff(%rax), %edx + addl %fs:b@dtpoff(%rax), %edx + + .section .tbss + .zero 8 +a: + .zero 4 +b: + .zero 4 diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 1782e8e5def..136371bd5a2 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -728,6 +728,7 @@ run_dump_test "pr27016a" run_dump_test "pr27016b" run_dump_test "report-reloc-1" run_dump_test "report-reloc-1-x32" +run_dump_test "pr29820" proc undefined_weak {cflags ldflags} { set testname "Undefined weak symbol"