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: PR binutils/12639: nm/readelf failed to detect corrupted symtab


On Tue, Apr 5, 2011 at 7:51 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Apr 05, 2011 at 10:08:49AM -0700, H.J. Lu wrote:
>> + ? ? ? ? ? /* Force it to local symbol. ?*/
>> + ? ? ? ? ? isym->st_info = ELF_ST_INFO (STB_LOCAL,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ELF_ST_TYPE (isym->st_info));
>> + ? ? ? ? }
>> +
>
> I think this is wrong. ?The testcase clearly wants "main" as a global.

That is the problem.  elflink.c has:

  /* The sh_info field of the symtab header tells us where the
     external symbols start.  We don't care about the local symbols at
     this point.  */
  if (elf_bad_symtab (abfd))
    {
      extsymcount = symcount;
      extsymoff = 0;
    }
  else
    {
      extsymcount = symcount - hdr->sh_info;
      extsymoff = hdr->sh_info;
    }

Linker will treat main as local no matter what symtab says.
For all practical purposes, any symbol before sh_info is
a local symbol.

> What created this bad object file?

They should remain nameless if possible :-).


-- 
H.J.


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