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 CABA53858C41 for ; Fri, 19 May 2023 21:52:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CABA53858C41 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=1684533154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gL5ev7YnbvSqJXTe6+1gvWhoSX0ACloQ91qmhu6PGu4=; b=LgSNNgWn3pd5osCbohETFnJnkKAVlbyBYJlzq3nIqexpa7bNMGmOy/TF01fWI4SU0+Z83m oSVZ+7c0WIvak7Al7Y2uo3ZhLz+q2xT29DcxnvRAq4UvEsRRa6O5rHSQihpaiAceqHc1YQ UAmlKSLydfoBntrLVCI9V2jORf42xJE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-SsLVFSlEMHa0HQn0XsLAcg-1; Fri, 19 May 2023 17:52:33 -0400 X-MC-Unique: SsLVFSlEMHa0HQn0XsLAcg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f5df65f9f4so8094675e9.2 for ; Fri, 19 May 2023 14:52:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684533152; x=1687125152; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gL5ev7YnbvSqJXTe6+1gvWhoSX0ACloQ91qmhu6PGu4=; b=C49Ho2012BocccfSaRGfosj2qivFvI64TqTGvGcCnnx22o04Fw4tt2vgWdHg1BVdFI TK0jnDRagNgnkchxX5oN9G1kHZ59Sxog0+AEadFeQDFcX2DsMYRUN7FyPsANHdokp8id J/gh2J3jnGfVNhgRvarXMtE3mje5mQvyV5Iw1sZ+4yM5Sn6rrgtanqt/28GHUpQC4Zs+ MmKIO3hmpt4fOKu/4Cm5lEPvClVYiqd/Byx2Uzt+J1mrhYPTrSalsfOz3lULrOnBRo+Q ctBpF9eXpyGXqxp7pVumY0JWFdWQ1YXusw2w4SH0ehLFBq9eG8fIceLPqxe03zue93xe nkJg== X-Gm-Message-State: AC+VfDzBBBGQu+rZcSapfTM95ULGhGDexYbLbR9peCOkqOefe3pZWle+ nTlyZTfxMimZsjCsX9o63usI0W/+zuFpe8J0VyTxi3NZYbNnMDvJ+QeeEbGmCsp4Dh/FNpSHS50 30QLiXkwlXjsp2nXmFnz5fkfBDW53eRCHdOLdO/2DwRpgHbJaimLjKy2LIawYYpL2P2Y6gcUjIa 0gkNQ86A== X-Received: by 2002:a05:600c:22d9:b0:3f4:2174:b28f with SMTP id 25-20020a05600c22d900b003f42174b28fmr2388543wmg.2.1684533151815; Fri, 19 May 2023 14:52:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qIFjeAeOHn+BVixQZAvd/jSGfqiUYnaf04uU0htgKqqD+BKyF8p3fm/I+IDIzm8Cal8pUzw== X-Received: by 2002:a05:600c:22d9:b0:3f4:2174:b28f with SMTP id 25-20020a05600c22d900b003f42174b28fmr2388531wmg.2.1684533151445; Fri, 19 May 2023 14:52:31 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id f5-20020a5d4dc5000000b0030644bdefd8sm107630wru.52.2023.05.19.14.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 14:52:30 -0700 (PDT) From: Andrew Burgess To: Bruno Larsen via Gdb-patches , gdb-patches@sourceware.org Cc: Bruno Larsen Subject: Re: [PATCH] gdb/testsuite: change hardcoded assembly in gdb.arch/disp-step-insn-reloc.exp In-Reply-To: <20230426132916.1988539-1-blarsen@redhat.com> References: <20230426132916.1988539-1-blarsen@redhat.com> Date: Fri, 19 May 2023 22:52:29 +0100 Message-ID: <87r0rc7zvm.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: Bruno Larsen via Gdb-patches writes: > 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: Honestly, I found the following paragraph really hard to grok. I had to go look at the failure myself to see what was going on. Don't spend too long on it, but it might be possible to make it a little clearer... > > And the segmentation fault happening at the final "ret" instruction of > the original function. s/the original function/the function cal_relocate_call/. > This suggests that gcc's compilation process would > realize that no ret instruction ever happened after that call and doesn't s/after that call and/after the inner call and so/ > save the return address, while clang's process wouldn't. Looking at the Maybe: save the return address, while clang doesn't spot the missing 'ret' and so does push the return address onto the stack. 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. Yes, but please, don't expect me to go read the x86-64 ISA manual -- what does this difference mean? > > 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. The change itself is great, and I agree that this shouldn't change the test. Feel free to tweak the commit message and push this. Approved-By: Andrew Burgess Thanks, Andrew > --- > 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) > -- > 2.39.2