From patchwork Mon Oct 7 20:30:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1172955 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-510422-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rGJ/3GZ7"; 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 46nBv71YwHz9sP7 for ; Tue, 8 Oct 2019 07:30:43 +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:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; q=dns; s=default; b=SRjds0oThnl+IwSrJtTr+uz nSmBIamKTrepQVJnO1qlakGWqlf/y9aloHK3uI/BoAh8GfEoWesgTQxLRrFPhAF8 Vo6foTTbFkcNLg8ySaj1JUJE7bHKxvyvufyfHG0+lPeVY7R4mE2YiZCpRTF9Npn0 Np6zpqY4NUkJUdwdb9tg= 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:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; s=default; bh=H/p7r6Baxh60nSk22470hSE5VCA=; b= rGJ/3GZ7q2n/XbUwhcnM6jHTpSvD2DdxJn1osj3tqdzzhBk0XK5UOk5UDy6TD8qm etVFuXcWmM+9ycppjesENuLUbEOsxOCNyPAUX2rjeeUg99xsYSwUesEu2kgim5ce pIYLYVo+N7iPG1aAmER2dPVhkrQbexFiXXmlUeR3VV4= Received: (qmail 52154 invoked by alias); 7 Oct 2019 20:30:35 -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 52063 invoked by uid 89); 7 Oct 2019 20:30:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Spam-Relays-External:ESMTPA X-HELO: smtp2.wavenetuk.net Received: from smtp.wavenetuk.net (HELO smtp2.wavenetuk.net) (195.26.37.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Oct 2019 20:30:24 +0000 Received: from [192.168.1.212] (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp2.wavenetuk.net (Postfix) with ESMTPA id 04B9B600156 for ; Mon, 7 Oct 2019 21:30:18 +0100 (BST) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [Darwin, machopic 1/n, conmmitted] Consider visibility in indirections. Message-Id: <51C183FC-2852-423D-9EF6-131346C7748B@sandoe.co.uk> Date: Mon, 7 Oct 2019 21:30:15 +0100 To: GCC Patches For weak, hidden vars the indirection should just be as normal; that is, that the indirections for such symbols should appear in the non-lazy symbol pointers table, not in the .data section. tested on x86_64-darwin16, applied to mainline, thanks Iain gcc/ChangeLog: 2019-10-07 Iain Sandoe * config/darwin.c (machopic_output_indirection): Don't put hidden symbol indirections into the .data section, use the non-lazy symbol pointers section as normal. (darwin_encode_section_info): Record if a symbol is hidden. * config/darwin.h (MACHO_SYMBOL_FLAG_HIDDEN_VIS): New. (MACHO_SYMBOL_HIDDEN_VIS_P): New. diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 45e0d744ad..869e850c57 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1120,6 +1120,7 @@ machopic_output_indirection (machopic_indirection **slot, FILE *asm_out_file) machopic_output_stub (asm_out_file, sym, stub); } else if (! indirect_data (symbol) + && ! MACHO_SYMBOL_HIDDEN_VIS_P (symbol) && (machopic_symbol_defined_p (symbol) || SYMBOL_REF_LOCAL_P (symbol))) { @@ -1237,6 +1238,12 @@ darwin_encode_section_info (tree decl, rtx rtl, int first) if (VAR_P (decl)) SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_VARIABLE; + /* For Darwin, if we have specified visibility and it's not the default + that's counted 'hidden'. */ + if (DECL_VISIBILITY_SPECIFIED (decl) + && DECL_VISIBILITY (decl) != VISIBILITY_DEFAULT) + SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_HIDDEN_VIS; + if (!DECL_EXTERNAL (decl) && (!TREE_PUBLIC (decl) || !DECL_WEAK (decl)) && ! lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)) diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 39c54cc720..87e1eb63b1 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -828,6 +828,12 @@ extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS]; #define MACHO_SYMBOL_DEFINED_P(RTX) \ ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_DEFINED) != 0) +/* Set on a symbol that has specified non-default visibility. */ + +#define MACHO_SYMBOL_FLAG_HIDDEN_VIS ((SYMBOL_FLAG_SUBT_DEP) << 3) +#define MACHO_SYMBOL_HIDDEN_VIS_P(RTX) \ + ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_HIDDEN_VIS) != 0) + /* Set on a symbol to indicate when fix-and-continue style code generation is being used and the symbol refers to a static symbol that should be rebound from new instances of a translation unit to