From aecdbb3042704075b303b626da424aa0665e4f97 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 17 Apr 2015 22:19:01 -0400 Subject: [PATCH] fix PLT call offset in sh dlsym asm the braf instruction's destination register is an offset from the address of the braf instruction plus 4 (or equivalently, the address of the next instruction after the delay slot). the code for dlsym was incorrectly computing the offset to pass using the address of the delay slot itself. in other places, a label was placed after the delay slot, but I find this confusing. putting the label on the branch instruction itself, and manually adding 4, makes it more clear which branch the offset in the constant pool goes with. --- src/ldso/sh/dlsym.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ldso/sh/dlsym.s b/src/ldso/sh/dlsym.s index bc8fd679..11a6fff5 100644 --- a/src/ldso/sh/dlsym.s +++ b/src/ldso/sh/dlsym.s @@ -4,8 +4,8 @@ .type dlsym, @function dlsym: mov.l L1, r0 - braf r0 -1: mov.l @r15, r6 +1: braf r0 + mov.l @r15, r6 .align 2 -L1: .long __dlsym@PLT-(1b-.) +L1: .long __dlsym@PLT-(1b+4-.) -- 2.25.1