From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8646 Path: news.gmane.org!not-for-mail From: Alex Dowad Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 1/3] in i386 CFI script, binary ops like ADD or AND modify 2nd operand, not 1st Date: Mon, 12 Oct 2015 15:58:58 +0200 Message-ID: <1444658340-10065-1-git-send-email-alexinbeijing@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1444658370 7016 80.91.229.3 (12 Oct 2015 13:59:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Oct 2015 13:59:30 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8658-gllmg-musl=m.gmane.org@lists.openwall.com Mon Oct 12 15:59:29 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZlddP-0003aS-3Z for gllmg-musl@m.gmane.org; Mon, 12 Oct 2015 15:59:27 +0200 Original-Received: (qmail 19650 invoked by uid 550); 12 Oct 2015 13:59:23 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 19548 invoked from network); 12 Oct 2015 13:59:18 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=uRf8ru7OZIHccvWan1AkNg2zVNRlG73LkJIeoDSlpo0=; b=OR99aFwWNgO0ecoy91mlWhwBCxlfvlN/oneOhg/HTVm/Rm8wfPgTwt7a8uKcHR27Sm N+fiD0rVVKNf77Bs/7FFh9k98+esPVlXbP/LDQY4PH72XTqjfimWY7YvgnAwkl7oOSdU mKx55wy3gaIKToJCNWLF7otFW6Qlf7QGYItQvV+In/NB4fpaSvV4UqZRu1xtSGQh5gXL RDPzfuDCkY8EImhXoV0zkdGEQbW7YB2CkAv5/mbrIOKmNHdBpOwpjh/cirMESrhBaCjC fRFU2yyt1KxJ+t5W3850Z33LNpbRRZC1yhyUbHVkG3nfYAwp4qGb+/xbIbj/dpNhH8rH Ja9A== X-Received: by 10.180.81.228 with SMTP id d4mr15411589wiy.38.1444658346612; Mon, 12 Oct 2015 06:59:06 -0700 (PDT) X-Mailer: git-send-email 2.0.0.GIT Xref: news.gmane.org gmane.linux.lib.musl.general:8646 Archived-At: thanks to R. Felker for noticing this problem. --- Fixed the issue with index registers being mistakenly identified as the destination for a binary op (thus causing their values to be treated as if overwritten). The fix is slightly hacky, but maintains brevity. The other option would be to write a long regex which is able to parse all x86 addressing modes. Also tweaked commit messages. Any other feedback will be appreciated, Alex Dowad tools/add-cfi.i386.awk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/add-cfi.i386.awk b/tools/add-cfi.i386.awk index 5dc8794..fc0d8cf 100644 --- a/tools/add-cfi.i386.awk +++ b/tools/add-cfi.i386.awk @@ -185,12 +185,12 @@ function trashed(register) { # this does NOT exhaustively check for all possible instructions which could # overwrite a register value inherited from the caller (just the common ones) /mov.*,%e(ax|bx|cx|dx|si|di|bp)/ { trashed(get_reg2()) } -/(add|addl|sub|subl|and|or|xor|lea|sal|sar|shl|shr) %e(ax|bx|cx|dx|si|di|bp),/ { - trashed(get_reg1()) +/(add|addl|sub|subl|and|or|xor|lea|sal|sar|shl|shr).*,%e(ax|bx|cx|dx|si|di|bp)/ { + trashed(get_reg2()) } -/^i?mul [^,]*$/ { trashed("eax"); trashed("edx") } -/^i?mul %e(ax|bx|cx|dx|si|di|bp),/ { trashed(get_reg1()) } -/^i?div/ { trashed("eax"); trashed("edx") } +/^i?mul [^,]*$/ { trashed("eax"); trashed("edx") } +/^i?mul.*,%e(ax|bx|cx|dx|si|di|bp)/ { trashed(get_reg2()) } +/^i?div/ { trashed("eax"); trashed("edx") } /(dec|inc|not|neg|pop) %e(ax|bx|cx|dx|si|di|bp)/ { trashed(get_reg()) } /cpuid/ { trashed("eax"); trashed("ebx"); trashed("ecx"); trashed("edx") } -- 2.0.0.GIT