Skip to contentSkip to conversation

Foiled by the linker again

parisc-linux [email protected] 3 participants 4 messages May 29, 2000 – May 30, 2000

lore
Share & tools
lore
#0 lore raw

Through some hacks, and special thanks to taggart for producing header files, I built a tool chain which cross compiles all applications I've attempted... well almost. Anyway the good news is I have a native binutils for palinux. Unfortunately cross-compiling bash, tar, and gcc all fail in the link stage with:

/home/bame/xc/bin/../lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/../../../../hppa1.1-linux/lib/libc.a(execve.o): In function `__execve':
/users/bame/palinux/glibc/posix/../sysdeps/unix/sysv/linux/execve.c:39: undefined reference to `$global$'
collect2: ld returned 1 exit status

I checked, and the absence of $global$ is a special case in the linker. I tried adding a file which defined $global$ by hand and that didn't help either.

My tentative conclusion is that smaller apps link and larger ones don't -- possibly some interaction with the decision to start using %r8-based stubs when the app gets too big. I'm stuck.

I'll leave puffin.external.hp.com:~bame/rrtar.o around for anyone who wants to mess with the linker. It is the "ld -r" of all the object files for tar. 'hppa1.1-linux-gcc -o tar rrtar.o' should create tar, but this causes the (my) linker to fail.

The tool chain I'm using, which has some hand patches in it because I don't really know where they belong in sources, can be rsync-ed from puffin.external.hp.com:~bame/xc or grab the tarball ftp://puffin.external.hp.com/pub/parisc/binaries/tgz/elf32x86.tar.gz

In the meantime I think this is pretty cool:

    VFS: Mounted root (NFS filesystem) readonly.
    request_irq(538, c01aca7c, 0x4000000, serial, c02cf95c)
    Stand-alone shell (version 3.4)
    > ar tv /usr/lib/libcrypt.a
    rw-r--r-- 16602/100  12176 May 28 00:01 2000 crypt-entry.o
    rw-r--r-- 16602/100  29312 May 28 00:01 2000 md5-crypt.o
    rw-r--r-- 16602/100  31364 May 28 00:01 2000 md5.o
    > objdump -d /usr/lib/crti.o
										
    /usr/lib/crti.o:     file format elf32-hppa
										
    Disassembly of section .text:
    Disassembly of section .init:
										
    00000000 <_init>:
       0:   6b c2 3f d9     stw rp,-14(sr0,sp)
       4:   37 de 00 80     ldo 40(sp),sp
       8:   6b d3 3f c1     stw r19,-20(sr0,sp)
       c:   6b c4 3f 81     stw r4,-40(sr0,sp)
      10:   e8 40 00 00     b,l 18 <gcc2_compiled.+0x18>,rp
      14:   08 13 02 44     copy r19,r4
    Disassembly of section .fini:
										
    00000000 <_fini>:
       0:   6b c2 3f d9     stw rp,-14(sr0,sp)
       4:   37 de 00 80     ldo 40(sp),sp
       8:   6b d3 3f c1     stw r19,-20(sr0,sp)
       c:   6b c4 3f 81     stw r4,-40(sr0,sp)
      10:   08 13 02 44     copy r19,r4


	-Paul Bame
#1 lore raw
Quoted 3 lines · On Mon, 29 May 2000 [email protected] wrote:

/home/bame/xc/bin/../lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/../../../../hppa1.1-linux/lib/libc.a(execve.o): In function `__execve':
/users/bame/palinux/glibc/posix/../sysdeps/unix/sysv/linux/execve.c:39: undefined reference to `$global$'
collect2: ld returned 1 exit status

This is a bogus error message. The real error is that a call to __pthread_kill_other_threads_np is too far to be reached by a branch so needs to go through a stub, but the relevant stub _____long_branch_stub___pthread_kill_other_threads_np isn't found for some reason.

Chasing it up...

Signature · 1 line
Linuxcare.  Support for the Revolution.
#2 lore raw
Quoted 6 lines · Alan Modra
Quoted 3 lines · On Mon, 29 May 2000 [email protected] wrote:

/home/bame/xc/bin/../lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/../../../../hppa1.1-linux/lib/libc.a(execve.o): In function `__execve':
/users/bame/palinux/glibc/posix/../sysdeps/unix/sysv/linux/execve.c:39: undefined reference to `$global$'
collect2: ld returned 1 exit status

Quoted 7 lines

This is a bogus error message. The real error is that a call to __pthread_kill_other_threads_np is too far to be reached by a branch so needs to go through a stub, but the relevant stub _____long_branch_stub___pthread_kill_other_threads_np isn't found for some reason.

Chasing it up...

It turned out that elf32_hppa_bfd_final_link_relocate wasn't handling undefined weak symbols correctly. I've fixed this, the bogus error message, and a handfull of other minor things, and commited the fixes to pehp CVS.

Now I get

$ ld/ld-new -o tar /usr/parisc/lib/crt1.o /usr/parisc/lib/crti.o
/usr/parisc/lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/crtbegin.o
-L/usr/parisc/lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112 -L/usr/parisc/lib/
rrtar.o -lgcc -lc -lgcc
/usr/parisc/lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/crtend.o
/usr/parisc/lib/crtn.o
/usr/parisc/lib//libc.a(nsswitch.o)(.data+0x64): undefined reference to
`_nss_files_getaliasent_r'

which looks like a problem with my glibc build.

Regards, Alan Modra

Signature · 1 line
Linuxcare.  Support for the Revolution.
#3 lore raw

= On Tue, 30 May 2000, Alan Modra wrote:
=
= > On Mon, 29 May 2000 [email protected] wrote:
= >
= > > /home/bame/xc/bin/../lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/../../../. ./hppa1.1-linux/lib/libc.a(execve.o): In function `__execve':
= > > /users/bame/palinux/glibc/posix/../sysdeps/unix/sysv/linux/execve.c:39: u ndefined reference to `$global$'
= > > collect2: ld returned 1 exit status
= >
= > This is a bogus error message. The real error is that a call to = > __pthread_kill_other_threads_np is too far to be reached by a branch so = > needs to go through a stub, but the relevant stub
= > _____long_branch_stub___pthread_kill_other_threads_np isn't found for some = > reason.
= >
= > Chasing it up...
=
= It turned out that elf32_hppa_bfd_final_link_relocate wasn't handling = undefined weak symbols correctly. I've fixed this, the bogus error = message, and a handfull of other minor things, and commited the fixes to = pehp CVS.
=
= Now I get
= $ ld/ld-new -o tar /usr/parisc/lib/crt1.o /usr/parisc/lib/crti.o = /usr/parisc/lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/crtbegin.o = -L/usr/parisc/lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112 -L/usr/parisc/lib/ = rrtar.o -lgcc -lc -lgcc
= /usr/parisc/lib/gcc-lib/hppa1.1-linux/2.9-hppa-991112/crtend.o
= /usr/parisc/lib/crtn.o
= /usr/parisc/lib//libc.a(nsswitch.o)(.data+0x64): undefined reference to = `_nss_files_getaliasent_r'
=
= which looks like a problem with my glibc build.

Yup. Grab the file glibc/PARISC-EXTRA-FILES which contains a list of the missing .o files which you can add by hand with 'hppa1.1-linux-ar'.

	-P