Message ID | 5A1812F4.1050904@arm.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 61495 invoked by alias); 24 Nov 2017 12:39:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <libc-alpha.sourceware.org> List-Unsubscribe: <mailto:libc-alpha-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:libc-alpha-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 61483 invoked by uid 89); 24 Nov 2017 12:39:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=upcoming X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Message-ID: <5A1812F4.1050904@arm.com> Date: Fri, 24 Nov 2017 12:39:16 +0000 From: Szabolcs Nagy <szabolcs.nagy@arm.com> 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 <libc-alpha@sourceware.org> CC: nd@arm.com, "H.J. Lu" <hjl.tools@gmail.com> Subject: [PATCH][RFC] aarch64: fix start code for static pie Content-Type: multipart/mixed; boundary="------------070600030106010101040509" X-ClientProxiedBy: AM6PR0502CA0007.eurprd05.prod.outlook.com (2603:10a6:209:1::20) To HE1PR0802MB2492.eurprd08.prod.outlook.com (2603:10a6:3:df::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603258)(49563074); SRVR:HE1PR0802MB2492; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2492; 3:EVKw/6P7NIn7SxH8CUk3iPGCCH5pfI61ZF7JMTnBBpTpkn5dEtttamA0ZPEejBae3HPmQxY9hn03U7sR1NldvRJMUqRekTv7qsneQRmH9ypTX/PAyosNXmvZQbaPKq9vfqgWZ7lHy778adspF6UDazhKz+I08WhBZAzS3yuqVrPrWN3ZHG0tKisVfx9F5Z9wsAMMiBSa1f7YEYPzlG4+QyjdB4il8lT7Pnr3Wy7VXiPP35qS3yOr25Ir72E2SLNp; 25:qzUVmLJRJ7kVoWGus2kzq/SriNU3aY1B1Vf9thmPHEmjqJ03frH9p2HBs+E7mjKlNf9kiSSDXN3guo204+cerYJG2wRiLIzvlL4Jhq5PPHuMwUjWhl6dp81W2YLaLsk2DEtmegtJne6Tyq6hOXSFunLKFyBgBvNYldDYC2HNzLpGEVUpKgFLjdg6BsTuY2BRSiGrJ+E6UIm/HWBO2K7t0eJ1q+oAkFSDMHuxMpYoqJL1LVltf+XQz8juM9kNqQnYNA9dqyfq0Y15rznUwgTlEGug3JvGW+8C3gLLiYsSZp99LEHWmJeq/EKkCs9zFG65oraas3N7pjnwYNCGzCSEgA==; 31:7x5KLgPN92Vr1ZCzQ7sXnd/LrXIyOsbJLi7EHhdbBeeosSueJYGmEqhOWrYACMR5xyIp71bp9wCx9J4DUF4mxtbGtXgyYMLAMtVEb4NdfFPOQIGaqZNfsZtIQBI59J6LJP6Hw+4I+D5AjebfWgdWU6R4YONTH1i/4WPpgnbfaeQMlE2JMAVHrnKGrTkrqmZgNplqXkTTFCq3rPOTMN9qP7TZhWG/y7Beltixbsyg+x8= X-MS-TrafficTypeDiagnostic: HE1PR0802MB2492: X-MS-Office365-Filtering-Correlation-Id: 379a3b78-5321-4bd2-8452-08d5333861fb NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2492; 20:erF0J5agPix0WEOeievBsnVAtVZ99SpkfOB+ErUoorsKeklyHcwS5E5iYwsQVJilmInlTdqnxmv+hxDc/ssgqowq4YdpJVC7eHP6xkEzu+qfRU2CDlZPx7mV5Hltjhj5Bqq9Z+YIfMQ2FoQ51LiIBsI1lJJw2OWYnhmbzTzFAf4=; 4:bgX5tfDzhbQc/oG2TwswmCw9m1K5V+0sKt6ZVGwEF1Yh5BOO/SvySmt8JvKi2UYkxRGk6qcZPpx2p1bbJiUs3MvMy3XWOGu9qcC6FT0j8rbF5Sj0ks4CYpcAWy1bywOzywGuQtDkeOHMZB145ROIhztrfxTil1QpecKxp26WVCMIJJYzwdHiyZcG52xThu+eez2MjLQjHkrUioKhIHEzE8wIKnCbmoi/t4BP4CVH5i39yiQ2QbRCZsLxZTW6sFf229UQ1+Eqs6sADpKy4C3IiuB6L5wnmyE7MO5Lb1Zr7lUx96QDBPwB6AfCcpowLKah X-Microsoft-Antispam-PRVS: <HE1PR0802MB24929215F53375C929BADA49ED260@HE1PR0802MB2492.eurprd08.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(102415395)(6040450)(2401047)(8121501046)(5005006)(3002001)(3231022)(10201501046)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123564025)(20161123562025)(20161123560025)(6072148)(201708071742011); SRVR:HE1PR0802MB2492; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR0802MB2492; X-Forefront-PRVS: 05015EB482 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6049001)(6009001)(346002)(366004)(376002)(39860400002)(377424004)(189002)(199003)(97736004)(66066001)(8936002)(6666003)(105586002)(58126008)(106356001)(6916009)(4610100001)(54356999)(87266999)(53936002)(50986999)(5660300001)(39060400002)(59896002)(65816999)(16526018)(21490400003)(83506002)(52116002)(5890100001)(101416001)(33656002)(2906002)(4326008)(86362001)(16586007)(65956001)(65806001)(80316001)(68736007)(36756003)(316002)(77096006)(6486002)(189998001)(81166006)(4001150100001)(270700001)(64126003)(568964002)(81156014)(84326002)(8676002)(25786009)(72206003)(2476003)(478600001)(305945005)(7736002)(16576012)(3846002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0802MB2492; 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) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs.Nagy@arm.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0802MB2492; 23:3cyMbrhQYILEpUIFNGppvr5OZfySyh9azYXNTT4?= =?us-ascii?Q?o+vPAd79YkkwJ/dy0m/YJq58wP2l1N1cuBOFsnPd3Jq97s4v8BnwIZAs21Ex?= =?us-ascii?Q?ZQozsCQ8ceVC7u9xgM6DF6TwyMFq+UquiYXFn2EcfWw6eybpr45TTAp1iQYY?= =?us-ascii?Q?7GqOuuie9bgYS98MGC+iB4i+EMNxGmWIj+yYOGCad2s9Sc0f9FRwo6wpb/Bq?= =?us-ascii?Q?Q+PY6H8urtqOCU2+X8JhV9+McFVs0g+lX02TmzdNOJI2SyagHMzsxCgIbUsl?= =?us-ascii?Q?8QRyemDJaKoS3m0Ei4O34PTahaT/yX9/c8I0DlpvlwxWyNNThSdOqCNP37Ma?= =?us-ascii?Q?8xAWaBg92XPhworX/df2X1fYP5BvCwAwmd0Bf4oZugIuv1Z7WwMU2lg6+BNM?= =?us-ascii?Q?r7Jr2lUid+t7DKeEU6ncW9sUanIiiZQhWuVgM/RwxBowII8BfDq+igXVmqjh?= =?us-ascii?Q?sfOEfUW174dFEqAy2bCe1UYWtruCOdNWEMWRdtb+n36QHQmarsDnFlwcajLL?= =?us-ascii?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/Wj SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2017 12:39:19.4257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 379a3b78-5321-4bd2-8452-08d5333861fb X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2492 |
Commit Message
Szabolcs Nagy
Nov. 24, 2017, 12:39 p.m. UTC
with upcoming static pie patches there are three flavors of the crt startup code: 1) crt1.o used for non-pie static linking (executable has no relocs), 2) Scrt1.o used for dynamic linking (dynamic linker relocates), 3) rcrt1.o used for static pie linking (self relocation is needed) when crt1.o and rcrt1.o is built in the --enable-static-pie case -DPIC is passed, when Scrt1.o is built then -DPIC -DSHARED is passed. (crt1.o gets a dummy _dl_relocate_static_pie that interposes the one in libc so no self-relocation is done in that case in __libc_start_main) the Scrt1.o code is position independent but it relies on GOT entries that need to be relocated which happens later and the static linker cannot relax the GOT loads, so rcrt1.o needs separate implementation. This implementation works with .text <= 4G files, which is fine, currently the toolchain does not support larger position independent executables. tests pass with ld/22269 and ld/22263 binutils bugs fixed. this patch is on top of master but assumes the static pie patches. 2017-11-24 Szabolcs Nagy <szabolcs.nagy@arm.com> * sysdeps/aarch64/start.S (_start): Handle PIC && !SHARED case.
Comments
On 24/11/17 12:39, Szabolcs Nagy wrote: > 2017-11-24 Szabolcs Nagy <szabolcs.nagy@arm.com> > > * sysdeps/aarch64/start.S (_start): Handle PIC && !SHARED case. > committed with updated commit message: There are three flavors of the crt startup code: 1) crt1.o used for non-pie, 2) Scrt1.o used for dynamic linked pie (dynamic linker relocates), 3) rcrt1.o used for static linked pie (self relocation is needed) In the --enable-static-pie case crt1.o is built with -DPIC and in case of static linking it interposes _dl_relocate_static_pie in libc to avoid self relocation. Scrt1.o is built with -DPIC -DSHARED and it relies on GOT entries that the static linker cannot relax and thus need relocation before the start code is executed, so rcrt1.o needs separate implementation. This implementation does not work for .text > 4G position independent executables, which is fine since the toolchain does not support -mcmodel=large with -fPIE. Tests pass with ld/22269 and ld/22263 binutils bugs fixed. * sysdeps/aarch64/start.S (_start): Handle PIC && !SHARED case.
On Mon, Dec 18, 2017 at 2:22 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote: > On 24/11/17 12:39, Szabolcs Nagy wrote: >> 2017-11-24 Szabolcs Nagy <szabolcs.nagy@arm.com> >> >> * sysdeps/aarch64/start.S (_start): Handle PIC && !SHARED case. >> > > committed with updated commit message: > > There are three flavors of the crt startup code: > > 1) crt1.o used for non-pie, > 2) Scrt1.o used for dynamic linked pie (dynamic linker relocates), > 3) rcrt1.o used for static linked pie (self relocation is needed) > > In the --enable-static-pie case crt1.o is built with -DPIC and in case > of static linking it interposes _dl_relocate_static_pie in libc to > avoid self relocation. > > Scrt1.o is built with -DPIC -DSHARED and it relies on GOT entries that > the static linker cannot relax and thus need relocation before the > start code is executed, so rcrt1.o needs separate implementation. > > This implementation does not work for .text > 4G position independent > executables, which is fine since the toolchain does not support > -mcmodel=large with -fPIE. > > Tests pass with ld/22269 and ld/22263 binutils bugs fixed. > > * sysdeps/aarch64/start.S (_start): Handle PIC && !SHARED case. > Can you update NEWS to add aarch64 to static PIE? Thanks.
diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S index c20433ad73..cd7ba7df3e 100644 --- a/sysdeps/aarch64/start.S +++ b/sysdeps/aarch64/start.S @@ -60,7 +60,8 @@ _start: /* Setup stack limit in argument register */ mov x6, sp -#ifdef SHARED +#ifdef PIC +# ifdef SHARED adrp x0, :got:main ldr PTR_REG (0), [x0, #:got_lo12:main] @@ -69,6 +70,15 @@ _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 x3, __libc_csu_init + add x3, x3, :lo12:__libc_csu_init + adrp x4, __libc_csu_fini + add x4, x4, :lo12:__libc_csu_fini +# endif #else /* Set up the other arguments in registers */ MOVL (0, main)