git: 60252f383052 - main - devel/objfw: fix build on powerpc64*

Piotr Kubaj <[email protected]> Mon, 03 Aug 2026 15:21:49 +0000
Newsgroups gmane.os.freebsd.devel.cvs.ports
Message-ID <[email protected]>
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=60252f38305257cf400dd94d6138b1ab4f955ed0

commit 60252f38305257cf400dd94d6138b1ab4f955ed0
Author:     Piotr Kubaj <[email protected]>
AuthorDate: 2026-08-02 21:12:27 +0000
Commit:     Piotr Kubaj <[email protected]>
CommitDate: 2026-08-03 15:21:22 +0000

    devel/objfw: fix build on powerpc64*
    
    Taking the address of _objc_taggedPointerClasses with
    
        addis   %r6, %r2, _objc_taggedPointerClasses@toc@ha
        addi    %r6, %r6, _objc_taggedPointerClasses@toc@l
    
    emits an R_PPC64_TOC16_LO relocation against the symbol itself, which
    requires the symbol to be non-preemptible and reachable relative to the
    TOC pointer. Neither holds for a global symbol in a shared library, so
    linking libobjfwrt.so fails on FreeBSD/powerpc64le:
    
      ld: error: relocation R_PPC64_TOC16_LO cannot be used against symbol
      '_objc_taggedPointerClasses'; recompile with -fPIC
      >>> defined in tagged-pointer.lib.o
      >>> referenced by lookup-asm.lib.o:(objc_msg_lookup) in archive
          lookup-asm/lookup-asm.lib.a
    
    The "recompile with -fPIC" hint is misleading: every object is already
    compiled with -fPIC, and the offending sequence is in hand-written
    assembly, which -fPIC does not affect.
    
    Load the address from the GOT instead, which is the position independent
    way to take the address of a preemptible global:
    
        addis   %r6, %r2, _objc_taggedPointerClasses@got@ha
        ld  %r6, _objc_taggedPointerClasses@got@l(%r6)
    
    The neighbouring _objc_taggedPointerSecret access is deliberately left
    unchanged. It uses @toc with a ld, which loads the variable's *value* --
    what the following xor needs. The classes access instead needs the
    array's *address* for the subsequent ldx, and only the address-forming
    sequence is affected.
---
 .../patch-src_runtime_lookup-asm_lookup-asm-powerpc64-elf.S | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/devel/objfw/files/patch-src_runtime_lookup-asm_lookup-asm-powerpc64-elf.S b/devel/objfw/files/patch-src_runtime_lookup-asm_lookup-asm-powerpc64-elf.S
new file mode 100644
index 000000000000..cc7859a92dff
--- /dev/null
+++ b/devel/objfw/files/patch-src_runtime_lookup-asm_lookup-asm-powerpc64-elf.S
@@ -0,0 +1,13 @@
+--- src/runtime/lookup-asm/lookup-asm-powerpc64-elf.S.orig	2026-08-02 17:00:57 UTC
++++ src/runtime/lookup-asm/lookup-asm-powerpc64-elf.S
+@@ -93,8 +93,8 @@
+ 	xor	%r5, %r3, %r5
+ 	rlwinm	%r5, %r5, 2, 0x38
+ 
+-	addis	%r6, %r2, _objc_taggedPointerClasses@toc@ha
+-	addi	%r6, %r6, _objc_taggedPointerClasses@toc@l
++	addis	%r6, %r2, _objc_taggedPointerClasses@got@ha
++	ld	%r6, _objc_taggedPointerClasses@got@l(%r6)
+ 	ldx	%r5, %r6, %r5
+ 	ld	%r5, 64(%r5)
+