public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Symbols in SHT_NULL sections
@ 2005-02-06  7:01 Paul Brook
  2005-02-06  9:30 ` Paul Brook
  2005-02-07 12:58 ` Alan Modra
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Brook @ 2005-02-06  7:01 UTC (permalink / raw)
  To: binutils

I have some third party elf object files which contain section headers with 
type SHT_NULL, and define symbols within those sections.

It's not clear that these symbols have any meaningful interpretation, however 
they cause ld to crash. The attached patch fixes this by discarding these 
symbols.

Tested on i686-linux --enable-targets=all.
Ok?

Paul

2005-02-03  Paul Brook  <paul@codesourcery.com>

 * elflink.c (elf_link_input_bfd): Ignore symbols from null input
 sections.
Index: elflink.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elflink.c,v
retrieving revision 1.126
diff -u -p -r1.126 elflink.c
--- elflink.c	1 Feb 2005 01:11:14 -0000	1.126
+++ elflink.c	3 Feb 2005 19:32:14 -0000
@@ -6757,8 +6757,8 @@ elf_link_input_bfd (struct elf_final_lin
 	 For the benefit of the MIPS ELF linker, we check SEC_EXCLUDE
 	 as well as linker_mark.  */
       if ((isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
-	  && isec != NULL
-	  && ((! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
+	  && (isec == NULL
+	      || (! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
 	      || (! finfo->info->relocatable
 		  && (isec->flags & SEC_EXCLUDE) != 0)))
 	continue;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Symbols in SHT_NULL sections
  2005-02-06  7:01 Symbols in SHT_NULL sections Paul Brook
@ 2005-02-06  9:30 ` Paul Brook
  2005-02-07 12:58 ` Alan Modra
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Brook @ 2005-02-06  9:30 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

I have some third party elf object files which contain section headers with 
type SHT_NULL, and define symbols within those sections.

It's not clear that these symbols have any meaningful interpretation, however 
they cause ld to crash. The attached patch fixes this by discarding these 
symbols.

Tested on i686-linux --enable-targets=all.
Ok?

Paul

2005-02-03  Paul Brook  <paul@codesourcery.com>

 * elflink.c (elf_link_input_bfd): Ignore symbols from null input
 sections.

[-- Attachment #2: patch.null_section --]
[-- Type: text/x-diff, Size: 794 bytes --]

Index: elflink.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elflink.c,v
retrieving revision 1.126
diff -u -p -r1.126 elflink.c
--- elflink.c	1 Feb 2005 01:11:14 -0000	1.126
+++ elflink.c	3 Feb 2005 19:32:14 -0000
@@ -6757,8 +6757,8 @@ elf_link_input_bfd (struct elf_final_lin
 	 For the benefit of the MIPS ELF linker, we check SEC_EXCLUDE
 	 as well as linker_mark.  */
       if ((isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
-	  && isec != NULL
-	  && ((! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
+	  && (isec == NULL
+	      || (! isec->linker_mark && (isec->flags & SEC_HAS_CONTENTS) != 0)
 	      || (! finfo->info->relocatable
 		  && (isec->flags & SEC_EXCLUDE) != 0)))
 	continue;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Symbols in SHT_NULL sections
  2005-02-06  7:01 Symbols in SHT_NULL sections Paul Brook
  2005-02-06  9:30 ` Paul Brook
@ 2005-02-07 12:58 ` Alan Modra
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Modra @ 2005-02-07 12:58 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils

On Thu, Feb 03, 2005 at 08:14:40PM +0000, Paul Brook wrote:
>  * elflink.c (elf_link_input_bfd): Ignore symbols from null input
>  sections.

OK.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-02-06 22:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-06  7:01 Symbols in SHT_NULL sections Paul Brook
2005-02-06  9:30 ` Paul Brook
2005-02-07 12:58 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).