From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116828 invoked by alias); 1 Mar 2020 21:06:31 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 116820 invoked by uid 89); 1 Mar 2020 21:06:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:tools, GLOBAL, dyn-syms, dynsyms X-HELO: mail-pj1-f45.google.com Received: from mail-pj1-f45.google.com (HELO mail-pj1-f45.google.com) (209.85.216.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Mar 2020 21:06:29 +0000 Received: by mail-pj1-f45.google.com with SMTP id e9so3532164pjr.4 for ; Sun, 01 Mar 2020 13:06:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=eoItlg/5Tqui6s9VFgOSBFVejquGp8pZvkzLi+unaSc=; b=LGNxIPUbczaxmQZzkXWZPxNyaOd3v3imqq7wpfsGFGi8D5vM7RC6l9vTbf9pPqzAKp SFn9uK4EkjiaiiHeuJYVGx/0utc8D0cxy/zLjtKjOfsF0k3WREyGX9016sqa3liRYwox cXI7FLxFJ8dQWM1RAQtGm4YeINkBUR9LRNVyjHB33vaT5WDFOOMre7v9+DAfk7kReXhe 3T0RPVpczzoBsCpAN8ZAhNggyE9Xk2xb/ln6lijpUgObxXncGqExDP6/xg+/RfhU3WMj ugTgAKgrNNXJiNnNnQ2glCjWVvNC4YJ71+LOrVEIjT+u6ECf4UIMMHVAFF2QWxS1rUBh 2b5g== Return-Path: Received: from gnu-cfl-2.localdomain (c-73-93-86-59.hsd1.ca.comcast.net. [73.93.86.59]) by smtp.gmail.com with ESMTPSA id b21sm19084440pfp.0.2020.03.01.13.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 13:06:27 -0800 (PST) Received: from gnu-cfl-2.hsd1.ca.comcast.net (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 1EBE0C0452 for ; Sun, 1 Mar 2020 13:06:23 -0800 (PST) From: "H.J. Lu" To: binutils@sourceware.org Subject: [PATCH] plugin: Copy the no_export field to the IR dummy object Date: Sun, 01 Mar 2020 21:06:00 -0000 Message-Id: <20200301210623.772188-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2020-03/txt/msg00000.txt Copy the no_export field to the IR dummy object when claiming an IR object. PR ld/25618 * plugin.c (plugin_object_p): Copy the no_export field to the IR dummy object. * testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Add PR ld/25618 tests. * testsuite/ld-plugin/pr25618.d: New file. * testsuite/ld-plugin/pr25618a.cc: Likewise. * testsuite/ld-plugin/pr25618a.h: Likewise. * testsuite/ld-plugin/pr25618b.cc: Likewise. * testsuite/ld-plugin/pr25618b.h: Likewise. --- ld/plugin.c | 1 + ld/testsuite/ld-plugin/lto.exp | 10 ++++++++++ ld/testsuite/ld-plugin/pr25618.d | 4 ++++ ld/testsuite/ld-plugin/pr25618a.cc | 3 +++ ld/testsuite/ld-plugin/pr25618a.h | 2 ++ ld/testsuite/ld-plugin/pr25618b.cc | 2 ++ ld/testsuite/ld-plugin/pr25618b.h | 2 ++ 7 files changed, 24 insertions(+) create mode 100644 ld/testsuite/ld-plugin/pr25618.d create mode 100644 ld/testsuite/ld-plugin/pr25618a.cc create mode 100644 ld/testsuite/ld-plugin/pr25618a.h create mode 100644 ld/testsuite/ld-plugin/pr25618b.cc create mode 100644 ld/testsuite/ld-plugin/pr25618b.h diff --git a/ld/plugin.c b/ld/plugin.c index 23a314543b9..af3f9e2ffe8 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -1239,6 +1239,7 @@ plugin_object_p (bfd *ibfd) ibfd->plugin_format = bfd_plugin_yes; ibfd->plugin_dummy_bfd = abfd; bfd_make_readable (abfd); + abfd->no_export = ibfd->no_export; return abfd->xvec; } else diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index 0243f093288..31da465d002 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -368,6 +368,16 @@ set lto_link_elf_tests [list \ "-O2 -flto -Wl,--as-needed tmpdir/pr25593a-2.o tmpdir/pr25593b.o \ tmpdir/pr25593c.so tmpdir/pr25593d.so tmpdir/pr25593e.so" "" \ {dummy.c} {{readelf {-d --wide} pr25593.d}} "pr25593b.exe"] \ + [list "Build pr25618a.o" \ + "$plug_opt" "-O2 -flto -fpic" \ + {pr25618a.cc} {} "" "c++"] \ + [list "Build pr25618.a" \ + "$plug_opt" "-O2 -flto -fpic" \ + {pr25618b.cc} {} "pr25618.a" "c++"] \ + [list "Build pr25618.so" \ + "-shared -Wl,--exclude-libs,ALL tmpdir/pr25618a.o tmpdir/pr25618.a" \ + "-fpic" \ + {dummy.c} {{readelf {--dyn-syms --wide} pr25618.d}} "pr25618.so" "c++"] \ ] # PR 14918 checks that libgcc is not spuriously included in a shared link of diff --git a/ld/testsuite/ld-plugin/pr25618.d b/ld/testsuite/ld-plugin/pr25618.d new file mode 100644 index 00000000000..2815d928b76 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr25618.d @@ -0,0 +1,4 @@ +#failif +#... + +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +_?_Z3foov +#... diff --git a/ld/testsuite/ld-plugin/pr25618a.cc b/ld/testsuite/ld-plugin/pr25618a.cc new file mode 100644 index 00000000000..6d35b3c74a1 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr25618a.cc @@ -0,0 +1,3 @@ +#include "pr25618a.h" +#include "pr25618b.h" +int bar() { return foo(); } diff --git a/ld/testsuite/ld-plugin/pr25618a.h b/ld/testsuite/ld-plugin/pr25618a.h new file mode 100644 index 00000000000..9bf857ce650 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr25618a.h @@ -0,0 +1,2 @@ +#pragma once +__attribute__((visibility("default"))) int bar(); diff --git a/ld/testsuite/ld-plugin/pr25618b.cc b/ld/testsuite/ld-plugin/pr25618b.cc new file mode 100644 index 00000000000..1d3dff3702d --- /dev/null +++ b/ld/testsuite/ld-plugin/pr25618b.cc @@ -0,0 +1,2 @@ +#include "pr25618b.h" +int foo() { return 100; } diff --git a/ld/testsuite/ld-plugin/pr25618b.h b/ld/testsuite/ld-plugin/pr25618b.h new file mode 100644 index 00000000000..cd80074f47c --- /dev/null +++ b/ld/testsuite/ld-plugin/pr25618b.h @@ -0,0 +1,2 @@ +#pragma once +__attribute__((visibility("default"))) int foo(); -- 2.24.1