From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 7AFBD3858C54 for ; Thu, 11 May 2023 09:04:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AFBD3858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683795868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Is6JVSN2vTf7q0hdzEoU39dv5eqvkCAizJp/aBzKf9M=; b=BFA89FyDdX2HKKWuGcj3kfJn8nEpwMom+XsRbR5IhHP3oLONJz6bDTfd2IEFP+hi5TbmuN khzK/neVdKrek2CvBvRe+76l91dAkotN3hgf+HIcQQYqOS43Yjd9cNTom6udwYx1gfllik NiEfkp7BSCq2q94a3M6y3rMYeGuIYrI= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-77-N3AiHV6aNpmQjM1e8vbm-A-1; Thu, 11 May 2023 05:04:27 -0400 X-MC-Unique: N3AiHV6aNpmQjM1e8vbm-A-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-751409cba6dso515430885a.3 for ; Thu, 11 May 2023 02:04:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683795866; x=1686387866; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Is6JVSN2vTf7q0hdzEoU39dv5eqvkCAizJp/aBzKf9M=; b=CEPeEWYg7XtTnnhpJLuKNzvspAXoBUxNVlpNC8kVoFMD2H+d3wqHaqgcJh37//dN8J gMk+T9N5B5rh6NXUJ97fAdhPs0Lg02WRMzNRNEoSPdlJuvpIYWljVX93FOTNLaDlO+bJ um89l7lR6QXdvb9GdggWokrGNabuKRYNYIK3lHnopR42fFQiAE04nDPztY0ZLeOcLW38 D3aQEW9SShCieSMnZbobio6wqSVcb70umPuNLjkm03MEmeqMKUK9SDZfmTvNRAWZUwPo kqcH/b63SOFeLhv6yP24xiRBln3jMJC8SHjcJ+cBsk8o285UPewyJIMG/XkmGJG2wziA +GMg== X-Gm-Message-State: AC+VfDwjkHpE4eNhonexPx/07blEOodtrW3/N9lmJPs3oooicrrABj+j qZ7cA1td1GzQe0GGd5Fi4uwzZLjHGbr9hB1khBRKzj//tDbo+67NBPOxhmNIVxaaHu16SoVVYhs TnmbZO8CsDlEj14uw7SMdhA== X-Received: by 2002:ac8:5911:0:b0:3ef:57c1:ad7 with SMTP id 17-20020ac85911000000b003ef57c10ad7mr30797056qty.30.1683795866457; Thu, 11 May 2023 02:04:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7yvB+PQxxiaQoPjcNzlMiPU3Uof9JTLPTb8ID5e6Y5Vm+7706AvLtSGpSg5tMbmAD6b++kTw== X-Received: by 2002:ac8:5911:0:b0:3ef:57c1:ad7 with SMTP id 17-20020ac85911000000b003ef57c10ad7mr30797023qty.30.1683795865969; Thu, 11 May 2023 02:04:25 -0700 (PDT) Received: from [192.168.0.45] (ip-94-112-225-44.bb.vodafone.cz. [94.112.225.44]) by smtp.gmail.com with ESMTPSA id bc5-20020a05622a1cc500b003ef5dc13bbbsm2064016qtb.85.2023.05.11.02.04.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 May 2023 02:04:25 -0700 (PDT) Message-ID: Date: Thu, 11 May 2023 11:04:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: [PING][PATCH] gdb/testsuite: change hardcoded assembly in gdb.arch/disp-step-insn-reloc.exp To: Bruno Larsen , Bruno Larsen via Gdb-patches References: <20230426132916.1988539-1-blarsen@redhat.com> From: Bruno Larsen In-Reply-To: <20230426132916.1988539-1-blarsen@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,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 List-Id: Ping! -- Cheers, Bruno On 26/04/2023 15:29, Bruno Larsen wrote: > When testing gdb.arch.disp-step-insn-reloc.exp with clang in an x86_64 > machine, the compiled test case would segfault when returning from > the function can_relocate_call, with a suggestion of a broken stack. > The example assembly in the commment was the following: > > f: > MOV $1, %[ok] > JMP end > set_point0: > CALL f ; tracepoint here. > end: > > And the segmentation fault happening at the final "ret" instruction of > the original function. This suggests that gcc's compilation process would > realize that no ret instruction ever happened after that call and doesn't > save the return address, while clang's process wouldn't. Looking at the > generated instructions, we can indeed see a difference: > > clang's version: e8 f1 ff ff ff call 11a4 > gcc's version: e8 f4 ff ff ff call 401125 > > Notice the difference on the second byte. > > Changing the assembly to use "ret" instead of "JMP end" does not change > the behavior of the program and guarantees a compiler independent > behavior. This commit does just that. > --- > gdb/testsuite/gdb.arch/insn-reloc.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/gdb/testsuite/gdb.arch/insn-reloc.c b/gdb/testsuite/gdb.arch/insn-reloc.c > index f687c2c5631..365e6180057 100644 > --- a/gdb/testsuite/gdb.arch/insn-reloc.c > +++ b/gdb/testsuite/gdb.arch/insn-reloc.c > @@ -49,10 +49,9 @@ fail (void) > JMP set_point0 > f: > MOV $1, %[ok] > - JMP end > + RET > set_point0: > CALL f ; tracepoint here. > - end: > > */ > > @@ -65,10 +64,9 @@ can_relocate_call (void) > " jmp " SYMBOL (set_point0) "\n" > "0:\n" > " mov $1, %[ok]\n" > - " jmp 1f\n" > + " ret\n" > SYMBOL (set_point0) ":\n" > " call 0b\n" > - "1:\n" > : [ok] "=r" (ok)); > > if (ok == 1)