[Bug c++/49777] for c++ code, without -g option, cannot generate PIC *.so library.

2011-10-14 Thread hekun_hekun at 163 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49777

--- Comment #5 from kun.he hekun_hekun at 163 dot com 2011-10-15 01:47:14 UTC 
---
Thanks Paolo  Nick,

When I replace gcc-4.5.1 by Gcc-linaro-4.5-2011.06, the issue disappeared. And
I found patch
http://bazaar.launchpad.net/~linaro-toolchain-dev/gcc-linaro/4.5/revision/99352


[Bug c++/49777] New: for c++ code, without -g option, cannot generate PIC *.so library.

2011-07-18 Thread hekun_hekun at 163 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49777

   Summary: for c++ code, without -g option, cannot generate PIC
*.so library.
   Product: gcc
   Version: 4.5.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: hekun_he...@163.com


test.cc:
int f_b ()
{
return 1;
}
int f_a () throw ()
{
return f_b();
}

without -g:
  $ armv7a-linux-gnueabi-gcc -S -fPIC -DPIC test.cc -o test.s
  $ armv7a-linux-gnueabi-gcc -c test.s -o test.o
  $ armv7a-linux-gnueabi-gcc -shared test.o -o test.so
  $ armv7a-linux-gnueabi-readelf -d test.so | grep TEXTREL
0x0016 (TEXTREL)0x0

with -g:
  $ armv7a-linux-gnueabi-gcc -S -fPIC -DPIC test.cc -o test-g.s -g
  $ armv7a-linux-gnueabi-gcc -c test-g.s -o test.o
  $ armv7a-linux-gnueabi-gcc -shared test.o -o test.so
  $ armv7a-linux-gnueabi-readelf -d test.so | grep TEXTREL
  nothing output.

the content of test.s:
  1 .arch armv7-a
  2 .eabi_attribute 27, 3
  3 .fpu vfpv3-d16
  4 .eabi_attribute 20, 1
  5 .eabi_attribute 21, 1
  6 .eabi_attribute 23, 3
  7 .eabi_attribute 24, 1
  8 .eabi_attribute 25, 1
  9 .eabi_attribute 26, 2
 10 .eabi_attribute 30, 6
 11 .eabi_attribute 18, 4
 12 .file   test.cc
 13 .text
 14 .align  2
 15 .global _Z3f_bv
 16 .type   _Z3f_bv, %function
 17 _Z3f_bv:
 18 .fnstart
 19 .LFB0:
 20 .cfi_startproc
 21 @ args = 0, pretend = 0, frame = 0
 22 @ frame_needed = 1, uses_anonymous_args = 0
 23 @ link register save eliminated.
 24 str fp, [sp, #-4]!
 25 .save {fp}
 26 .cfi_def_cfa_offset 4
 27 .setfp fp, sp, #0
 28 add fp, sp, #0
 29 .cfi_offset 11, -4
 30 .cfi_def_cfa_register 11
 31 mov r3, #1
 32 mov r0, r3
 33 add sp, fp, #0
 34 ldmfd   sp!, {fp}
 35 bx  lr
 36 .cfi_endproc
 37 .LFE0:
 38 .fnend
 39 .size   _Z3f_bv, .-_Z3f_bv
 40 .align  2
 41 .global _Z3f_av
 42 .type   _Z3f_av, %function
 43 _Z3f_av:
 44 .fnstart
 45 .LFB1:
 46 .cfi_startproc
 47 .cfi_personality 0x0,__gxx_personality_v0
 48 .cfi_lsda 0x0,.LLSDA1
 49 @ args = 0, pretend = 0, frame = 0
 50 @ frame_needed = 1, uses_anonymous_args = 0
 51 stmfd   sp!, {fp, lr}
 52 .save {fp, lr}
 53 .cfi_def_cfa_offset 8
 54 .setfp fp, sp, #4
 55 add fp, sp, #4
 56 .cfi_offset 14, -4
 57 .cfi_offset 11, -8
 58 .cfi_def_cfa 11, 4
 59 .LEHB0:
 60 bl  _Z3f_bv(PLT)
 61 .LEHE0:
 62 mov r3, r0
 63 mov r0, r3
 64 ldmfd   sp!, {fp, pc}
 65 .L5:
 66 mov r3, r0
 67 mov r2, r1
 68 cmn r2, #1
 69 beq .L4
 70 .LEHB1:
 71 bl  __cxa_end_cleanup(PLT)
 72 .L4:
 73 mov r0, r3
 74 bl  __cxa_call_unexpected(PLT)
 75 .LEHE1:
 76 .cfi_endproc
 77 .LFE1:
 78 .global __gxx_personality_v0
 79 .personality__gxx_personality_v0
 80 .handlerdata
 81 .align  2
 82 .LLSDA1:
 83 .byte   0xff
 84 .byte   0x0
 85 .uleb128 .LLSDATT1-.LLSDATTD1
 86 .LLSDATTD1:
 87 .byte   0x1
 88 .uleb128 .LLSDACSE1-.LLSDACSB1
 89 .LLSDACSB1:
 90 .uleb128 .LEHB0-.LFB1
 91 .uleb128 .LEHE0-.LEHB0
 92 .uleb128 .L5-.LFB1
 93 .uleb128 0x1
 94 .uleb128 .LEHB1-.LFB1
 95 .uleb128 .LEHE1-.LEHB1
 96 .uleb128 0x0
 97 .uleb128 0x0
 98 .LLSDACSE1:
 99 .byte   0x7f
100 .byte   0x0
101 .align  2
102 .LLSDATT1:
103 .word   0
104 .fnend
105 .size   _Z3f_av, .-_Z3f_av
106 .ident  GCC: (GNU) 4.5.1
107 .section.note.GNU-stack,,%progbits


the content of test-g.s:
  1 .arch armv7-a
  2 .eabi_attribute 27, 3
  3 .fpu vfpv3-d16
  4 .eabi_attribute 20, 1
  5 .eabi_attribute 21, 1
  6 .eabi_attribute 23, 3
  7 .eabi_attribute 24, 1
  8 .eabi_attribute 25, 1
  9 .eabi_attribute 26, 2
 10 .eabi_attribute 30, 6
 11