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: PATCH: ld/2218: Weak undefined symbol doesn't work properly with PIE


On Fri, Jan 27, 2006 at 06:28:06AM -0800, H. J. Lu wrote:
> On Fri, Jan 27, 2006 at 08:34:51PM +1030, Alan Modra wrote:
> > On Thu, Jan 26, 2006 at 11:03:35PM -0800, H. J. Lu wrote:
> > > We should treat global symbols in PIE like shared library.
> > 
> > Perhaps.  But please explain why the place you are patching is the
> > correct place to fix a problem with weak syms.  I don't think your patch
> > is correct.
> 
> PIE is like DSO when the undefined weak symbols are concerned. They
> have to be dynamic symbols so that ld.so can handle them properly. I
> will check in my testcase shortly so that you can check it out.
> 

The patch probably is incorrect. I think we have an issue with dynamic
symbols in PIE:

bash-3.00$ cat x.c
main (){ }
bash-3.00$ gcc -c x.c
bash-3.00$ gcc x.o
bash-3.00$ readelf -Ds a.out

Symbol table for image:
  Num Buc:    Value  Size   Type   Bind Vis      Ndx Name
    4   0: 00000000     0  NOTYPE   WEAK DEFAULT UND __gmon_start__
    3   0: 00000000     0  NOTYPE   WEAK DEFAULT UND _Jv_RegisterClasses
    1   1: 00000000   221    FUNC GLOBAL DEFAULT UND __libc_start_main
    2   2: 08048430     4  OBJECT GLOBAL DEFAULT  14 _IO_stdin_used
bash-3.00$ gcc x.o -pie
bash-3.00$ readelf -Ds a.out

Symbol table for image:
  Num Buc:    Value  Size   Type   Bind Vis      Ndx Name
   16   1: 000017c0     0  NOTYPE GLOBAL DEFAULT ABS _edata
   15   1: 00000000   231    FUNC   WEAK DEFAULT UND __cxa_finalize
   19   3: 00000000     0  NOTYPE   WEAK DEFAULT UND _Jv_RegisterClasses
   14   7: 00000000   221    FUNC GLOBAL DEFAULT UND __libc_start_main
   13  10: 0000059c    30    FUNC GLOBAL DEFAULT  12 main
   12  11: 000017c0     0  NOTYPE GLOBAL DEFAULT ABS __bss_start
   18  13: 000006ac     4  OBJECT GLOBAL DEFAULT  14 _IO_stdin_used
   17  13: 000017c4     0  NOTYPE GLOBAL DEFAULT ABS _end
   20  15: 00000000     0  NOTYPE   WEAK DEFAULT UND __gmon_start__
bash-3.00$

We are putting more symbols into dynamic symbol table in PIE without
marking them hidden. That means we export more symbols in PIE. I will
see what I can do.


H.J.


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