This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

Re: PIE and --(no-)export-dynamic


lÃr 2010-03-20 klockan 22:34 -0400 skrev Daniel Jacobowitz:
> On Sun, Mar 21, 2010 at 12:11:45PM +1030, Alan Modra wrote:
> > On Sat, Mar 20, 2010 at 02:32:59PM +0100, Peter Hjalmarsson wrote:
> > > Should the -export-dynamic/--no-export-dynamic do any difference on a
> > > PIE file?
> > > 
> > > As an example lets take ld/testsuite/ld-elfvers/vers4.c.
> > > compile it:
> > > 
> > > $ gcc -o test1 -Wl,--no-export-dynamic vers4.c
> > > $ gcc -o test2 -fPIE -pie -Wl,--no-export-dynamic vers4.c
> > > 
> > > If you objdump -T the resulting files you will see that test2 still
> > > exports foo@@VERS_2.0 along other things (like main).
> > > 
> > > Is this a expected behaviour or is it a bug?
> > 
> > I think you are reading too much into the name of the option.
> > --no-export-dynamic doesn't say "don't export any dynamic symbols".
> > It is merely there to turn off --export-dynamic.  See the ld info
> > doc.
> 
> I think Peter's got a point.  Why should a PIE version of vers4 export
> foo?  Or, for that matter, main?  No dynamic object references the
> symbol; it's just wasting space.
> 
> MIPS used to have this same problem for dynamic applications; we
> (Richard S., I think, but I don't remember) fixed it just a year or
> two ago.
> 

After H.J. Lu's patch ld passes the testsuite for PIE (i.e. foo@VERS_2.0
is no longer exported), but is still exports more symbols for PIE, like
main. 
Is there something we can do about it or do we have to live with it?

As reference:

$ gcc -o test1 -Wl,--no-export-dynamic vers4.c 
$ gcc -o test2 -fPIE -pie -Wl,--no-export-dynamic vers4.c 
$ objdump -T test*

test1:     file format elf64-x86-64

DYNAMIC SYMBOL TABLE:
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.2.5 printf
0000000000000000  w   D  *UND*	0000000000000000
__gmon_start__
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.2.5
__libc_start_main
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.4
__stack_chk_fail



test2:     file format elf64-x86-64

DYNAMIC SYMBOL TABLE:
0000000000000270 l    d  .interp	0000000000000000              .interp
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.2.5 printf
0000000000000000  w   D  *UND*	0000000000000000
__gmon_start__
0000000000000000  w   D  *UND*	0000000000000000
_Jv_RegisterClasses
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.2.5
__libc_start_main
0000000000000000  w   DF *UND*	0000000000000000  GLIBC_2.2.5
__cxa_finalize
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.4
__stack_chk_fail
0000000000201020 g    D  *ABS*	0000000000000000  Base        _end
0000000000201010 g    D  *ABS*	0000000000000000  Base        _edata
00000000000008e0 g    DF .text	0000000000000088  Base
__libc_csu_init
0000000000201010 g    D  *ABS*	0000000000000000  Base        __bss_start
000000000000087a g    DF .text	0000000000000054  Base        main
00000000000008d0 g    DF .text	0000000000000002  Base
__libc_csu_fini



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