From patchwork Wed May 17 00:52:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 94992 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp794994vqo; Tue, 16 May 2023 17:53:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6eO8GLToGnzajZR5wwMZwvJkmNyRGqjTmYBwzQVn2QkDVBRAkfvdL+aYHRKf1lDpC6gECY X-Received: by 2002:a17:907:c1e:b0:94a:4107:3975 with SMTP id ga30-20020a1709070c1e00b0094a41073975mr35229779ejc.76.1684284792646; Tue, 16 May 2023 17:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684284792; cv=none; d=google.com; s=arc-20160816; b=mAr9BoF18/SCII+7HRkSWbd7VGs90xMGEQ+E5yRXn2zCOOigcJmsvblxntzsA8jgsk nf19wgpv/rGJw820TfbdME0ovigl1pIk9CrH0jbF6jyI6qENO7KZm2iLjllPCF7aMOlM VcjoJ4Ntrr8hnbzCLe3XsmjoibJ1A0W3/yEZg/7RJ8wrrnRxJMF8Hg9iLUwCw+D1iuec 3BfjqbXkXHgmr3E6QaOBMkBI46hzch+0eVXcXRg/+i5Q44P4RXUlP+jtqBYRjQyxkXfg Lq4vAPr3LIy6T91FSBpHy2ZTJJT5leTHfCqP1jqlYq+r2O7w5eNC7TpBeb6Ahk+T4JO+ h7uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=jRrfgb4AJPxIPE+Xg+SYRDX/YBK0DB3aUgSN17MM00I=; b=bxRCEclNwIg6PL/PqqApYHYBvVpSWRyno+g4B5TAwYIPX4zUm0FTOGtRABu1x9QkOC EcO9TjLkjPM/dmyeSwEYLeJ/yKUG1ZEN0TCWiJXgR86clcqp+rQXyGOzzqntXVaDL6ir 2IEh5x3vnAvTbHWtRZBLrBp/HmAkHuDk1FB+QXr8PUhpmQB6lf/dWdbtWVEYYx8AH+j3 y/MNclIleM1dvK0kXphZytG+ScV/AuRm79gGRVDwTJQLvZYif5lK//X3WrCGUSaDRTrs i/qm1j7wZwGE4zDprt88vdejB3ag3k55cRPIt1xoeYcKef382phRVCYHD80jDf1gMKOW mDbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HWshttcc; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dx18-20020a170906a85200b0094f70e98f95si16021381ejb.757.2023.05.16.17.53.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 17:53:12 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HWshttcc; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B6693856243 for ; Wed, 17 May 2023 00:53:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B6693856243 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684284791; bh=jRrfgb4AJPxIPE+Xg+SYRDX/YBK0DB3aUgSN17MM00I=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=HWshttcczH+sVWv2xNB/z3s1j418IO2T2NDCd+4t8zBBK34/od1eZpn31IxJX2wyi whIRzPAA96QjIvTyeBODyvDq1zU4h8uDcQJUgNRh/yLB8K1Pp4pnyOPIRmJAMNqVMi 1mmYpPsoaRqD9nqByEYezigs9iLX8pGUchJklBDU= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 876693858D1E for ; Wed, 17 May 2023 00:53:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 876693858D1E Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-64384274895so88185b3a.2 for ; Tue, 16 May 2023 17:53:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684284779; x=1686876779; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jRrfgb4AJPxIPE+Xg+SYRDX/YBK0DB3aUgSN17MM00I=; b=Q8/tX4Z0mk3kzEUGuCGtPlpffU0GsLgT3FgojN45FRWfFTmdB/gXgvhhRuQrkyVqAh LpilZfYy0WGfWBeeNIyqz0gu6YeZS42A3xRGkt79g1ESdQzzinMoxDB6FDauv2dMKuvq +WOcNm43ZOf4DSVa8kL9ypwcYqnp6hhKYwVarX8i3Zj7Ubu/mXpzbjq7LR0XhDJ/te9Q qN5jFePHItbLmZcalw/u/weTnQe0cGJ+03msnJ9EYYw0ZKwWwy17van/vHDznf+yPuWx ZCDMX3uK/2y+mUSVKekEl004JVDQ4SVGjeG9cdhNdIt+F12Xbv1bmanXoKtVBWPJnvuF w+qQ== X-Gm-Message-State: AC+VfDz0UC3K6vg63xNMJr/TtrlswDatu/+wcQd+o8jvOtuw208MjtMS zPH45FPYGBx4OBW6yKoFKFfirBfFZmY= X-Received: by 2002:a05:6a00:1312:b0:648:774d:3cd0 with SMTP id j18-20020a056a00131200b00648774d3cd0mr27614497pfu.14.1684284779422; Tue, 16 May 2023 17:52:59 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:3c4d:54da:637:3855]) by smtp.gmail.com with ESMTPSA id w4-20020aa78584000000b0063a04905379sm13969895pfn.137.2023.05.16.17.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 17:52:58 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id BF16711409AA; Wed, 17 May 2023 10:22:55 +0930 (ACST) Date: Wed, 17 May 2023 10:22:55 +0930 To: binutils@sourceware.org Cc: Matthew Glazar , Jan Beulich , Dave Korn Subject: PR29189, dlltool delaylibs corrupt float/double arguments Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766100610780956756?= X-GMAIL-MSGID: =?utf-8?q?1766100610780956756?= PR29189 is an excellent bug report. The reporter debugged the problem to the point of finding out exactly where things were going wrong (in a windows dll, so not a mingw problem) and even supplied a fix, giving an ABI reference. There hasn't been any action on the bug report due to lack of an active mingw binutils maintainer, so I thought I'd take a look as part of trying to whittle down the enormous number of binutils bugzilla entries. This is a rewrite of the patch given in the PR. (It might even resemble code emitted by Microsoft's LINK.EXE as reported in https://www.mail-archive.com/llvm-bugs@lists.llvm.org/msg55205.html). I'm not going to apply it without review from an x86 maintainer, because it's been too long since I did any serious x86 specific work and I don't want to break things for someone running an original amd64 machine. The patch needs to be tested too. I don't have a mingw setup. PR 29189 * dlltool.c (i386_x64_trampoline): Save and restore xmm0-3. Make use of parameter save area for integer arg regs. Comment. diff --git a/binutils/dlltool.c b/binutils/dlltool.c index 31c864d7d5c..eb2c4f34658 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -583,22 +583,37 @@ static const char i386_trampoline[] = "\tpopl %%ecx\n" "\tjmp *%%eax\n"; +/* Save integer arg regs in parameter space reserved by our caller + above the return address. Allocate space for four fp arg regs plus + parameter space possibly used by __delayLoadHelper2 plus alignment. + We enter with the stack offset from 16-byte alignment by the return + address, so allocate 64 + 32 + 8 = 104 bytes. + FIXME: do we need to save avx ymm0-5 used to pass vectors args? If + so, how to do it without blowing up on cpus without avx, cpuid? */ static const char i386_x64_trampoline[] = - "\tsubq $72, %%rsp\n" - "\t.seh_stackalloc 72\n" + "\tsubq $104, %%rsp\n" + "\t.seh_stackalloc 104\n" "\t.seh_endprologue\n" - "\tmovq %%rcx, 64(%%rsp)\n" - "\tmovq %%rdx, 56(%%rsp)\n" - "\tmovq %%r8, 48(%%rsp)\n" - "\tmovq %%r9, 40(%%rsp)\n" - "\tmovq %%rax, %%rdx\n" - "\tleaq __DELAY_IMPORT_DESCRIPTOR_%s(%%rip), %%rcx\n" + "\tmovq %%rcx, 104+8(%%rsp)\n" + "\tmovq %%rdx, 104+16(%%rsp)\n" + "\tmovq %%r8, 104+24(%%rsp)\n" + "\tmovq %%r9, 104+32(%%rsp)\n" + "\tmovaps %%xmm0, 32(%%rsp)\n" + "\tmovaps %%xmm1, 48(%%rsp)\n" + "\tmovaps %%xmm2, 64(%%rsp)\n" + "\tmovaps %%xmm3, 80(%%rsp)\n" + "\tmovq %%rax, %%rdx\n" + "\tleaq __DELAY_IMPORT_DESCRIPTOR_%s(%%rip), %%rcx\n" "\tcall __delayLoadHelper2\n" - "\tmovq 40(%%rsp), %%r9\n" - "\tmovq 48(%%rsp), %%r8\n" - "\tmovq 56(%%rsp), %%rdx\n" - "\tmovq 64(%%rsp), %%rcx\n" - "\taddq $72, %%rsp\n" + "\tmovq 104+8(%%rsp), %%rcx\n" + "\tmovq 104+16(%%rsp), %%rdx\n" + "\tmovq 104+24(%%rsp), %%r8\n" + "\tmovq 104+32(%%rsp), %%r9\n" + "\tmovaps 32(%%rsp), %%xmm0\n" + "\tmovaps 48(%%rsp), %%xmm1\n" + "\tmovaps 64(%%rsp), %%xmm2\n" + "\tmovaps 80(%%rsp), %%xmm3\n" + "\taddq $104, %%rsp\n" "\tjmp *%%rax\n"; struct mac