Re: Small binutils tweak

2013-10-18 Thread Landry Breuil
On Fri, Aug 23, 2013 at 10:40:22PM +0200, Landry Breuil wrote:
> On Sun, Apr 21, 2013 at 10:42:09AM -0400, Brian Callahan wrote:
> > On 04/21/13 03:21, Jonathan Gray wrote:
> > >On Sat, Mar 02, 2013 at 10:36:50AM -0500, Brian Callahan wrote:
> > >>Hi tech --
> > >>
> > >>While doing some ports testing with clang, I came across the
> > >>binutils bug mentioned here:
> > >>http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html
> > >>
> > >>Below is a backport of the commit mentioned later in the thread. It
> > >>fixes the issue.
> > >>I was able to rebuild working kernels and do a full 'make build' on
> > >>amd64, loongson, and macppc with this patch. But since it affects
> > >>all archs, testing on the archs I don't have access to will be
> > >>needed.
> > >>
> > >>OK?
> > >This patch does not apply, it seems your mail client is wrapping lines.
> > >
> > >
> > 
> > Below. Also attached as a tarball, in case Thunderbird really just hates me.
> > 
> > miod told me about a month and a half ago to focus on moving to
> > binutils-2.17 and not backport things to 2.15 so I never bothered to
> > ping this.
> 
> Bringing this back , since i'm facing issues with mozilla / icu linking
> with ld/building with clang. In my limited testing, instead of the big
> patch you were referring to, just using elflink.c r1.76 was enough to
> fix my issue.
> 
> See https://bugzilla.mozilla.org/show_bug.cgi?id=908080 for the whole
> story, and
> http://www.sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.75&r2=1.76
> for the much smaller fix.
> 
> Whatever was the reason for backing this out (iirc, xenocara blowed on
> ppc), this needs to be reconsidered, since we're not going to move to
> binutils 2.17 right now.

I know it still breaks stuff subtly on powerpc, but i stumbled upon this
again when trying to build mozilla trunk on i386 with clang. If we still
want to build next firefoxes (26 or 27, dont remember) with clang,
something has to move around this.

Landry



Re: Small binutils tweak

2013-08-23 Thread Landry Breuil
On Sun, Apr 21, 2013 at 10:42:09AM -0400, Brian Callahan wrote:
> On 04/21/13 03:21, Jonathan Gray wrote:
> >On Sat, Mar 02, 2013 at 10:36:50AM -0500, Brian Callahan wrote:
> >>Hi tech --
> >>
> >>While doing some ports testing with clang, I came across the
> >>binutils bug mentioned here:
> >>http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html
> >>
> >>Below is a backport of the commit mentioned later in the thread. It
> >>fixes the issue.
> >>I was able to rebuild working kernels and do a full 'make build' on
> >>amd64, loongson, and macppc with this patch. But since it affects
> >>all archs, testing on the archs I don't have access to will be
> >>needed.
> >>
> >>OK?
> >This patch does not apply, it seems your mail client is wrapping lines.
> >
> >
> 
> Below. Also attached as a tarball, in case Thunderbird really just hates me.
> 
> miod told me about a month and a half ago to focus on moving to
> binutils-2.17 and not backport things to 2.15 so I never bothered to
> ping this.

Bringing this back , since i'm facing issues with mozilla / icu linking
with ld/building with clang. In my limited testing, instead of the big
patch you were referring to, just using elflink.c r1.76 was enough to
fix my issue.

See https://bugzilla.mozilla.org/show_bug.cgi?id=908080 for the whole
story, and
http://www.sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.75&r2=1.76
for the much smaller fix.

Whatever was the reason for backing this out (iirc, xenocara blowed on
ppc), this needs to be reconsidered, since we're not going to move to
binutils 2.17 right now.

Landry



Re: Small binutils tweak

2013-04-21 Thread Brian Callahan

On 04/21/13 03:21, Jonathan Gray wrote:

On Sat, Mar 02, 2013 at 10:36:50AM -0500, Brian Callahan wrote:

Hi tech --

While doing some ports testing with clang, I came across the
binutils bug mentioned here:
http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html

Below is a backport of the commit mentioned later in the thread. It
fixes the issue.
I was able to rebuild working kernels and do a full 'make build' on
amd64, loongson, and macppc with this patch. But since it affects
all archs, testing on the archs I don't have access to will be
needed.

OK?

This patch does not apply, it seems your mail client is wrapping lines.




Below. Also attached as a tarball, in case Thunderbird really just hates me.

miod told me about a month and a half ago to focus on moving to 
binutils-2.17 and not backport things to 2.15 so I never bothered to 
ping this.


~Brian

Index: elf-bfd.h
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elf-bfd.h,v
retrieving revision 1.8
diff -u -p -r1.8 elf-bfd.h
--- elf-bfd.h2 Nov 2004 20:45:06 -1.8
+++ elf-bfd.h21 Apr 2013 14:31:06 -
@@ -1055,8 +1055,8 @@ struct bfd_elf_section_data
 #define elf_discarded_section(sec)\
   (!bfd_is_abs_section (sec)\
&& bfd_is_abs_section ((sec)->output_section) \
-   && sec->sec_info_type != ELF_INFO_TYPE_MERGE \
-   && sec->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
+   && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE \
+   && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)

 #define get_elf_backend_data(abfd) \
   ((const struct elf_backend_data *) (abfd)->xvec->backend_data)
Index: elflink.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elflink.c,v
retrieving revision 1.9
diff -u -p -r1.9 elflink.c
--- elflink.c24 Nov 2004 16:55:31 -1.9
+++ elflink.c21 Apr 2013 14:31:07 -
@@ -6239,6 +6239,9 @@ elf_link_output_extsym (struct elf_link_
   return TRUE;
 }

+/* Return TRUE if special handling is done for relocs in SEC against
+   symbols defined in discarded sections.  */
+
 static bfd_boolean
 elf_section_ignore_discarded_relocs (asection *sec)
 {
@@ -6261,6 +6264,26 @@ elf_section_ignore_discarded_relocs (ase
   return FALSE;
 }

+/* Return TRUE if we should complain about a reloc in SEC against a
+   symbol defined in a discarded section.  */
+
+static bfd_boolean
+elf_section_complain_discarded (asection *sec)
+{
+  if (strncmp (".stab", sec->name, 5) == 0
+  && (!sec->name[5] ||
+ (sec->name[5] == '.' && ISDIGIT (sec->name[6]
+return FALSE;
+
+  if (strcmp (".eh_frame", sec->name) == 0)
+return FALSE;
+
+  if (strcmp (".gcc_except_table", sec->name) == 0)
+return FALSE;
+
+  return TRUE;
+}
+
 /* Link an input file into the linker output file.  This function
handles all the sections and relocations of the input file at once.
This is so that we only have to read the local symbols once, and
@@ -6532,13 +6555,16 @@ elf_link_input_bfd (struct elf_final_lin
   if (!elf_section_ignore_discarded_relocs (o))
 {
   Elf_Internal_Rela *rel, *relend;
+  bfd_boolean complain = elf_section_complain_discarded 
(o);


   rel = internal_relocs;
   relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel;
   for ( ; rel < relend; rel++)
 {
   unsigned long r_symndx = rel->r_info >> r_sym_shift;
-  asection *sec;
+  asection **ps, *sec;
+  struct elf_link_hash_entry *h = NULL;
+  const char *sym_name;

   if (r_symndx >= locsymcount
   || (elf_bad_symtab (input_bfd)
@@ -6551,79 +6577,70 @@ elf_link_input_bfd (struct elf_final_lin
  || h->root.type == bfd_link_hash_warning)
 h = (struct elf_link_hash_entry *) h->root.u.i.link;

-  /* Complain if the definition comes from a
- discarded section.  */
-  sec = h->root.u.def.section;
-  if ((h->root.type == bfd_link_hash_defined
-   || h->root.type == bfd_link_hash_defweak)
-  && elf_discarded_section (sec))
-{
-  if ((o->flags & SEC_DEBUGGING) != 0)
-{
-  BFD_ASSERT (r_symndx != 0);
-  /* Try to preserve debug information.  */
-  if ((o->flags & SEC_DEBUGGING) != 0
-  && sec->kept_section != NULL
-  && sec->_raw_size == sec->kept_section->_raw_size)
-h->root.u.def.section
-  = sec->kept_section;
-  else
-memset (rel, 0, sizeof (*rel));
-}
-  else
-finfo->info->callbacks->error_handler
-  (LD_DEFINITION_IN_DISCARDED_SECTION,
-   _("%T: di

Re: Small binutils tweak

2013-04-21 Thread Jonathan Gray
On Sat, Mar 02, 2013 at 10:36:50AM -0500, Brian Callahan wrote:
> Hi tech --
> 
> While doing some ports testing with clang, I came across the
> binutils bug mentioned here:
> http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html
> 
> Below is a backport of the commit mentioned later in the thread. It
> fixes the issue.
> I was able to rebuild working kernels and do a full 'make build' on
> amd64, loongson, and macppc with this patch. But since it affects
> all archs, testing on the archs I don't have access to will be
> needed.
> 
> OK?

This patch does not apply, it seems your mail client is wrapping lines.

> 
> ~Brian
> 
> Index: elf-bfd.h
> ===
> RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elf-bfd.h,v
> retrieving revision 1.8
> diff -u -p -r1.8 elf-bfd.h
> --- elf-bfd.h2 Nov 2004 20:45:06 -1.8
> +++ elf-bfd.h16 Feb 2013 22:43:53 -
> @@ -1055,8 +1055,8 @@ struct bfd_elf_section_data
>  #define elf_discarded_section(sec)\
>(!bfd_is_abs_section (sec)\
> && bfd_is_abs_section ((sec)->output_section) \
> -   && sec->sec_info_type != ELF_INFO_TYPE_MERGE \
> -   && sec->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
> +   && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE  \
> +   && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
> 
>  #define get_elf_backend_data(abfd) \
>((const struct elf_backend_data *) (abfd)->xvec->backend_data)
> Index: elflink.c
> ===
> RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elflink.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 elflink.c
> --- elflink.c24 Nov 2004 16:55:31 -1.9
> +++ elflink.c16 Feb 2013 22:43:56 -
> @@ -6239,6 +6239,9 @@ elf_link_output_extsym (struct elf_link_
>return TRUE;
>  }
> 
> +/* Return TRUE if special handling is done for relocs in SEC against
> +   symbols defined in discarded sections.  */
> +
>  static bfd_boolean
>  elf_section_ignore_discarded_relocs (asection *sec)
>  {
> @@ -6261,6 +6264,26 @@ elf_section_ignore_discarded_relocs (ase
>return FALSE;
>  }
> 
> +/* Return TRUE if we should complain about a reloc in SEC against a
> +   symbol defined in a discarded section.  */
> +
> +static bfd_boolean
> +elf_section_complain_discarded (asection *sec)
> +{
> +  if (strncmp (".stab", sec->name, 5) == 0
> +  && (!sec->name[5] ||
> + (sec->name[5] == '.' && ISDIGIT (sec->name[6]
> +return FALSE;
> +
> +  if (strcmp (".eh_frame", sec->name) == 0)
> +return FALSE;
> +
> +  if (strcmp (".gcc_except_table", sec->name) == 0)
> +return FALSE;
> +
> +  return TRUE;
> +}
> +
>  /* Link an input file into the linker output file.  This function
> handles all the sections and relocations of the input file at once.
> This is so that we only have to read the local symbols once, and
> @@ -6532,13 +6555,16 @@ elf_link_input_bfd (struct elf_final_lin
>if (!elf_section_ignore_discarded_relocs (o))
>  {
>Elf_Internal_Rela *rel, *relend;
> +  bfd_boolean complain = elf_section_complain_discarded (o);
> 
>rel = internal_relocs;
>relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel;
>for ( ; rel < relend; rel++)
>  {
>unsigned long r_symndx = rel->r_info >> r_sym_shift;
> -  asection *sec;
> +  asection **ps, *sec;
> +  struct elf_link_hash_entry *h = NULL;
> +  const char *sym_name;
> 
>if (r_symndx >= locsymcount
>|| (elf_bad_symtab (input_bfd)
> @@ -6551,79 +6577,70 @@ elf_link_input_bfd (struct elf_final_lin
>   || h->root.type == bfd_link_hash_warning)
>  h = (struct elf_link_hash_entry *) h->root.u.i.link;
> 
> -  /* Complain if the definition comes from a
> - discarded section.  */
> -  sec = h->root.u.def.section;
> -  if ((h->root.type == bfd_link_hash_defined
> -   || h->root.type == bfd_link_hash_defweak)
> -  && elf_discarded_section (sec))
> -{
> -  if ((o->flags & SEC_DEBUGGING) != 0)
> -{
> -  BFD_ASSERT (r_symndx != 0);
> -  /* Try to preserve debug information.  */
> -  if ((o->flags & SEC_DEBUGGING) != 0
> -  && sec->kept_section != NULL
> -  && sec->_raw_size == sec->kept_section->_raw_size)
> -h->root.u.def.section
> -  = sec->kept_section;
> -  else
> -memset (rel, 0, sizeof (*rel));
> -}
> -  else
> -finfo->info->callbacks->error_handler
> -  (LD_DEFINITION_IN_DISCARDED_SECTION,
> -   _("%T: discarded in section `%s' from %s\n"),
> -

Re: Small binutils tweak

2013-03-02 Thread Brian Callahan

On 3/2/2013 10:36 AM, Brian Callahan wrote:

Hi tech --

While doing some ports testing with clang, I came across the binutils
bug mentioned here:
http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html

Below is a backport of the commit mentioned later in the thread. It
fixes the issue.
I was able to rebuild working kernels and do a full 'make build' on
amd64, loongson, and macppc with this patch. But since it affects all
archs, testing on the archs I don't have access to will be needed.

OK?



To clear up any confusion, this code is taken from the 2.16 time frame. 
It is GPLv2 code. The fix in question is already in the binutils-2.17 
code we have in our tree.



~Brian

Index: elf-bfd.h
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elf-bfd.h,v
retrieving revision 1.8
diff -u -p -r1.8 elf-bfd.h
--- elf-bfd.h2 Nov 2004 20:45:06 -1.8
+++ elf-bfd.h16 Feb 2013 22:43:53 -
@@ -1055,8 +1055,8 @@ struct bfd_elf_section_data
  #define elf_discarded_section(sec)\
(!bfd_is_abs_section (sec)\
 && bfd_is_abs_section ((sec)->output_section) \
-   && sec->sec_info_type != ELF_INFO_TYPE_MERGE \
-   && sec->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
+   && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE  \
+   && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)

  #define get_elf_backend_data(abfd) \
((const struct elf_backend_data *) (abfd)->xvec->backend_data)
Index: elflink.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elflink.c,v
retrieving revision 1.9
diff -u -p -r1.9 elflink.c
--- elflink.c24 Nov 2004 16:55:31 -1.9
+++ elflink.c16 Feb 2013 22:43:56 -
@@ -6239,6 +6239,9 @@ elf_link_output_extsym (struct elf_link_
return TRUE;
  }

+/* Return TRUE if special handling is done for relocs in SEC against
+   symbols defined in discarded sections.  */
+
  static bfd_boolean
  elf_section_ignore_discarded_relocs (asection *sec)
  {
@@ -6261,6 +6264,26 @@ elf_section_ignore_discarded_relocs (ase
return FALSE;
  }

+/* Return TRUE if we should complain about a reloc in SEC against a
+   symbol defined in a discarded section.  */
+
+static bfd_boolean
+elf_section_complain_discarded (asection *sec)
+{
+  if (strncmp (".stab", sec->name, 5) == 0
+  && (!sec->name[5] ||
+ (sec->name[5] == '.' && ISDIGIT (sec->name[6]
+return FALSE;
+
+  if (strcmp (".eh_frame", sec->name) == 0)
+return FALSE;
+
+  if (strcmp (".gcc_except_table", sec->name) == 0)
+return FALSE;
+
+  return TRUE;
+}
+
  /* Link an input file into the linker output file.  This function
 handles all the sections and relocations of the input file at once.
 This is so that we only have to read the local symbols once, and
@@ -6532,13 +6555,16 @@ elf_link_input_bfd (struct elf_final_lin
if (!elf_section_ignore_discarded_relocs (o))
  {
Elf_Internal_Rela *rel, *relend;
+  bfd_boolean complain = elf_section_complain_discarded (o);

rel = internal_relocs;
relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel;
for ( ; rel < relend; rel++)
  {
unsigned long r_symndx = rel->r_info >> r_sym_shift;
-  asection *sec;
+  asection **ps, *sec;
+  struct elf_link_hash_entry *h = NULL;
+  const char *sym_name;

if (r_symndx >= locsymcount
|| (elf_bad_symtab (input_bfd)
@@ -6551,79 +6577,70 @@ elf_link_input_bfd (struct elf_final_lin
   || h->root.type == bfd_link_hash_warning)
  h = (struct elf_link_hash_entry *) h->root.u.i.link;

-  /* Complain if the definition comes from a
- discarded section.  */
-  sec = h->root.u.def.section;
-  if ((h->root.type == bfd_link_hash_defined
-   || h->root.type == bfd_link_hash_defweak)
-  && elf_discarded_section (sec))
-{
-  if ((o->flags & SEC_DEBUGGING) != 0)
-{
-  BFD_ASSERT (r_symndx != 0);
-  /* Try to preserve debug information.  */
-  if ((o->flags & SEC_DEBUGGING) != 0
-  && sec->kept_section != NULL
-  && sec->_raw_size == sec->kept_section->_raw_size)
-h->root.u.def.section
-  = sec->kept_section;
-  else
-memset (rel, 0, sizeof (*rel));
-}
-  else
-finfo->info->callbacks->error_handler
-  (LD_DEFINITION_IN_DISCARDED_SECTION,
-   _("%T: discarded in section `%s' from %s\n"),
-   h->root.root.string,
-   h->root.root.string,
-   h->root.u.def.section->name,
- 

Small binutils tweak

2013-03-02 Thread Brian Callahan

Hi tech --

While doing some ports testing with clang, I came across the binutils 
bug mentioned here:

http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html

Below is a backport of the commit mentioned later in the thread. It 
fixes the issue.
I was able to rebuild working kernels and do a full 'make build' on 
amd64, loongson, and macppc with this patch. But since it affects all 
archs, testing on the archs I don't have access to will be needed.


OK?

~Brian

Index: elf-bfd.h
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elf-bfd.h,v
retrieving revision 1.8
diff -u -p -r1.8 elf-bfd.h
--- elf-bfd.h2 Nov 2004 20:45:06 -1.8
+++ elf-bfd.h16 Feb 2013 22:43:53 -
@@ -1055,8 +1055,8 @@ struct bfd_elf_section_data
 #define elf_discarded_section(sec)\
   (!bfd_is_abs_section (sec)\
&& bfd_is_abs_section ((sec)->output_section) \
-   && sec->sec_info_type != ELF_INFO_TYPE_MERGE \
-   && sec->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
+   && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE  \
+   && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)

 #define get_elf_backend_data(abfd) \
   ((const struct elf_backend_data *) (abfd)->xvec->backend_data)
Index: elflink.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elflink.c,v
retrieving revision 1.9
diff -u -p -r1.9 elflink.c
--- elflink.c24 Nov 2004 16:55:31 -1.9
+++ elflink.c16 Feb 2013 22:43:56 -
@@ -6239,6 +6239,9 @@ elf_link_output_extsym (struct elf_link_
   return TRUE;
 }

+/* Return TRUE if special handling is done for relocs in SEC against
+   symbols defined in discarded sections.  */
+
 static bfd_boolean
 elf_section_ignore_discarded_relocs (asection *sec)
 {
@@ -6261,6 +6264,26 @@ elf_section_ignore_discarded_relocs (ase
   return FALSE;
 }

+/* Return TRUE if we should complain about a reloc in SEC against a
+   symbol defined in a discarded section.  */
+
+static bfd_boolean
+elf_section_complain_discarded (asection *sec)
+{
+  if (strncmp (".stab", sec->name, 5) == 0
+  && (!sec->name[5] ||
+ (sec->name[5] == '.' && ISDIGIT (sec->name[6]
+return FALSE;
+
+  if (strcmp (".eh_frame", sec->name) == 0)
+return FALSE;
+
+  if (strcmp (".gcc_except_table", sec->name) == 0)
+return FALSE;
+
+  return TRUE;
+}
+
 /* Link an input file into the linker output file.  This function
handles all the sections and relocations of the input file at once.
This is so that we only have to read the local symbols once, and
@@ -6532,13 +6555,16 @@ elf_link_input_bfd (struct elf_final_lin
   if (!elf_section_ignore_discarded_relocs (o))
 {
   Elf_Internal_Rela *rel, *relend;
+  bfd_boolean complain = elf_section_complain_discarded (o);

   rel = internal_relocs;
   relend = rel + o->reloc_count * bed->s->int_rels_per_ext_rel;
   for ( ; rel < relend; rel++)
 {
   unsigned long r_symndx = rel->r_info >> r_sym_shift;
-  asection *sec;
+  asection **ps, *sec;
+  struct elf_link_hash_entry *h = NULL;
+  const char *sym_name;

   if (r_symndx >= locsymcount
   || (elf_bad_symtab (input_bfd)
@@ -6551,79 +6577,70 @@ elf_link_input_bfd (struct elf_final_lin
  || h->root.type == bfd_link_hash_warning)
 h = (struct elf_link_hash_entry *) h->root.u.i.link;

-  /* Complain if the definition comes from a
- discarded section.  */
-  sec = h->root.u.def.section;
-  if ((h->root.type == bfd_link_hash_defined
-   || h->root.type == bfd_link_hash_defweak)
-  && elf_discarded_section (sec))
-{
-  if ((o->flags & SEC_DEBUGGING) != 0)
-{
-  BFD_ASSERT (r_symndx != 0);
-  /* Try to preserve debug information.  */
-  if ((o->flags & SEC_DEBUGGING) != 0
-  && sec->kept_section != NULL
-  && sec->_raw_size == sec->kept_section->_raw_size)
-h->root.u.def.section
-  = sec->kept_section;
-  else
-memset (rel, 0, sizeof (*rel));
-}
-  else
-finfo->info->callbacks->error_handler
-  (LD_DEFINITION_IN_DISCARDED_SECTION,
-   _("%T: discarded in section `%s' from %s\n"),
-   h->root.root.string,
-   h->root.root.string,
-   h->root.u.def.section->name,
-   bfd_archive_filename (h->root.u.def.section->owner));
-}
-}
-  else
-{
-  sec = finfo->sections[r_symndx];
-
-  if (sec != NULL && elf_discarded_section (sec))
-