This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: glibc built without .gnu.warning.symbol sections
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Thu, 25 Jul 2013 09:45:51 +0930
- Subject: Re: glibc built without .gnu.warning.symbol sections
- References: <20130720094728 dot GB3294 at bubble dot grove dot modra dot org> <CAMe9rOr_ojZv=FNqx6rWbV_sw+A_7goaRRnrZdvFRjMNGKyxMg at mail dot gmail dot com> <CAMe9rOqR=WEzwdS3c4oLgPaCC9cdSHWrGDpxZstfw+pLDQcS9g at mail dot gmail dot com>
On Wed, Jul 24, 2013 at 11:46:59AM -0700, H.J. Lu wrote:
> On Wed, Jul 24, 2013 at 10:26 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> > On Sat, Jul 20, 2013 at 2:47 AM, Alan Modra <amodra@gmail.com> wrote:
> >> The fix for PR 12761 results in glibc libc.so.6 being built without
> >> warning sections. Fixed as follows.
> >>
> >> PR ld/15762
> >> * elflink.c (elf_link_add_object_symbols): Don't clobber
> >> .gnu.warning.symbol sections when shared.
> >>
> >> Index: bfd/elflink.c
> >> ===================================================================
> >> RCS file: /cvs/src/src/bfd/elflink.c,v
> >> retrieving revision 1.494
> >> diff -u -p -r1.494 elflink.c
> >> --- bfd/elflink.c 8 May 2013 23:31:38 -0000 1.494
> >> +++ bfd/elflink.c 20 Jul 2013 09:34:39 -0000
> >> @@ -3444,7 +3445,7 @@ elf_link_add_object_symbols (bfd *abfd,
> >> FALSE, bed->collect, NULL)))
> >> goto error_return;
> >>
> >> - if (! info->relocatable)
> >> + if (!info->relocatable && !info->shared)
> >
> > This looks wrong. It will generate .gnu.warning.symbol sections in PIE.
> > Shouldn't the check be if (info->executable)?
Yes, it is wrong. Oops.
> Here is a patch. OK to install?
>
> Thanks.
>
>
> --
> H.J.
> --
> 2013-07-24 H.J. Lu <hongjiu.lu@intel.com>
>
> PR ld/15762
> * elflink.c (elf_link_add_object_symbols): Always clobber
> .gnu.warning.symbol sections when building executable.
>
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index 55f00da..e4044e3 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -3444,7 +3444,7 @@ elf_link_add_object_symbols (bfd *abfd, struct
> bfd_link_info *info)
> FALSE, bed->collect, NULL)))
> goto error_return;
>
> - if (!info->relocatable && !info->shared)
> + if (info->executable)
> {
> /* Clobber the section size so that the warning does
> not get copied into the output file. */
No, don't remove !info->relocatable here.
Looking over this code again, I see a couple of other things could be
tidied too. "if (info->executable || info->shared)" is the same as
"if (1)". (See ld/lexsup.c:parse_args.) Also, zapping the size of
dynamic bfd sections is unnecessary as those won't be included in the
output anyway. (See bfd_section_list_clear() later in this function.)
PR ld/15762
PR ld/12761
* elflink.c (elf_link_add_object_symbols): Correct test in
last patch. Remove unnecessary code.
Note diff -w in the patch following!
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.495
diff -u -p -w -r1.495 elflink.c
--- bfd/elflink.c 20 Jul 2013 09:50:16 -0000 1.495
+++ bfd/elflink.c 24 Jul 2013 23:59:21 -0000
@@ -3344,6 +3345,7 @@ elf_link_add_object_symbols (bfd *abfd,
long old_dynsymcount = 0;
bfd_size_type old_dynstr_size = 0;
size_t tabsize = 0;
+ asection *s;
htab = elf_hash_table (info);
bed = get_elf_backend_data (abfd);
@@ -3385,10 +3387,6 @@ elf_link_add_object_symbols (bfd *abfd,
symbol. This differs from .gnu.warning sections, which generate
warnings when they are included in an output file. */
/* PR 12761: Also generate this warning when building shared libraries. */
- if (info->executable || info->shared)
- {
- asection *s;
-
for (s = abfd->sections; s != NULL; s = s->next)
{
const char *name;
@@ -3420,14 +3418,8 @@ elf_link_add_object_symbols (bfd *abfd,
if (h != NULL
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak))
- {
- /* We don't want to issue this warning. Clobber
- the section size so that the warning does not
- get copied into the output file. */
- s->size = 0;
continue;
}
- }
sz = s->size;
msg = (char *) bfd_alloc (abfd, sz + 1);
@@ -3444,7 +3436,7 @@ elf_link_add_object_symbols (bfd *abfd,
FALSE, bed->collect, NULL)))
goto error_return;
- if (!info->relocatable && !info->shared)
+ if (!info->relocatable && info->executable)
{
/* Clobber the section size so that the warning does
not get copied into the output file. */
@@ -3456,7 +3448,6 @@ elf_link_add_object_symbols (bfd *abfd,
}
}
}
- }
add_needed = TRUE;
if (! dynamic)
@@ -3479,7 +3470,6 @@ elf_link_add_object_symbols (bfd *abfd,
goto error_return;
else
{
- asection *s;
const char *soname = NULL;
char *audit = NULL;
struct bfd_link_needed_list *rpath = NULL, *runpath = NULL;
--
Alan Modra
Australia Development Lab, IBM