From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by sourceware.org (Postfix) with ESMTPS id 94702386F447 for ; Mon, 15 Jun 2020 23:13:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 94702386F447 Received: by mail-ej1-x642.google.com with SMTP id dr13so19315340ejc.3 for ; Mon, 15 Jun 2020 16:13:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-description:content-disposition:in-reply-to; bh=uyWpiumRQkLzrkA1LFmN1PtIFKdJI1w7LTZgzZlX1x0=; b=ilfQQHyv+4SDd1OuSwzzwmHY3ocEARF0EbeXkC4ifW37jUhkrIgLLghaRearT60uVQ nr1rbICpMfFVcgIjMav5fbbFA6iumgI/d9VS+zuM/QMa8sC79Dlym85HzSmoJ5BLfoVf 5i6yV8zdNVS3hezXhLsPAdv9s2GmFs4ERNjbc/dTvQJkXs5WGs4um+tuPCSyIyfmcPI5 vX0Pf0ZZXrXHQvwGtKMGkKsx2bqYCqwBfGaJRggv55vMhrbCOl8L89hdVcPA586tgoPm j1gnDvnBSsr+LS51d2eTPe0lDyTJ0vS7OkOxTHNFoTIVzzYFLgsECKaQqOqOKIcUEGE2 10BQ== X-Gm-Message-State: AOAM532COaiKXqy8v59Gw6EtUHGfrjabYXJgs8rSSUwT+g9YRqcmF2XW kKKWtsjYt0gTKHg1FhrMjME= X-Google-Smtp-Source: ABdhPJyow0Yo1YhmWdEDnMaB2IhZxrwChCE9jG70MuKXCHla3wCMZytkMx30oRgDxrqISN5/rEpbRw== X-Received: by 2002:a17:906:e298:: with SMTP id gg24mr154897ejb.120.1592262828626; Mon, 15 Jun 2020 16:13:48 -0700 (PDT) Received: from gmail.com ([2a03:1b20:3:f011::6d]) by smtp.gmail.com with ESMTPSA id z3sm9795720ejl.38.2020.06.15.16.13.47 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Jun 2020 16:13:47 -0700 (PDT) Date: Tue, 16 Jun 2020 01:13:49 +0200 From: Shahab Vahedi To: Simon Marchi Cc: gdb-patches@sourceware.org, Shahab Vahedi , Anton Kolesov , Tom Tromey , Francois Bedard Subject: Re: [PATCH v2 3/4] arc: Add GNU/Linux support for ARC Message-ID: <20200615231349.GB1816@gmail.com> References: <20200326125206.13120-1-shahab.vahedi@gmail.com> <20200428160437.1585-1-shahab.vahedi@gmail.com> <20200428160437.1585-4-shahab.vahedi@gmail.com> <6f07f665-a003-5dad-bace-bfdcbd77a906@simark.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Description: simark_response Content-Disposition: inline In-Reply-To: <6f07f665-a003-5dad-bace-bfdcbd77a906@simark.ca> X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2020 23:13:50 -0000 On Thu, May 14, 2020 at 11:09:08AM -0400, Simon Marchi wrote: > On 2020-04-28 12:04 p.m., Shahab Vahedi via Gdb-patches wrote: > > +/* Initialization specific to Linux environment. */ > > + > > +static void > > +arc_linux_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) > > +{ > > + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > > + > > + if (arc_debug) > > + debug_printf ("arc-linux: GNU/Linux OS/ABI initialization.\n"); > > + > > + /* If we are using Linux, we have in uClibc > > + (libc/sysdeps/linux/arc/bits/setjmp.h): > > + > > + typedef int __jmp_buf[13+1+1+1]; //r13-r25, fp, sp, blink > > + > > + Where "blink" is a stored PC of a caller function. > > + */ > > + tdep->jb_pc = 15; > > I don't really understand this, could you dumb it down a bit for me? In advance, I appologize if my explanation is not right on the spot or is too verbose. I am not 100% sure what is not clear, so I try to explain as much as I can. If you mean why "tdep->jb_pc" is 15 and what the comments mean, then: fp -> Frame Pointer register sp -> Stack Pointer register blink -> Branch and LINK register (acts like a "return" register) blink register is set (implicitly) when "bl @name_of_fuction" instruction is used. It will point to the instruction that comes after "bl" (branch and link). e.g.: 0x100: add r0, r1, r2 0x104: bl @galaxy_far_away # pc=@galaxy_far_away; blink=0x108 0x108: add r3, r4, r5 a simple "j(ump) blink" will return from the function. ----- The layout of "__jump_buf" looks like: 0..12: stored registers r13, r14, ..., r25 13: stored fp 14: stored sp 15: stored blink This is how the "calling" convention in ARC saves the registers before switching the frame to another function. I hope it is clear now. Shahab