From patchwork Fri Jan 12 18:13:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 860144 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=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-89163-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="uz0Sgia+"; 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 3zJ9qj57dZz9sNx for ; Sat, 13 Jan 2018 05:14:09 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:content-type; q=dns; s=default; b=faA4reblB8tuJM2Hb63iO d2W/V2cIEDe5+AREHAUnJtE6UMC2DKL5Bl+KYh8BOfRznpniWWCgIh2xpOP26uYI Cv7oLyOiONK3NrLpqcmu1jFeJ0osJcJHczAdmj8fKpb+HMj9C31VjZCMaYbRVTyO vdX5NFJJcHlBr1nbLXxoFo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:content-type; s=default; bh=mXoNcZZG70lWpfBJM8eNnxm/H6c =; b=uz0Sgia+xaC2+La9VawClRGQtt7sAL72yOzSuBA5PKVCbo9Ib7vO1S9c0MJ TnjGlH4CdzWBFdAgiuoQeU3uOLkzOV5ypqElNIpsmQqo7rYeE93WG+X99yaybEn/ IDZZPillEcSqv/v02DbDipLzEcguYDvOlh7B4l/5f0xyYwwQ= Received: (qmail 128134 invoked by alias); 12 Jan 2018 18:14:03 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 127403 invoked by uid 89); 12 Jan 2018 18:14:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Further, HX-ClientProxiedBy:401, HX-ClientProxiedBy:sk:CWLP265 X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs.Nagy@arm.com; Message-ID: <5A58FAE2.4050905@arm.com> Date: Fri, 12 Jan 2018 18:13:54 +0000 From: Szabolcs Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: GNU C Library CC: nd Subject: [committed] aarch64: fix static pie enabled libc when main is in a shared library X-ClientProxiedBy: CWLP265CA0010.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:10::22) To HE1PR0802MB2489.eurprd08.prod.outlook.com (2603:10a6:3:d8::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c656e1e-e548-471c-9dc2-08d559e83fac X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020085)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(49563074)(7193020); SRVR:HE1PR0802MB2489; X-Microsoft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Ixf2wkLhKrJniicT0BtzhM6yx/FeCiEXuHC5bFX5Fh0iozvFn3isOStDTs0bsGQ=; 4:u/hGztraklVurcGPTY6V9kzpFlk5uaOtv/Kwl2PPHJbMlBZWqz1z8JBi377rEZ9vy8FYgusivo3YLAXP2IVoIVJLh6etm9zfhQBzmOVJWARRqkFzd53pAZC88f4Yhg+HZ4WbA4+DcYce9ty7LHJ61QYskY6aXn0T6VarLjuA/FblgenfPXZd5hyHvFOugkQBGjq1d0EUj3tMe3Tg3qhDlt0WG5Xn2+iDd/cPdB1kB8L7ZnqEGZhstXg4K6yUil2yQ2HR0UzBJwczNkDx0uxQ9/H/r7eIw7t9BqTe+HT9sjDlULrpJdiAlfpCl8gv/VWy X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(102415395)(6040470)(2401047)(8121501046)(5005006)(10201501046)(3231023)(944501146)(3002001)(93006095)(93001095)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR0802MB2489; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR0802MB2489; X-Forefront-PRVS: 0550778858 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6049001)(376002)(346002)(366004)(39380400002)(396003)(39860400002)(189003)(199004)(377424004)(270700001)(386003)(4326008)(83506002)(64126003)(52116002)(4610100001)(2906002)(33964004)(84326002)(305945005)(478600001)(81166006)(87266011)(2476003)(3846002)(568964002)(33656002)(68736007)(6116002)(72206003)(5660300001)(316002)(16576012)(5000100001)(25786009)(6666003)(59896002)(81156014)(6916009)(65816011)(16526018)(106356001)(8676002)(5890100001)(105586002)(53936002)(66066001)(77096006)(86362001)(58126008)(65956001)(7736002)(36756003)(80316001)(16586007)(6486002)(97736004)(65806001)(8936002)(21490400003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0802MB2489; H:[10.2.206.69]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2489; 23:UQwVaboQJX9/cfXYJnZYReAQ2OlWdz6/qZzrhplSQ7l3sMsZhDQfEerlg4QGNbb4lEvXV0HQOgYioCd1t0dpJbnEft2hV5/JQ0Ey2XjO3crYU9OPx6PwujXboA1wglOMsOiOrnFtztKuTImA6VPO6Efvua65Mlv9ARBwvIJvlxCzbdfgb8m0JAYfJ3mFwZ0O3qbeQJt+i1Q2Dps9+1bXHdWPjYuqZgERthe6/9fpFsbWsb5Kv4wfHBfJrPg0kKUcfP9cvPNYicfmhuZgnfzxBGc/b3cMmhr31uqjLSt91rlNy3i3XMpp4CsMYN84hNhTrEIHzA8BI6Eywc5RS6X9O3if4cm7TnWAPwEOywD7XhJJzmXEFj0gZObVqLfDedLRchy3rNs2rmDh6iTYMgLtZ9KxoDtc2KU4Ly0ekUF/4CpXq8wDObtd4c6JX21/Zaexzo0oWNKN3ObpvpTXvvFO/0GxkdG/cI4EKC6qYAEb4AZiP0Er/cosxq22IJz7n3akQOEfiNMzFx3V4aggTIj+4hAoZh2S/xtoUHA9JaLIug5TvHvTf2nBG69KzOSqsKRUkwYyJRtF9lVm3C2OAJYd5InyqXrlu3QJpeDCC2ny8BXGAsb+gbodat8XXfPPUA59dXhr0nI5jtURAClP/9Td0vOiG4XnqvjpJORUA+JbLrn4yWdl0srBwUZaWX6pbgNjTkRz73AEsgGtW0V7J9OZj+57GhciGAmCfMrQjKJr96zdxliSZTmjuBpwKfDwRdMLhRqKQp3/XDA+SdcJ8p1lew1p14sPygHV4m9Brj+aAmEzH0rEbDHs0yKbcD2ng4jv6W6Y1aHQ+8cF+0LV6VFPSnUcDM6U+QTwqdNU3P8t1poiZL2V0zaT7SoOTC7ArZS2vjpJ8v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K2EG6NuwMyGvqqPLnMwyppbX/1UtQ=; 24:TNmd9saIqoDB3ZhHU1Wnrv8lzzhnVIQijpbXSsqZ0yW2Uqr1Ni5uyUHvMIMdOQV+aW0wghLVH2577Cjlj/otluroatr/t5BuPXESZ+ya1mU=; 7:fk571CBYwecRJmHvRqnLDsWMSU3EuVFruA4udW8Mr2lp+Ny6qfwH8UIiK9ra6bvZdek5fQ/OnbSQRzY+IFj0Dpi4/KexSvmoz2F7BUEmYD7ggxSoDiL4OTaVMVVZn4x5YtCpFY1jsV15OkfiQKEmBfrAEGSrnMRBAITXJLvzXK5sjgmxeheM4j8U2ZY87s+GuObOYnPf2XaUIB23LJzw+DZ9cPKLx9Pog9iKMihaSCvCWwyoq6m9rzGNgzwePN2m SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2018 18:13:57.4605 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c656e1e-e548-471c-9dc2-08d559e83fac X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2489 In the static pie enabled libc, crt1.o uses the same position independent code as rcrt1.o, and crt1.o is used instead of Scrt1.o when -no-pie executables are linked. When main is not defined in the executable, but in a shared library crt1.o is currently broken, it assumes main is local. (glibc has a test for this but i missed it in my previous testing.) To make both rcrt1.o and crt1.o happy with the same code, a wrapper is introduced around main: with this crt1.o works with extern main symbol while rcrt1.o does not depend on GOT relocations. (The change only affects static pie enabled libc. Further simplification of start.S is possible in the future by using the same approach for Scrt1.o too.) 2018-01-12 Szabolcs Nagy * aarch64/start.S (_start): Use __wrap_main. (__wrap_main): New local symbol. diff --git a/ChangeLog b/ChangeLog index 971257a4bd..da74352ce1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-01-12 Szabolcs Nagy + + * aarch64/start.S (_start): Use __wrap_main. + (__wrap_main): New local symbol. + 2018-01-12 Dmitry V. Levin [BZ #22679] diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S index 9f3b4188db..bad000f555 100644 --- a/sysdeps/aarch64/start.S +++ b/sysdeps/aarch64/start.S @@ -71,8 +71,8 @@ _start: adrp x4, :got:__libc_csu_fini ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini] # else - adrp x0, main - add x0, x0, :lo12:main + adrp x0, __wrap_main + add x0, x0, :lo12:__wrap_main adrp x3, __libc_csu_init add x3, x3, :lo12:__libc_csu_init adrp x4, __libc_csu_fini @@ -94,6 +94,15 @@ _start: /* should never get here....*/ bl abort +#if defined PIC && !defined SHARED + /* When main is not defined in the executable but in a shared library + then a wrapper is needed in crt1.o of the static-pie enabled libc, + because crt1.o and rcrt1.o share code and the later must avoid the + use of GOT relocations before __libc_start_main is called. */ +__wrap_main: + b main +#endif + /* Define a symbol for the first piece of initialized data. */ .data .globl __data_start