This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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: unassigned@gcc.gnu.org
        ReportedBy: hekun_hekun@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
    0x00000016 (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         .eabi_attribute 18, 4
     12         .file   "test.cc"
     13         .section        .debug_abbrev,"",%progbits
     14 .Ldebug_abbrev0:
     15         .section        .debug_info,"",%progbits
     16 .Ldebug_info0:
     17         .section        .debug_line,"",%progbits
     18 .Ldebug_line0:
     19         .text
     20 .Ltext0:
     21         .cfi_sections   .debug_frame
     22         .align  2
     23         .global _Z3f_bv
     24         .type   _Z3f_bv, %function
     25 _Z3f_bv:
     26         .fnstart
     27 .LFB0:
     28         .file 1 "test.cc"
     29         .loc 1 2 0
     30         .cfi_startproc
     31         @ args = 0, pretend = 0, frame = 0
     32         @ frame_needed = 1, uses_anonymous_args = 0
     33         @ link register save eliminated.
     34         str     fp, [sp, #-4]!
     35         .save {fp}
     36 .LCFI0:
     37         .cfi_def_cfa_offset 4
     38         .setfp fp, sp, #0
     39         add     fp, sp, #0
     40         .cfi_offset 11, -4
     41 .LCFI1:
     42         .cfi_def_cfa_register 11
     43         .loc 1 3 0
     44         mov     r3, #1
     45         .loc 1 4 0
     46         mov     r0, r3
     47         add     sp, fp, #0
     48         ldmfd   sp!, {fp}
     49         bx      lr
     50         .cfi_endproc
     51 .LFE0:
     52         .fnend
     53         .size   _Z3f_bv, .-_Z3f_bv
     54         .align  2
     55         .global _Z3f_av
     56         .type   _Z3f_av, %function
     57 _Z3f_av:
     58         .fnstart
     59 .LFB1:
     60         .loc 1 6 0
     61         .cfi_startproc
     62         .cfi_personality 0x0,__gxx_personality_v0
     63         .cfi_lsda 0x0,.LLSDA1
     64         @ args = 0, pretend = 0, frame = 0
     65         @ frame_needed = 1, uses_anonymous_args = 0
     66         stmfd   sp!, {fp, lr}
     67         .save {fp, lr}
     68 .LCFI2:
     69         .cfi_def_cfa_offset 8
     70         .setfp fp, sp, #4
     71         add     fp, sp, #4
     72         .cfi_offset 14, -4
     73         .cfi_offset 11, -8
     74 .LCFI3:
     75         .cfi_def_cfa 11, 4
     76 .LEHB0:
     77         .loc 1 7 0
     78         bl      _Z3f_bv(PLT)
     79 .LEHE0:
     80         mov     r3, r0
     81         .loc 1 8 0
     82         mov     r0, r3
     83         ldmfd   sp!, {fp, pc}
     84 .L5:
     85         mov     r3, r0
     86         mov     r2, r1
     87         .loc 1 7 0
     88         cmn     r2, #1
     89         beq     .L4
     90 .LEHB1:
     91         bl      __cxa_end_cleanup(PLT)
     92 .L4:
     93         .loc 1 5 0
     94         mov     r0, r3
     95         bl      __cxa_call_unexpected(PLT)
     96 .LEHE1:
     97         .cfi_endproc
     98 .LFE1:
     99         .global __gxx_personality_v0
    100         .personality    __gxx_personality_v0
    101         .handlerdata
    102         .align  2
    103 .LLSDA1:
    104         .byte   0xff
    105         .byte   0x0
    106         .uleb128 .LLSDATT1-.LLSDATTD1
    107 .LLSDATTD1:
    108         .byte   0x1
    109         .uleb128 .LLSDACSE1-.LLSDACSB1
    110 .LLSDACSB1:
    111         .uleb128 .LEHB0-.LFB1
    112         .uleb128 .LEHE0-.LEHB0
    113         .uleb128 .L5-.LFB1
    114         .uleb128 0x1
    115         .uleb128 .LEHB1-.LFB1
    116         .uleb128 .LEHE1-.LEHB1
    117         .uleb128 0x0
    118         .uleb128 0x0
    119 .LLSDACSE1:
    120         .byte   0x7f
    121         .byte   0x0
    122         .align  2
    123 .LLSDATT1:
    124         .word   0
    125         .fnend
    126         .size   _Z3f_av, .-_Z3f_av
    127 .Letext0:
    128         .section        .debug_loc,"",%progbits
    129 .Ldebug_loc0:
    130 .LLST0:
    131         .4byte  .LFB0-.Ltext0
    132         .4byte  .LCFI0-.Ltext0
    133         .2byte  0x2
    134         .byte   0x7d
    135         .sleb128 0
    136         .4byte  .LCFI0-.Ltext0
    137         .4byte  .LCFI1-.Ltext0
    138         .2byte  0x2
    139         .byte   0x7d
    140         .sleb128 4
    141         .4byte  .LCFI1-.Ltext0
    142         .4byte  .LFE0-.Ltext0
    143         .2byte  0x2
    144         .byte   0x7b
    145         .sleb128 4
    146         .4byte  0x0
    147         .4byte  0x0
    148 .LLST1:
    149         .4byte  .LFB1-.Ltext0
    150         .4byte  .LCFI2-.Ltext0
    151         .2byte  0x2
    152         .byte   0x7d
    153         .sleb128 0
    154         .4byte  .LCFI2-.Ltext0
    155         .4byte  .LCFI3-.Ltext0
    156         .2byte  0x2
    157         .byte   0x7d
    158         .sleb128 8
    159         .4byte  .LCFI3-.Ltext0
    160         .4byte  .LFE1-.Ltext0
    161         .2byte  0x2
    162         .byte   0x7b
    163         .sleb128 4
    164         .4byte  0x0
    165         .4byte  0x0
    166         .section        .debug_info
    167         .4byte  0x61
    168         .2byte  0x2
    169         .4byte  .Ldebug_abbrev0
    170         .byte   0x4
    171         .uleb128 0x1
    172         .4byte  .LASF2
    173         .byte   0x4
    174         .4byte  .LASF3
    175         .4byte  .LASF4
    176         .4byte  .Ltext0
    177         .4byte  .Letext0
    178         .4byte  .Ldebug_line0
    179         .uleb128 0x2
    180         .byte   0x1
    181         .ascii  "f_b\000"
    182         .byte   0x1
    183         .byte   0x1
    184         .4byte  .LASF0
    185         .4byte  0x41
    186         .4byte  .LFB0
    187         .4byte  .LFE0
    188         .4byte  .LLST0
    189         .uleb128 0x3
    190         .byte   0x4
    191         .byte   0x5
    192         .ascii  "int\000"
    193         .uleb128 0x2
    194         .byte   0x1
    195         .ascii  "f_a\000"
    196         .byte   0x1
    197         .byte   0x5
    198         .4byte  .LASF1
    199         .4byte  0x41
    200         .4byte  .LFB1
    201         .4byte  .LFE1
    202         .4byte  .LLST1
    203         .byte   0x0
    204         .section        .debug_abbrev
    205         .uleb128 0x1
    206         .uleb128 0x11
    207         .byte   0x1
    208         .uleb128 0x25
    209         .uleb128 0xe
    210         .uleb128 0x13
    211         .uleb128 0xb
    212         .uleb128 0x3
    213         .uleb128 0xe
    214         .uleb128 0x1b
    215         .uleb128 0xe
    216         .uleb128 0x11
    217         .uleb128 0x1
    218         .uleb128 0x12
    219         .uleb128 0x1
    220         .uleb128 0x10
    221         .uleb128 0x6
    222         .byte   0x0
    223         .byte   0x0
    224         .uleb128 0x2
    225         .uleb128 0x2e
    226         .byte   0x0
    227         .uleb128 0x3f
    228         .uleb128 0xc
    229         .uleb128 0x3
    230         .uleb128 0x8
    231         .uleb128 0x3a
    232         .uleb128 0xb
    233         .uleb128 0x3b
    234         .uleb128 0xb
    235         .uleb128 0x2007
    236         .uleb128 0xe
    237         .uleb128 0x49
    238         .uleb128 0x13
    239         .uleb128 0x11
    240         .uleb128 0x1
    241         .uleb128 0x12
    242         .uleb128 0x1
    243         .uleb128 0x40
    244         .uleb128 0x6
    245         .byte   0x0
    246         .byte   0x0
    247         .uleb128 0x3
    248         .uleb128 0x24
    249         .byte   0x0
    250         .uleb128 0xb
    251         .uleb128 0xb
    252         .uleb128 0x3e
    253         .uleb128 0xb
    254         .uleb128 0x3
    255         .uleb128 0x8
    256         .byte   0x0
    257         .byte   0x0
    258         .byte   0x0
    259         .section        .debug_pubnames,"",%progbits
    260         .4byte  0x1e
    261         .2byte  0x2
    262         .4byte  .Ldebug_info0
    263         .4byte  0x65
    264         .4byte  0x25
    265         .ascii  "f_b\000"
    266         .4byte  0x48
    267         .ascii  "f_a\000"
    268         .4byte  0x0
    269         .section        .debug_aranges,"",%progbits
    270         .4byte  0x1c
    271         .2byte  0x2
    272         .4byte  .Ldebug_info0
    273         .byte   0x4
    274         .byte   0x0
    275         .2byte  0x0
    276         .2byte  0x0
    277         .4byte  .Ltext0
    278         .4byte  .Letext0-.Ltext0
    279         .4byte  0x0
    280         .4byte  0x0
    281         .section        .debug_str,"MS",%progbits,1
    282 .LASF1:
    283         .ascii  "_Z3f_av\000"
    284 .LASF4:
    285         .ascii  "/home/kun/work/share_lib\000"
    286 .LASF0:
    287         .ascii  "_Z3f_bv\000"
    288 .LASF3:
    289         .ascii  "test.cc\000"
    290 .LASF2:
    291         .ascii  "GNU C++ 4.5.1\000"
    292         .ident  "GCC: (GNU) 4.5.1"
    293         .section        .note.GNU-stack,"",%progbits


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]