From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8655 Path: news.gmane.org!not-for-mail From: Alex Dowad Newsgroups: gmane.linux.lib.musl.general Subject: [PATCHv3 1/3] fix matching errors for overwritten registers in x86 CFI generation script Date: Tue, 13 Oct 2015 13:28:50 +0200 Message-ID: <1444735732-12265-1-git-send-email-alexinbeijing@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1444735764 32422 80.91.229.3 (13 Oct 2015 11:29:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Oct 2015 11:29:24 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8667-gllmg-musl=m.gmane.org@lists.openwall.com Tue Oct 13 13:29:19 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 1Zlxle-00042i-CS for gllmg-musl@m.gmane.org; Tue, 13 Oct 2015 13:29:18 +0200 Original-Received: (qmail 7391 invoked by uid 550); 13 Oct 2015 11:29:14 -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 7301 invoked from network); 13 Oct 2015 11:29:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=/5sIO26RFh9BxglumV1fVGFLMMs5ezsGW4IFC7obNHA=; b=t57oGY7ObrEyr4eKUfp/7YrIufEtwgQWl1ATo2IQSnJu7XMTdBu/1RLlaZo0pU5VR2 N8EksoG8JSs/LICQs+jm45TrKvYmk+NATIdzHmOMp3kivI/BxnCkMgYGjdXRwJtu3Vpi ExMj0iSjYCQ4sYss+bHHnoY6GUPzshhXhiA2GGOdFYnTU185bxFMtAc8yJmCGlnAsSh6 1TeYa9fCZ+6HcA0hhh/ceEavSZV8BKNS0ZBPxluIdgxRSleI3iu1LSTe/M/R/k7SnHaW lImcG5ELOmp2Ms1uzrMVu8y3B3GfOcu+KU/EOb0mmz25tT6FREmN+oYxiRuP+oIsb09w PT6A== X-Received: by 10.180.208.100 with SMTP id md4mr19538192wic.41.1444735736930; Tue, 13 Oct 2015 04:28:56 -0700 (PDT) X-Mailer: git-send-email 2.0.0.GIT Xref: news.gmane.org gmane.linux.lib.musl.general:8655 Archived-At: thanks to R. Felker for noticing 2 separate problems: - binary ops like ADD, AND, etc. overwrite the 2nd operand, not the 1st. this confusion resulted from mixing up Intel and GNU asm syntax. - the regexps used to identify clobbered registers would erroneously match index registers. in other words, the following asm: mov $0, (%eax,%ebx,4) ...would cause EBX to be considered as overwritten, which might prevent a debugger from displaying a variable's value in a higher stack frame. --- Here is the latest iteration. I have merged 2 previously separate commits, and fixed up the matching of registers (for the purpose of identifying overwritten registers). As usual, thanks for the feedback. AD tools/add-cfi.i386.awk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/add-cfi.i386.awk b/tools/add-cfi.i386.awk index 5dc8794..bd7932f 100644 --- a/tools/add-cfi.i386.awk +++ b/tools/add-cfi.i386.awk @@ -184,13 +184,13 @@ 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()) +/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_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