• Linker error "relocati,on truncated to fit"

    From Ole Streicher@21:1/5 to All on Tue Jun 13 11:00:02 2017
    Hi,

    I am slowly re-starting the packaging of IRAF (still not officially
    announced yet). When porting to s390x, I however run into a strange
    error: IRAF needs a small piece of assembler code (kind-of longjump for Fortan), which John Long gratefully ported to s390x two years ago:

    zsvjmp_:
    stg %r3,0(0,%r2)
    xc 0(8,%r3),0(%r3)
    xgr %r3,%r3
    aghi %r2,8
    j __sigsetjmp@PLT

    (Copyright John Long, MIT license).

    However, when I try to link that (statically), I get the following error:

    zsvjmp.s:16:(.text+0x16): relocation truncated to fit: R_390_PLT16DBL
    against symbol `__sigsetjmp@@GLIBC_2.2' defined in .text section in /lib/s390x-linux-gnu/libc.so.6
    collect2: error: ld returned 1 exit status

    As an uneducated guess, I removed the "@PLT", but then I get a complaint
    about that this is missing.

    Compiler (assembler) is gcc-6.3, with the current (sid) binutils. About
    three years ago (when John wrote that code), this problem didn't happen.

    Could anyone help me here what is wrong with that assembler?

    Best regards

    Ole

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bastian Blank@21:1/5 to Ole Streicher on Tue Jun 13 20:40:01 2017
    On Tue, Jun 13, 2017 at 09:38:44AM +0200, Ole Streicher wrote:
    I am slowly re-starting the packaging of IRAF (still not officially
    announced yet). When porting to s390x, I however run into a strange
    error: IRAF needs a small piece of assembler code (kind-of longjump for Fortan), which John Long gratefully ported to s390x two years ago:

    Is IRAF the stuff from http://iraf.noao.edu/ and last released five
    years ago?

    zsvjmp_:
    stg %r3,0(0,%r2)
    xc 0(8,%r3),0(%r3)
    xgr %r3,%r3
    aghi %r2,8
    j __sigsetjmp@PLT

    Looks like it is, but why do you want this jump via the PLT, while all
    other variants do not?

    | ./unix/as.linux/zsvjmp.s: jmp __sigsetjmp # let sigsetjmp do the rest
    | ./unix/as.linux64/zsvjmp_c:asm(" jmp __sigsetjmp # let sigsetjmp do the rest");

    Could anyone help me here what is wrong with that assembler?

    To make this work, you need to build with -fPIC.

    Bastian

    --
    Earth -- mother of the most beautiful women in the universe.
    -- Apollo, "Who Mourns for Adonais?" stardate 3468.1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ole Streicher@21:1/5 to Bastian Blank on Wed Jun 14 12:10:01 2017
    Hi,

    (Could I ask to get a CC of answers via mail? I am not subscribed to
    this list.)

    Thank you for your response!

    Bastian Blank wrote:
    On Tue, Jun 13, 2017 at 09:38:44AM +0200, Ole Streicher wrote:
    I am slowly re-starting the packaging of IRAF (still not officially
    announced yet). When porting to s390x, I however run into a strange
    error: IRAF needs a small piece of assembler code (kind-of longjump for
    Fortan), which John Long gratefully ported to s390x two years ago:

    Is IRAF the stuff from http://iraf.noao.edu/ and last released five
    years ago?

    Yes. I could convince upstream to put it into a git repository, <https://github.com/iraf/iraf-v216> and now I am creating pull requests
    to get it more Debian friendly: portability, build from the tarball,
    removal of oddly licensed code. To port zsvjmp, I created a small
    project three years ago: <https://github.com/olebole/zsvjmp>.

    zsvjmp_: [...]
    j __sigsetjmp@PLT

    Looks like it is, but why do you want this jump via the PLT, while all
    other variants do not?

    | ./unix/as.linux/zsvjmp.s: jmp __sigsetjmp # let sigsetjmp do the rest
    | ./unix/as.linux64/zsvjmp_c:asm(" jmp __sigsetjmp # let sigsetjmp do the rest");

    That is way outdated. At least for x86_64, I need the @PLT now to avoid
    linker errors. From my (very limited) understanding, @PLT would be
    correct, since sigsetjmp resides in a shared lib (libc).

    Could anyone help me here what is wrong with that assembler?

    To make this work, you need to build with -fPIC.

    This didn't help, I still get the same error message. Since zsvjmp.o
    will be statically linked (yet), I also don't see why -fPIC would be needed.

    From browsing the S390 mnemonic list, I tried to replace the "j" opcode
    with a "jg", and then the compilation succeeds. However, this is a very
    wild guess, since the menmonic list just in both cases said it were a
    "jump". Can you (or someone) confirm that "jg" is correct here? The code
    still does not work, and I want to be sure that "jg" is not causing this.

    Best regards

    Ole

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)