From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101672 invoked by alias); 19 Jun 2015 07:13:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 100869 invoked by uid 89); 19 Jun 2015 07:13:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 19 Jun 2015 07:13:41 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id A4414285416E; Fri, 19 Jun 2015 09:13:35 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cRB8cKWuvmpw; Fri, 19 Jun 2015 09:13:35 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 8FD6F285412E; Fri, 19 Jun 2015 09:13:35 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Subject: Re: RFC: Prevent disassembly beyond symbolic boundaries From: Tristan Gingold In-Reply-To: <87lhfhynoz.fsf@redhat.com> Date: Fri, 19 Jun 2015 07:13:00 -0000 Cc: binutils@sourceware.org, gdb-patches@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: <3D81F97D-90EA-4769-8381-514BB6E81E3F@adacore.com> References: <87lhfhynoz.fsf@redhat.com> To: Nick Clifton X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00401.txt.bz2 Nick, > Currently objdump will disassemble beyond a symbolic boundary if it > needs extra bytes to decode an instruction. For example (with x86): >=20 > .file "foo.c" > .text > .globl foo > .type foo, @function > foo: > .byte 0x24 > .byte 0x2f > .byte 0x83 > .size foo, .-foo >=20 > .globl bar > .type bar, @function > bar: > .byte 0x0f > .byte 0xba > .byte 0xe2 > .byte 0x03 > .size bar, .-bar >=20 > This will disassemble as: >=20 > 0000000000000000 : > 0: 24 2f and $0x2f,%al > 2: 83 0f ba orl $0xffffffba,(%rdi) >=20 > 0000000000000003 : > 3: 0f ba e2 03 bt $0x3,%edx >=20 > Note how the instruction decoded at address 0x2 has stolen two bytes > from "foo", but these bytes are also decoded (correctly this time) as > part of the first instruction of foo. >=20 > I have a patch (attached) which changes this behaviour, so that the > disassembly would be: >=20 > 0: 24 2f and $0x2f,%al > 2: 83 .byte 0x83 >=20 > 00000003 : > 3: 0f ba e2 03 bt $0x3,%edx [=E2=80=A6] > What do people think ? To me this seems like a good idea, but I > willing to consider alternative suggestions if people have them. I am curious. Why do you think it was a problem ? Even if there is a symbol in the middle of an instruction, I=E2=80=99d like to understand what the processor will execute. Before the proposed change, it was possible, but after it isn=E2=80=99t easy anymore. (But I agree I never met this issue. I am just curious here). Tristan.