From patchwork Tue Feb 13 21:15:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 873179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-473209-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uXEgWlyK"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zgwLr34cNz9t34 for ; Wed, 14 Feb 2018 08:16:04 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=UsOpMBdC9FPenD8HDHsBGElBsUuoAITeKjUuqHILxQZsZ/ 3n6nSLxVSmy4w8taLbHtog82p7b3iIpzK43mybyCWJJ65Dj8f4/LpXlljFwzj8o6 eGbLEIMLvA6eL7ByQooZapNCABqJYfSeUOaq4I96ImPJ6Hg3rjbFlF/cJI48M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=WFru9Wv0qyMtlZDQHGkxr79i7Ls=; b=uXEgWlyKtpDmmvyr9H/f otwwiMHy/zKPONZ2cJsloqlueF56p3c6TiLE/HPpjvWjJ79shmNZceHBdSOWLpDp 0+jQ019/15jMgnsMSsA/+mEGDWOzgT0tQxruHTs/zYqsWKJ5Vn6u60CuZAeTBg5p 93TGTShN2N2HYNLCNgM6Jgk= Received: (qmail 16829 invoked by alias); 13 Feb 2018 21:15:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12393 invoked by uid 89); 13 Feb 2018 21:15:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Feb 2018 21:15:48 +0000 Received: by mail-wm0-f48.google.com with SMTP id r71so18640331wmd.1 for ; Tue, 13 Feb 2018 13:15:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=0S/D2dxJk183Vhbida6bexNH3pNNu4vMeCK7JFAXfnQ=; b=JK3Bm9EfV0S1RwNITw0oLmFmUVgMlk1Bc/yoZX6EUJ9uYTZctIkU7Kzubu/dNENsP0 wIhWxQwZ4+VmabpAhKoaE76sBvjqJY3OUYtlgV8s6Ls1iiZBwztCUX5j+6TMFZVj+pkF yW5BjA1AU91HXBUWAMTZzrfRwbv6UWb9+Q+lFKddHqVabuvzPvcuapT2NaQHE9H0Ve4W Sp97u9xTg+3EbIFs+jHXRgKkMwbljAR+z8jh2ZzNcbUdvy/PiKB/oFTtDFGYed8cnszA vXIZtzUwEePt/p1svYw8rFrX+6wGr+DFkRpf4ipnQSVRqgmC2pFK08wmjP/xpPHhNJRQ 05RA== X-Gm-Message-State: APf1xPDxLwyWss81s/NF63d73pp8g1waayfYsJ8csohvy15fHfTLnlNO tfATBNbjd5hUiT1UX0jZz6gCJ6wH8BwPYPvAGylbdzS7 X-Google-Smtp-Source: AH8x224ULhcnc4/6AEptRL9swexMoTWNO8tLqpwLYHUuA9bVrIjIhbAUbI7oRzRjNJQVld+FgiG4qtTkFqSxl0d9o4U= X-Received: by 10.80.181.93 with SMTP id z29mr3833826edd.223.1518556545628; Tue, 13 Feb 2018 13:15:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.148.168 with HTTP; Tue, 13 Feb 2018 13:15:44 -0800 (PST) From: Ian Lance Taylor Date: Tue, 13 Feb 2018 13:15:44 -0800 Message-ID: Subject: Go patch committed: Don't export function descriptors for unexported names To: gcc-patches , gofrontend-dev@googlegroups.com The patch changes the Go frontend to not export function descriptors for unexported names. They aren't needed, and could potentially cause unlikely symbol name collisions. Also, the runtime package's reference to main could cause the runtime package to define main.main..f, which could also be defined in the main package if it does something like fmt.Print(main). That will normally work but will fail with a multiple symbol definition error when using -static-libgo. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 257600) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -7998e29eec43ede1cee925d87eef0b09da67d90b +5d5ea2fd05dbf369ccc53c93d4846623cdea0c47 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 257527) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -1330,9 +1330,24 @@ Func_descriptor_expression::do_get_backe else { Location bloc = Linemap::predeclared_location(); + + // The runtime package has hash/equality functions that are + // referenced by type descriptors outside of the runtime, so the + // function descriptors must be visible even though they are not + // exported. + bool is_exported_runtime = false; + if (gogo->compiling_runtime() + && gogo->package_name() == "runtime" + && (no->name().find("hash") != std::string::npos + || no->name().find("equal") != std::string::npos)) + is_exported_runtime = true; + bool is_hidden = ((no->is_function() && no->func_value()->enclosing() != NULL) + || (Gogo::is_hidden_name(no->name()) + && !is_exported_runtime) || Gogo::is_thunk(no)); + bvar = context->backend()->immutable_struct(var_name, asm_name, is_hidden, false, btype, bloc);