[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help needed with strange linking bug



I apologize if this is a duplicate message. I posted to
rtems-snapshots at oarcorp.com last Wednesday, and never saw my post. In
fact, I haven't received anything from that list since early last
Thursday. I may have "fallen off" the list. If anyone responds, please
cc your message to me as well as responding to the list. Thank you.

-------------------------------------------

Here is a strange problem with m68k-rtemself:

cdtest crashes when throwing the C++ exception. I have traced the
problem to a linking problem:

[gauthier at c55 cdtest]$ m68k-rtemself-nm o-mvme167-debug/cdtest.exe |
grep pthread_once
         U pthread_once

There is still one (and only one) undefined symbol in the executable
image, but the link was successful! The link command issued by 'make
RTEMS_BSP=mvme167 debug' was:

collect2 version 2.95 19990728 (release) (68k, Motorola syntax)
/usr/local/bin/m68k-rtemself-ld -v -dc -dp -N -e start -o
o-mvme167-debug/cdtest.exe
/home/gauthier/build-rtems/./mvme167/lib/start_g.o
/usr/local/lib/gcc-lib/m68k-rtemself/2.95/crti.o
/usr/local/lib/gcc-lib/m68k-rtemself/2.95/crtbegin.o
-L/home/gauthier/build-rtems/./mvme167/lib
-L/usr/local/lib/gcc-lib/m68k-rtemself/2.95
-L/usr/local/m68k-rtemself/lib o-mvme167-debug/init.o
o-mvme167-debug/main.o
/home/gauthier/build-rtems/./mvme167/lib/libtest_g.a -lgcc --start-group
-lrtemsall_g -lc -lgcc --end-group -T
/home/gauthier/build-rtems/./mvme167/lib/elflinkcmds -lgcc -lrtemsall_g
/usr/local/lib/gcc-lib/m68k-rtemself/2.95/crtend.o
/usr/local/lib/gcc-lib/m68k-rtemself/2.95/crtn.o
GNU ld version 2.9.1 (with BFD 2.9.1)

I checked librtemsall_g.a. A section of the output of
m68k-rtemself-objdump -j .text -d librtemsall_g.a appears below:


pthreadonce.o:     file format elf32-m68k

Disassembly of section .text:

00000000 <pthread_once>:
   0:   4856            pea %fp@
   2:   2c4f            moveal %sp,%fp
   4:   2f0a            movel %a2,%sp at -
   6:   4aae 0008       tstl %fp@(8)
   a:   670a            beqs 16 <pthread_once+0x16>
   c:   4aae 000c       tstl %fp@(12)
  10:   6608            bnes 1a <pthread_once+0x1a>
  12:   6000 0002       braw 16 <pthread_once+0x16>
  16:   7016            moveq #22,%d0
  18:   6034            bras 4e <pthread_once+0x4e>
  1a:   4eb9 0000 0000  jsr 0 <pthread_once>
  20:   206e 0008       moveal %fp@(8),%a0
  24:   4aa8 0004       tstl %a0@(4)
  28:   6618            bnes 42 <pthread_once+0x42>
  2a:   206e 0008       moveal %fp@(8),%a0
  2e:   7001            moveq #1,%d0
  30:   2080            movel %d0,%a0@
  32:   206e 0008       moveal %fp@(8),%a0
  36:   7001            moveq #1,%d0
  38:   2140 0004       movel %d0,%a0@(4)
  3c:   246e 000c       moveal %fp@(12),%a2
  40:   4e92            jsr %a2@
  42:   4eb9 0000 0000  jsr 0 <pthread_once>
  48:   4280            clrl %d0
  4a:   6000 0002       braw 4e <pthread_once+0x4e>
  4e:   246e fffc       moveal %fp@(-4),%a2
  52:   4e5e            unlk %fp
  54:   4e75            rts

00000056 <_Thread_Disable_dispatch>:
  56:   4856            pea %fp@
  58:   2c4f            moveal %sp,%fp
  5a:   2039 0000 0000  movel 0 <pthread_once>,%d0
  60:   2200            movel %d0,%d1
  62:   5281            addql #1,%d1
  64:   23c1 0000 0000  movel %d1,0 <pthread_once>
  6a:   4e5e            unlk %fp
  6c:   4e75            rts

0000006e <_Thread_Enable_dispatch>:
  6e:   4856            pea %fp@
  70:   2c4f            moveal %sp,%fp
  72:   2039 0000 0000  movel 0 <pthread_once>,%d0
  78:   2200            movel %d0,%d1
  7a:   5381            subql #1,%d1
  7c:   23c1 0000 0000  movel %d1,0 <pthread_once>
  82:   2039 0000 0000  movel 0 <pthread_once>,%d0
  88:   4a80            tstl %d0
  8a:   6606            bnes 92 <_Thread_Enable_dispatch+0x24>
  8c:   4eb9 0000 0000  jsr 0 <pthread_once>
  92:   4e5e            unlk %fp
  94:   4e75            rts


The crash occurs because ld generated jsr 0 for a call to pthread_once()
in throw().

Any idea what the problem might be?

BTW, cdtest works fine if I link against pthreadonce.o to force
pthread_once into the image!



Environment:

rtems-19990709
binutils-2.9.1 with binutils-2.9.1-rtems-diff-19990804 patch
gcc-2.95 with gcc-2.95-rtems-diff-19990804 patch
newlib-1.8.1 with newlib-1.8.1-rtems-diff-19990708 patch
Pentium II with RedHat Linux 6.0 host


-- 
Charles-Antoine Gauthier
Research Officer
Software Engineering Group
Institute for Information Technology
National Research Council of Canada
Ottawa, ON, Canada
K1A 0R6