mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <>
Subject: Re: [musl] aarch64 sigsetjmp relocation truncation bug, maybe
Date: Thu, 7 Sep 2023 05:08:13 +0200	[thread overview]
Message-ID: <ZPk+nanF21x/14nA@voyager> (raw)
In-Reply-To: <>

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

Am Wed, Sep 06, 2023 at 08:46:32PM -0400 schrieb Peter Williams:
> If I'm understanding correctly, the complaint is that a branch in
> sigsetjmp that invokes setjmp is too far away from the definition of
> setjmp. My very handwavey idea is that maybe for some reason my program
> is causing the linker to want to locate setjmp() and sigsetjmp() really
> far away from each other. If that's right, perhaps it would be possible
> to modify the assembler code to be able to handle such a situation?

I'm guessing the same. Pretty much all architectures have shorter
conditional than unconditional branches. That is why branches to other
files (technically to other sections) should always be unconditional. I
am attaching a simple patch that should help with the situation.


[-- Attachment #2: 0001-Make-branch-to-external-symbol-unconditional.patch --]
[-- Type: text/x-diff, Size: 966 bytes --]

From dd227e22a5337d54e1cb0838410bca6672c76c43 Mon Sep 17 00:00:00 2001
From: Markus Wichmann <>
Date: Thu, 7 Sep 2023 05:01:23 +0200
Subject: [PATCH] Make branch to external symbol unconditional.

Conditional branches have a shorter branch length than unconditional
ones, and almost all ABIs require unconditional branches to external
symbols. Otherwise linkers may create broken binaries.
 src/signal/aarch64/sigsetjmp.s | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/signal/aarch64/sigsetjmp.s b/src/signal/aarch64/sigsetjmp.s
index 75910c43..9a28e395 100644
--- a/src/signal/aarch64/sigsetjmp.s
+++ b/src/signal/aarch64/sigsetjmp.s
@@ -4,7 +4,7 @@
 .type __sigsetjmp,%function
-	cbz x1,setjmp
+	cbz x1,1f

 	str x30,[x0,#176]
 	str x19,[x0,#176+8+8]
@@ -19,3 +19,5 @@ __sigsetjmp:

 .hidden __sigsetjmp_tail
 	b __sigsetjmp_tail
+1: b setjmp

  parent reply	other threads:[~2023-09-07  3:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07  0:46 Peter Williams
2023-09-07  1:01 ` [musl] " Peter Williams
2023-09-07  3:08 ` Markus Wichmann [this message]
2023-09-07 12:48   ` [musl] " Rich Felker
2023-09-07 13:28     ` Rich Felker
2023-09-07 19:49       ` Szabolcs Nagy
2023-09-07 14:42     ` Markus Wichmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZPk+nanF21x/14nA@voyager \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).