From patchwork Sat May 19 00:49:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 27330 Received: (qmail 12173 invoked by alias); 19 May 2018 00:51:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 12161 invoked by uid 89); 19 May 2018 00:51:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:744a, startS, UD:start.S, HX-Received:sk:e10-v6m X-HELO: mail-pf0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:cc:from:to; bh=W8tLU9KnNBg7HLboKDfAoiuY00AcDgW4pLj6YkcW/cY=; b=knRdzPS1BSjVWVkpjeTQL2/dh1BHJTdRzWJzK6Qn5FzrSm/wFuF7nwA3Ciq+r0e9Qy VYFeP0GGrU+CorgXdRx267t0Vwg+adFzlgO8ObCy/f4km5SomGSJqgOYQ+1ObMDD5N9s MAV/IbO3VOxERpMJ+WTUUPg+RWqLrq160hGeIXmIKAtLHAyreBXEq/qyPKhrTu+mbN0b 1isGslupywHs28Z/qndu5cnytEoj10ZpD76iRjqaiRukNBU9Q0ynL7gpaSB0mWb+37d4 TxI7NTZuVwHal8/Lgp//6HGZyo5RtDzNodUITOxxoHe64xVyKfREdItxUl/TRbmzYOzR 3Eyg== X-Gm-Message-State: ALKqPweJ4nAE77BFfFrgbt+uQapZLPTO5Ar/2lKMCoyRkXFJKS3cWoyN KlKIOhJjEfbCTl2jH0e7L2SrvaLF0m0= X-Google-Smtp-Source: AB8JxZovNu+r+R6GnmHAUAE3Ygl2DNV7AQyf5VSxH0kBuRTeexGD2w+HpUGeVhvSXfykQnxuUDwjfw== X-Received: by 2002:a63:744a:: with SMTP id e10-v6mr9133242pgn.275.1526691086353; Fri, 18 May 2018 17:51:26 -0700 (PDT) Subject: [PATCH] RISC-V: Mark RA as undefined at the start of execution Date: Fri, 18 May 2018 17:49:53 -0700 Message-Id: <20180519004953.19860-1-palmer@dabbelt.com> Cc: Palmer Dabbelt From: Palmer Dabbelt To: libc-alpha@sourceware.org glibc bug 23125 (originally GCC bug 85492) demonstrates an infinate loop in exception handling that results from RA as being undefined at the start of program execution. This patch uses a CFI directive to mark RA as undefined, which allows the backtrace to terminate. There is no explicit glibc test case for this, but I thought I'd send the patch out anyway as it is fixing a bug. I'd like to have a test before committing this. I have not even compiled this. I will do that before committing... :) Thanks to Aurelian Jarno for finding the bug, and Jim Wilson for fixing it. ChangeLog 2018-05-18 Palmer Dabbelt PR 23125 * sysdeps/riscv/start.S (ENTRY_POINT): Mark ra as undefined so backtraces can terminate if they reach this point. --- sysdeps/riscv/start.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S index 4635ddb5eb8c..93a80bc4a760 100644 --- a/sysdeps/riscv/start.S +++ b/sysdeps/riscv/start.S @@ -43,6 +43,8 @@ __libc_start_main wants this in a5. */ ENTRY (ENTRY_POINT) + /* Mark ra as undefined in order to stop unwinding here! */ + cfi_undefined (ra) call .Lload_gp mv a5, a0 /* rtld_fini. */ /* main may be in a shared library. */