functions defined in .rodata section

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

functions defined in .rodata section

Alex Kogan

Hello,

I found strange code layout while building glibc 2.3.6 with gcc 4.1 on RHEL
4/PowerPC system - some functions seem to be defined in .rodata section.
Here is the fragment of header information of created libm library
(collected by readelf):
  [14] .fini             PROGBITS        0003f320 03f320 000038 00  AX  0
0  4
  [15] .rela.fini        RELA            00000000 0935b8 000024 0c     48
14  4
  [16] .rodata           PROGBITS        0003f358 03f358 038738 00   A  0
0  8
  [17] .rela.rodata      RELA            00000000 0935dc 000d5c 0c     48
16  4
  [18] .interp           PROGBITS        00077a90 077a90 000024 00   A  0
0  4
From .dynsymtab:
    65: 00071d78   100 FUNC    WEAK   DEFAULT   16 truncl@@GLIBC_2.1
From .symtab:
  3293: 00071d78   100 FUNC    LOCAL  DEFAULT   16 __truncl
  3677: 00071d78   100 FUNC    WEAK   DEFAULT   16 truncl
From gdb, it seems like a real function:
0x71d78 <truncl>:       mffs    f11
0x71d7c <truncl+4>:     mflr    r11
0x71d80 <truncl+8>:     bl      0x8a580 <tab54+9552>
0x71d84 <truncl+12>:    mflr    r10
0x71d88 <truncl+16>:    lwz     r9,-4384(r10)
0x71d8c <truncl+20>:    mtlr    r11
0x71d90 <truncl+24>:    lfd     f13,0(r9)
0x71d94 <truncl+28>:    fabs    f0,f1
0x71d98 <truncl+32>:    fsub    f12,f13,f13
0x71d9c <truncl+36>:    fcmpu   cr7,f0,f13
0x71da0 <truncl+40>:    fcmpu   cr6,f1,f12
0x71da4 <truncl+44>:    bgelr   cr7
0x71da8 <truncl+48>:    mtfsfi  cr7,1
0x71dac <truncl+52>:    ble-    cr6,0x71dc4 <truncl+76>
0x71db0 <truncl+56>:    fadd    f1,f1,f13
0x71db4 <truncl+60>:    fsub    f1,f1,f13
0x71db8 <truncl+64>:    fabs    f1,f1
0x71dbc <truncl+68>:    mtfsf   1,f11
0x71dc0 <truncl+72>:    blr
0x71dc4 <truncl+76>:    bge-    cr6,0x71dd4 <truncl+92>
0x71dc8 <truncl+80>:    fsub    f1,f1,f13
0x71dcc <truncl+84>:    fadd    f1,f1,f13
0x71dd0 <truncl+88>:    fnabs   f1,f1
0x71dd4 <truncl+92>:    mtfsf   1,f11
0x71dd8 <truncl+96>:    blr
0x71ddc <truncl+100>:   .long 0x0

I am wondering if this is some bug in compiler or this function can be
still called externally (although .rodata appears as non-executable
section,)?

Thanks in advance,
_______________________________
Alex Kogan
IBM Research Labs

Reply | Threaded
Open this post in threaded view
|

Re: functions defined in .rodata section

Alan Modra
On Mon, Dec 26, 2005 at 08:03:05PM +0200, Alex Kogan wrote:
> I found strange code layout while building glibc 2.3.6 with gcc 4.1 on RHEL
> 4/PowerPC system - some functions seem to be defined in .rodata section.

A glibc bug, fixed by 2005-05-17  Alan Modra  <[hidden email]>

--
Alan Modra
IBM OzLabs - Linux Technology Centre