This is the mail archive of the binutils@sources.redhat.com 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]

Re: Patch: Zero out the allocated dynamic content space.


   Date: Fri, 18 Aug 2000 00:14:31 -0700
   From: "H . J . Lu" <hjl@valinux.com>

   # make
   ld -shared -o test.so --version-script=test.map rtld.os setjmp.os
   readelf -r test.so | head -5

   Relocation section '.rel.text' at offset 0xcbc contains 1 entries:
     Offset    Info  Type            Symbol's Value  Symbol's Name
     00000609  01c84 unrecognised: 84      00000000  _dl_debug_fd

   "unrecognised: 84" is caused by bfd_alloc, which leaves s->contents
   uninitialized in certain cases. Most of the ELF targets use bfd_zalloc
   instead of bfd_alloc for s->contents. I think all ELF targets should
   use bfd_zalloc. At least, it fixes Linux/ia32:

This is an argument we have had many times before.  You have found a
bug.  Using bfd_zalloc fixes the symptoms by hiding the bug.  It does
not fix the bug.  I think it is better to fix the bug than to fix the
symptoms.

In programming I can think of only one possible reason to fix the
symptoms rather than to fix the bug: because you must make release the
code immediately, and you are very pressed for time.  That reason does
not apply in this case.  Even if it did, it would only be appropriate
to fix the symptoms on the release branch.  In the real sources, we
should fix the actual bug.

Ian

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