This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
MIPS patch for the handling of hidden symbols
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: 24 Oct 2003 16:24:00 +0100
- Subject: MIPS patch for the handling of hidden symbols
This patch fixes a read-from-uninitialised-memory error in the
mips linker. If an input bfd has a hidden symbol, the following
code in _bfd_mips_elf_hide_symbol is supposed to allocate a local
GOT entry for it:
else if (g->global_gotno == 0 && g->global_gotsym == NULL)
/* If we haven't got through GOT allocation yet, just bump up the
number of local entries, as this symbol won't be counted as
global. */
g->local_gotno++;
But global_gotno isn't initialised at this point. Sometimes
we'd allocate a GOT entry and sometimes we wouldn't.
Patch tested on mips64-linux-gnu. It fixes cgd's original test case
but, due to the nature of the bug, it's not easy to whittle down for
the testsuite.
Installed as obvious.
Richard
* elfxx-mips.c (mips_elf_create_got_section): Initialize global_gotno.
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.78
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.78 elfxx-mips.c
*** bfd/elfxx-mips.c 13 Oct 2003 19:51:09 -0000 1.78
--- bfd/elfxx-mips.c 19 Oct 2003 10:53:01 -0000
*************** mips_elf_create_got_section (abfd, info,
*** 2867,2872 ****
--- 2867,2873 ----
if (g == NULL)
return FALSE;
g->global_gotsym = NULL;
+ g->global_gotno = 0;
g->local_gotno = MIPS_RESERVED_GOTNO;
g->assigned_gotno = MIPS_RESERVED_GOTNO;
g->bfd2got = NULL;