This problem depends on generated pic code for sh.

For reproducing, needs two files a shared library(musician.so) and a executable
file(main). I will attach these files.

musician.so is shared library compiled with -fPIC option.
musician.so is linked dynamically if main is excuted as follows.

g++ -g -o musician.so musician.cc -shared -fPIC
g++ -g -o main main.cc musician.so
env LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH main

actual result: main issues a following error.
Segmentation fault

expected result: main prints a following message.
playing=1

The following code generated by g++ is wrong for the pic code because r12 is
not set for this shared library.

        .weak   _ZThn4_N6typist5printEv
        .type   _ZThn4_N6typist5printEv, @function
_ZThn4_N6typist5printEv:
.LFB46:
        mov.l   .L153,r3
        add     r12,r3
        jmp     @r3
        add     #-4,r4
.L154:
        .align 2
.L153:
        .long   [EMAIL PROTECTED]


-- 
           Summary: [SH] generated pic code is not right
           Product: gcc
           Version: 3.4.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: saito at densan dot co dot jp
 GCC build triplet: sh4-linux
  GCC host triplet: sh4-linux
GCC target triplet: sh4-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27621

Reply via email to