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]

tidy SHN_* definitions


Some cleanup before I tackle PR5900 in earnest.

include/
	* elf/cr16c.h (SHN_CR16C_FCOMMON): Define using SHN_LORESERVE.
	(SHN_CR16C_NCOMMON): Likewise.
	* elf/hppa.h (SHN_PARISC_ANSI_COMMON): Likewise.
	(SHN_PARISC_HUGE_COMMON): Likewise.
	* elf/ia64.h (SHN_IA_64_ANSI_COMMON): Likewise.
	(SHN_IA_64_VMS_SYMVEC): Define using SHN_LOOS.
	* elf/m32r.h (SHN_M32R_SCOMMON): Define using SHN_LORESERVE.
	* elf/mips.h (SHN_MIPS_ACOMMON, SHN_MIPS_TEXT): Likewise.
	(SHN_MIPS_DATA, SHN_MIPS_SCOMMON, SHN_MIPS_SUNDEFINED): Likewise.
	* elf/score.h (SHN_SCORE_TEXT, SHN_SCORE_DATA): Likewise.
	(SHN_SCORE_SCOMMON): Likewise.
	* elf/sparc.h (SHN_BEFORE, SHN_AFTER): Likewise.
	* elf/v850.h (SHN_V850_SCOMMON, SHN_V850_TCOMMON): Likewise.
	(SHN_V850_ZCOMMON): Likewise.
	* elf/x86-64.h (SHN_X86_64_LCOMMON): Likewise.
bfd/
	* elf-bfd.h (_bfd_elf_section_from_bfd_section): Update prototype.
	* elf.c (_bfd_elf_section_from_bfd_section): Return unsigned int,
	SHN_BAD on error.
	(_bfd_elf_print_private_bfd_data): Test for SHN_BAD result from
	_bfd_elf_section_from_bfd_section, not -1.
	(swap_out_syms): Likewise.
	* elflink.c (elf_link_add_object_symbols): Likewise.
	(bfd_elf_get_bfd_needed_list): Likewise.
	(bfd_elf_match_symbols_in_sections): Likewise.
	(elf_link_add_object_symbols): Don't bother testing for symbols
	using normal sections before calling bfd_section_from_elf_index.
	(elf_link_input_bfd, bfd_elf_final_link): Likewise.
	(bfd_elf_reloc_symbol_deleted_p): Likewise.
	* elfcode.h (elf_slurp_symbol_table): Likewise.
	* elf32-spu.c (get_sym_h): Likewise.
	* elf32-xtensa.c (get_elf_r_symndx_section): Likewise.
	* elf64-ppc.c (opd_entry_value, get_sym_h, ppc64_elf_edit_toc): Ditto.
	* elf64-sh64.c (sh_elf64_get_relocated_section_contents): Likewise.

Index: include/elf/cr16c.h
===================================================================
RCS file: /cvs/src/src/include/elf/cr16c.h,v
retrieving revision 1.2
diff -u -p -r1.2 cr16c.h
--- include/elf/cr16c.h	10 May 2005 10:21:10 -0000	1.2
+++ include/elf/cr16c.h	11 Mar 2008 22:43:32 -0000
@@ -1,5 +1,5 @@
 /* CR16C ELF support for BFD.
-   Copyright 2004 Free Software Foundation, Inc.
+   Copyright 2004, 2008 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -246,8 +246,8 @@ END_RELOC_NUMBERS (RINDEX_16C_MAX)
    values have a special meaning.  */
 
 /* Far common symbol.  */
-#define SHN_CR16C_FCOMMON	0xff00
-#define SHN_CR16C_NCOMMON	0xff01
+#define SHN_CR16C_FCOMMON	SHN_LORESERVE
+#define SHN_CR16C_NCOMMON	(SHN_LORESERVE + 1)
 
 typedef struct reloc_map
 {
Index: include/elf/hppa.h
===================================================================
RCS file: /cvs/src/src/include/elf/hppa.h,v
retrieving revision 1.21
diff -u -p -r1.21 hppa.h
--- include/elf/hppa.h	24 May 2006 11:05:42 -0000	1.21
+++ include/elf/hppa.h	11 Mar 2008 22:43:32 -0000
@@ -1,5 +1,5 @@
 /* HPPA ELF support for BFD.
-   Copyright 1993, 1994, 1995, 1998, 1999, 2000, 2005, 2006
+   Copyright 1993, 1994, 1995, 1998, 1999, 2000, 2005, 2006, 2008
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -54,11 +54,11 @@
 /* Special section indices.  */
 /* A symbol that has been declared as a tentative definition in an ANSI C
    compilation.  */
-#define SHN_PARISC_ANSI_COMMON 	0xff00
+#define SHN_PARISC_ANSI_COMMON 	SHN_LORESERVE
 
 /* A symbol that has been declared as a common block using the
    huge memory model.  */
-#define SHN_PARISC_HUGE_COMMON	0xff01
+#define SHN_PARISC_HUGE_COMMON	(SHN_LORESERVE + 1)
 
 /* Processor specific section types.  */
 
Index: include/elf/ia64.h
===================================================================
RCS file: /cvs/src/src/include/elf/ia64.h,v
retrieving revision 1.14
diff -u -p -r1.14 ia64.h
--- include/elf/ia64.h	30 Jan 2008 10:37:43 -0000	1.14
+++ include/elf/ia64.h	11 Mar 2008 22:43:32 -0000
@@ -158,11 +158,11 @@
 /* This section only used by HP-UX, The HP linker gives weak symbols
    precedence over regular common symbols.  We want common to override
    weak.  Using this common instead of SHN_COMMON does that.  */
-#define SHN_IA_64_ANSI_COMMON 0xFF00
+#define SHN_IA_64_ANSI_COMMON SHN_LORESERVE
 
 /* This section is only used by OpenVMS.  Symbol is defined in the symbol
    vector (only possible for image files).  */
-#define SHN_IA_64_VMS_SYMVEC 0xff20
+#define SHN_IA_64_VMS_SYMVEC SHN_LOOS
 
 /* IA64-specific relocation types: */
 
Index: include/elf/m32r.h
===================================================================
RCS file: /cvs/src/src/include/elf/m32r.h,v
retrieving revision 1.10
diff -u -p -r1.10 m32r.h
--- include/elf/m32r.h	20 Jul 2005 11:35:03 -0000	1.10
+++ include/elf/m32r.h	11 Mar 2008 22:43:32 -0000
@@ -1,5 +1,6 @@
 /* M32R ELF support for BFD.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2008
+   Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -80,7 +81,7 @@ END_RELOC_NUMBERS (R_M32R_max)
    values have a special meaning.  */
 
 /* Small common symbol.  */
-#define SHN_M32R_SCOMMON	0xff00
+#define SHN_M32R_SCOMMON	SHN_LORESERVE
 
 /* Processor specific section flags.  */
 
Index: include/elf/mips.h
===================================================================
RCS file: /cvs/src/src/include/elf/mips.h,v
retrieving revision 1.36
diff -u -p -r1.36 mips.h
--- include/elf/mips.h	4 Feb 2008 19:21:25 -0000	1.36
+++ include/elf/mips.h	11 Mar 2008 22:43:32 -0000
@@ -226,21 +226,21 @@ END_RELOC_NUMBERS (R_MIPS_maxext)
 
 /* Defined and allocated common symbol.  Value is virtual address.  If
    relocated, alignment must be preserved.  */
-#define SHN_MIPS_ACOMMON	0xff00
+#define SHN_MIPS_ACOMMON	SHN_LORESERVE
 
 /* Defined and allocated text symbol.  Value is virtual address.
    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
-#define SHN_MIPS_TEXT		0xff01
+#define SHN_MIPS_TEXT		(SHN_LORESERVE + 1)
 
 /* Defined and allocated data symbol.  Value is virtual address.
    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
-#define SHN_MIPS_DATA		0xff02
+#define SHN_MIPS_DATA		(SHN_LORESERVE + 2)
 
 /* Small common symbol.  */
-#define SHN_MIPS_SCOMMON	0xff03
+#define SHN_MIPS_SCOMMON	(SHN_LORESERVE + 3)
 
 /* Small undefined symbol.  */
-#define SHN_MIPS_SUNDEFINED	0xff04
+#define SHN_MIPS_SUNDEFINED	(SHN_LORESERVE + 4)
 
 /* Processor specific section types.  */
 
Index: include/elf/score.h
===================================================================
RCS file: /cvs/src/src/include/elf/score.h,v
retrieving revision 1.2
diff -u -p -r1.2 score.h
--- include/elf/score.h	19 Oct 2006 15:47:34 -0000	1.2
+++ include/elf/score.h	11 Mar 2008 22:43:32 -0000
@@ -1,5 +1,5 @@
 /* Score ELF support for BFD.
-   Copyright 2006 Free Software Foundation, Inc.
+   Copyright 2006, 2008 Free Software Foundation, Inc.
    Contributed by 
    Mei Ligang (ligang@sunnorth.com.cn)
    Pei-Lin Tsai (pltsai@sunplus.com)
@@ -44,10 +44,10 @@
 
 /* Defined and allocated common symbol.  Value is virtual address.  If
    relocated, alignment must be preserved.  */
-#define SHN_SCORE_TEXT		0xff01
-#define SHN_SCORE_DATA		0xff02
+#define SHN_SCORE_TEXT		(SHN_LORESERVE + 1)
+#define SHN_SCORE_DATA		(SHN_LORESERVE + 2)
 /* Small common symbol.  */
-#define SHN_SCORE_SCOMMON	0xff03
+#define SHN_SCORE_SCOMMON	(SHN_LORESERVE + 3)
 
 /* Processor specific section flags.  */
 
Index: include/elf/sparc.h
===================================================================
RCS file: /cvs/src/src/include/elf/sparc.h,v
retrieving revision 1.12
diff -u -p -r1.12 sparc.h
--- include/elf/sparc.h	10 May 2005 10:21:10 -0000	1.12
+++ include/elf/sparc.h	11 Mar 2008 22:43:32 -0000
@@ -1,5 +1,5 @@
 /* SPARC ELF support for BFD.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2008
    Free Software Foundation, Inc.
    By Doug Evans, Cygnus Support, <dje@cygnus.com>.
 
@@ -45,8 +45,8 @@ Foundation, Inc., 51 Franklin Street - F
 
 /* Section indices.  */
 
-#define SHN_BEFORE		0xff00		/* used with SHF_ORDERED */
-#define SHN_AFTER		0xff01		/* used with SHF_ORDERED */
+#define SHN_BEFORE	SHN_LORESERVE		/* used with SHF_ORDERED */
+#define SHN_AFTER	(SHN_LORESERVE + 1)	/* used with SHF_ORDERED */
 
 /* Section flags.  */
 
Index: include/elf/v850.h
===================================================================
RCS file: /cvs/src/src/include/elf/v850.h,v
retrieving revision 1.13
diff -u -p -r1.13 v850.h
--- include/elf/v850.h	8 Mar 2007 11:28:35 -0000	1.13
+++ include/elf/v850.h	11 Mar 2008 22:43:32 -0000
@@ -1,5 +1,5 @@
 /* V850 ELF support for BFD.
-   Copyright 1997, 1998, 2000, 2002, 2003, 2004, 2007
+   Copyright 1997, 1998, 2000, 2002, 2003, 2004, 2007, 2008
    Free Software Foundation, Inc.
    Created by Michael Meissner, Cygnus Support <meissner@cygnus.com>
 
@@ -88,13 +88,13 @@ END_RELOC_NUMBERS (R_V850_max)
    values have a special meaning.  */
 
 /* Small data area common symbol.  */
-#define SHN_V850_SCOMMON	0xff00
+#define SHN_V850_SCOMMON	SHN_LORESERVE
 
 /* Tiny data area common symbol.  */
-#define SHN_V850_TCOMMON	0xff01
+#define SHN_V850_TCOMMON	(SHN_LORESERVE + 1)
 
 /* Zero data area common symbol.  */
-#define SHN_V850_ZCOMMON	0xff02
+#define SHN_V850_ZCOMMON	(SHN_LORESERVE + 2)
 
 
 /* Processor specific section types.  */
Index: include/elf/x86-64.h
===================================================================
RCS file: /cvs/src/src/include/elf/x86-64.h,v
retrieving revision 1.10
diff -u -p -r1.10 x86-64.h
--- include/elf/x86-64.h	23 Mar 2006 08:23:09 -0000	1.10
+++ include/elf/x86-64.h	11 Mar 2008 22:43:32 -0000
@@ -1,5 +1,5 @@
 /* x86_64 ELF support for BFD.
-   Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006
+   Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2008
    Free Software Foundation, Inc.
    Contributed by Jan Hubicka <jh@suse.cz>
 
@@ -81,7 +81,7 @@ END_RELOC_NUMBERS (R_X86_64_max)
 
 /* Like SHN_COMMON but the symbol will be allocated in the .lbss
    section.  */
-#define SHN_X86_64_LCOMMON 	0xff02
+#define SHN_X86_64_LCOMMON 	(SHN_LORESERVE + 2)
 
 #define SHF_X86_64_LARGE	0x10000000
 #endif
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.260
diff -u -p -r1.260 elf-bfd.h
--- bfd/elf-bfd.h	27 Feb 2008 17:06:06 -0000	1.260
+++ bfd/elf-bfd.h	11 Mar 2008 22:42:59 -0000
@@ -1636,7 +1636,7 @@ extern void _bfd_elf_swap_versym_in
 extern void _bfd_elf_swap_versym_out
   (bfd *, const Elf_Internal_Versym *, Elf_External_Versym *);
 
-extern int _bfd_elf_section_from_bfd_section
+extern unsigned int _bfd_elf_section_from_bfd_section
   (bfd *, asection *);
 extern char *bfd_elf_string_from_elf_section
   (bfd *, unsigned, unsigned);
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.436
diff -u -p -r1.436 elf.c
--- bfd/elf.c	27 Feb 2008 17:06:06 -0000	1.436
+++ bfd/elf.c	11 Mar 2008 22:43:05 -0000
@@ -1180,7 +1180,7 @@ _bfd_elf_print_private_bfd_data (bfd *ab
   s = bfd_get_section_by_name (abfd, ".dynamic");
   if (s != NULL)
     {
-      int elfsec;
+      unsigned int elfsec;
       unsigned long shlink;
       bfd_byte *extdyn, *extdynend;
       size_t extdynsize;
@@ -1192,7 +1192,7 @@ _bfd_elf_print_private_bfd_data (bfd *ab
 	goto error_return;
 
       elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
-      if (elfsec == -1)
+      if (elfsec == SHN_BAD)
 	goto error_return;
       shlink = elf_elfsections (abfd)[elfsec]->sh_link;
 
@@ -4996,11 +4996,11 @@ _bfd_elf_write_corefile_contents (bfd *a
 
 /* Given a section, search the header to find them.  */
 
-int
+unsigned int
 _bfd_elf_section_from_bfd_section (bfd *abfd, struct bfd_section *asect)
 {
   const struct elf_backend_data *bed;
-  int index;
+  unsigned int index;
 
   if (elf_section_data (asect) != NULL
       && elf_section_data (asect)->this_idx != 0)
@@ -5013,7 +5013,7 @@ _bfd_elf_section_from_bfd_section (bfd *
   else if (bfd_is_und_section (asect))
     index = SHN_UNDEF;
   else
-    index = -1;
+    index = SHN_BAD;
 
   bed = get_elf_backend_data (abfd);
   if (bed->elf_backend_section_from_bfd_section)
@@ -5024,7 +5024,7 @@ _bfd_elf_section_from_bfd_section (bfd *
 	return retval;
     }
 
-  if (index == -1)
+  if (index == SHN_BAD)
     bfd_set_error (bfd_error_nonrepresentable_section);
 
   return index;
@@ -6277,7 +6277,7 @@ swap_out_syms (bfd *abfd,
       else
 	{
 	  asection *sec = syms[idx]->section;
-	  int shndx;
+	  unsigned int shndx;
 
 	  if (sec->output_section)
 	    {
@@ -6324,7 +6324,7 @@ swap_out_syms (bfd *abfd,
 	    {
 	      shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
 
-	      if (shndx == -1)
+	      if (shndx == SHN_BAD)
 		{
 		  asection *sec2;
 
@@ -6348,7 +6348,7 @@ Unable to find equivalent output section
 		    }
 
 		  shndx = _bfd_elf_section_from_bfd_section (abfd, sec2);
-		  BFD_ASSERT (shndx != -1);
+		  BFD_ASSERT (shndx != SHN_BAD);
 		}
 	    }
 
Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.32
diff -u -p -r1.32 elf32-spu.c
--- bfd/elf32-spu.c	11 Mar 2008 09:30:50 -0000	1.32
+++ bfd/elf32-spu.c	11 Mar 2008 22:43:06 -0000
@@ -409,14 +409,7 @@ get_sym_h (struct elf_link_hash_entry **
 	*symp = sym;
 
       if (symsecp != NULL)
-	{
-	  asection *symsec = NULL;
-	  if ((sym->st_shndx != SHN_UNDEF
-	       && sym->st_shndx < SHN_LORESERVE)
-	      || sym->st_shndx > SHN_HIRESERVE)
-	    symsec = bfd_section_from_elf_index (ibfd, sym->st_shndx);
-	  *symsecp = symsec;
-	}
+	*symsecp = bfd_section_from_elf_index (ibfd, sym->st_shndx);
     }
 
   return TRUE;
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.108
diff -u -p -r1.108 elf32-xtensa.c
--- bfd/elf32-xtensa.c	20 Feb 2008 17:42:35 -0000	1.108
+++ bfd/elf32-xtensa.c	11 Mar 2008 22:43:10 -0000
@@ -9503,15 +9503,12 @@ get_elf_r_symndx_section (bfd *abfd, uns
 
       if (section_index == SHN_UNDEF)
 	target_sec = bfd_und_section_ptr;
-      else if (section_index > 0 && section_index < SHN_LORESERVE)
-	target_sec = bfd_section_from_elf_index (abfd, section_index);
       else if (section_index == SHN_ABS)
 	target_sec = bfd_abs_section_ptr;
       else if (section_index == SHN_COMMON)
 	target_sec = bfd_com_section_ptr;
       else
-	/* Who knows?  */
-	target_sec = NULL;
+	target_sec = bfd_section_from_elf_index (abfd, section_index);
     }
   else
     {
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.278
diff -u -p -r1.278 elf64-ppc.c
--- bfd/elf64-ppc.c	1 Mar 2008 06:52:32 -0000	1.278
+++ bfd/elf64-ppc.c	11 Mar 2008 22:43:16 -0000
@@ -5026,11 +5026,7 @@ opd_entry_value (asection *opd_sec,
 
 		  sym += symndx;
 		  val = sym->st_value;
-		  sec = NULL;
-		  if ((sym->st_shndx != SHN_UNDEF
-		       && sym->st_shndx < SHN_LORESERVE)
-		      || sym->st_shndx > SHN_HIRESERVE)
-		    sec = bfd_section_from_elf_index (opd_bfd, sym->st_shndx);
+		  sec = bfd_section_from_elf_index (opd_bfd, sym->st_shndx);
 		  BFD_ASSERT ((sec->flags & SEC_MERGE) == 0);
 		}
 	      else
@@ -6060,14 +6056,7 @@ get_sym_h (struct elf_link_hash_entry **
 	*symp = sym;
 
       if (symsecp != NULL)
-	{
-	  asection *symsec = NULL;
-	  if ((sym->st_shndx != SHN_UNDEF
-	       && sym->st_shndx < SHN_LORESERVE)
-	      || sym->st_shndx > SHN_HIRESERVE)
-	    symsec = bfd_section_from_elf_index (ibfd, sym->st_shndx);
-	  *symsecp = symsec;
-	}
+	*symsecp = bfd_section_from_elf_index (ibfd, sym->st_shndx);
 
       if (tls_maskp != NULL)
 	{
@@ -7577,10 +7566,7 @@ ppc64_elf_edit_toc (bfd *obfd ATTRIBUTE_
 	      for (sym = local_syms;
 		   sym < local_syms + symtab_hdr->sh_info;
 		   ++sym)
-		if (sym->st_shndx != SHN_UNDEF
-		    && (sym->st_shndx < SHN_LORESERVE
-			|| sym->st_shndx > SHN_HIRESERVE)
-		    && sym->st_value != 0
+		if (sym->st_value != 0
 		    && bfd_section_from_elf_index (ibfd, sym->st_shndx) == toc)
 		  {
 		    if (skip[sym->st_value >> 3] != (unsigned long) -1)
Index: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.80
diff -u -p -r1.80 elf64-sh64.c
--- bfd/elf64-sh64.c	28 Sep 2007 08:43:45 -0000	1.80
+++ bfd/elf64-sh64.c	11 Mar 2008 22:43:17 -0000
@@ -1,5 +1,5 @@
 /* SuperH SH64-specific support for 64-bit ELF
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -2195,17 +2195,12 @@ sh_elf64_get_relocated_section_contents 
 
 	  if (isymp->st_shndx == SHN_UNDEF)
 	    isec = bfd_und_section_ptr;
-	  else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
-	    isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
 	  else if (isymp->st_shndx == SHN_ABS)
 	    isec = bfd_abs_section_ptr;
 	  else if (isymp->st_shndx == SHN_COMMON)
 	    isec = bfd_com_section_ptr;
 	  else
-	    {
-	      /* Who knows?  */
-	      isec = NULL;
-	    }
+	    isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
 
 	  *secpp = isec;
 	}
Index: bfd/elfcode.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcode.h,v
retrieving revision 1.88
diff -u -p -r1.88 elfcode.h
--- bfd/elfcode.h	24 Dec 2007 16:55:39 -0000	1.88
+++ bfd/elfcode.h	11 Mar 2008 22:43:18 -0000
@@ -1,6 +1,6 @@
 /* ELF executable support for BFD.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
 
    Written by Fred Fish @ Cygnus Support, from information published
@@ -1270,19 +1270,6 @@ elf_slurp_symbol_table (bfd *abfd, asymb
 	    {
 	      sym->symbol.section = bfd_und_section_ptr;
 	    }
-	  else if (isym->st_shndx < SHN_LORESERVE
-		   || isym->st_shndx > SHN_HIRESERVE)
-	    {
-	      sym->symbol.section = bfd_section_from_elf_index (abfd,
-								isym->st_shndx);
-	      if (sym->symbol.section == NULL)
-		{
-		  /* This symbol is in a section for which we did not
-		     create a BFD section.  Just use bfd_abs_section,
-		     although it is wrong.  FIXME.  */
-		  sym->symbol.section = bfd_abs_section_ptr;
-		}
-	    }
 	  else if (isym->st_shndx == SHN_ABS)
 	    {
 	      sym->symbol.section = bfd_abs_section_ptr;
@@ -1297,7 +1284,17 @@ elf_slurp_symbol_table (bfd *abfd, asymb
 	      sym->symbol.value = isym->st_size;
 	    }
 	  else
-	    sym->symbol.section = bfd_abs_section_ptr;
+	    {
+	      sym->symbol.section
+		= bfd_section_from_elf_index (abfd, isym->st_shndx);
+	      if (sym->symbol.section == NULL)
+		{
+		  /* This symbol is in a section for which we did not
+		     create a BFD section.  Just use bfd_abs_section,
+		     although it is wrong.  FIXME.  */
+		  sym->symbol.section = bfd_abs_section_ptr;
+		}
+	    }
 
 	  /* If this is a relocatable file, then the symbol value is
 	     already section relative.  */
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.299
diff -u -p -r1.299 elflink.c
--- bfd/elflink.c	2 Mar 2008 22:26:09 -0000	1.299
+++ bfd/elflink.c	11 Mar 2008 22:43:25 -0000
@@ -3472,14 +3472,14 @@ elf_link_add_object_symbols (bfd *abfd, 
 	{
 	  bfd_byte *dynbuf;
 	  bfd_byte *extdyn;
-	  int elfsec;
+	  unsigned int elfsec;
 	  unsigned long shlink;
 
 	  if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
 	    goto error_free_dyn;
 
 	  elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
-	  if (elfsec == -1)
+	  if (elfsec == SHN_BAD)
 	    goto error_free_dyn;
 	  shlink = elf_elfsections (abfd)[elfsec]->sh_link;
 
@@ -3820,8 +3820,16 @@ elf_link_add_object_symbols (bfd *abfd, 
 
       if (isym->st_shndx == SHN_UNDEF)
 	sec = bfd_und_section_ptr;
-      else if (isym->st_shndx < SHN_LORESERVE
-	       || isym->st_shndx > SHN_HIRESERVE)
+      else if (isym->st_shndx == SHN_ABS)
+	sec = bfd_abs_section_ptr;
+      else if (isym->st_shndx == SHN_COMMON)
+	{
+	  sec = bfd_com_section_ptr;
+	  /* What ELF calls the size we call the value.  What ELF
+	     calls the value we call the alignment.  */
+	  value = isym->st_size;
+	}
+      else
 	{
 	  sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
 	  if (sec == NULL)
@@ -3836,19 +3844,6 @@ elf_link_add_object_symbols (bfd *abfd, 
 	  else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
 	    value -= sec->vma;
 	}
-      else if (isym->st_shndx == SHN_ABS)
-	sec = bfd_abs_section_ptr;
-      else if (isym->st_shndx == SHN_COMMON)
-	{
-	  sec = bfd_com_section_ptr;
-	  /* What ELF calls the size we call the value.  What ELF
-	     calls the value we call the alignment.  */
-	  value = isym->st_size;
-	}
-      else
-	{
-	  /* Leave it up to the processor backend.  */
-	}
 
       name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
 					      isym->st_name);
@@ -6750,7 +6745,7 @@ bfd_elf_get_bfd_needed_list (bfd *abfd,
 {
   asection *s;
   bfd_byte *dynbuf = NULL;
-  int elfsec;
+  unsigned int elfsec;
   unsigned long shlink;
   bfd_byte *extdyn, *extdynend;
   size_t extdynsize;
@@ -6770,7 +6765,7 @@ bfd_elf_get_bfd_needed_list (bfd *abfd,
     goto error_return;
 
   elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
-  if (elfsec == -1)
+  if (elfsec == SHN_BAD)
     goto error_return;
 
   shlink = elf_elfsections (abfd)[elfsec]->sh_link;
@@ -6942,7 +6937,7 @@ bfd_elf_match_symbols_in_sections (asect
   Elf_Internal_Sym *isym, *isymend;
   struct elf_symbol *symtable1 = NULL, *symtable2 = NULL;
   bfd_size_type count1, count2, i;
-  int shndx1, shndx2;
+  unsigned int shndx1, shndx2;
   bfd_boolean result;
 
   bfd1 = sec1->owner;
@@ -6958,7 +6953,7 @@ bfd_elf_match_symbols_in_sections (asect
 
   shndx1 = _bfd_elf_section_from_bfd_section (bfd1, sec1);
   shndx2 = _bfd_elf_section_from_bfd_section (bfd2, sec2);
-  if (shndx1 == -1 || shndx2 == -1)
+  if (shndx1 == SHN_BAD || shndx2 == SHN_BAD)
     return FALSE;
 
   bed1 = get_elf_backend_data (bfd1);
@@ -7015,9 +7010,9 @@ bfd_elf_match_symbols_in_sections (asect
       while (lo < hi)
 	{
 	  mid = (lo + hi) / 2;
-	  if ((unsigned int) shndx1 < ssymbuf1[mid].st_shndx)
+	  if (shndx1 < ssymbuf1[mid].st_shndx)
 	    hi = mid;
-	  else if ((unsigned int) shndx1 > ssymbuf1[mid].st_shndx)
+	  else if (shndx1 > ssymbuf1[mid].st_shndx)
 	    lo = mid + 1;
 	  else
 	    {
@@ -7034,9 +7029,9 @@ bfd_elf_match_symbols_in_sections (asect
       while (lo < hi)
 	{
 	  mid = (lo + hi) / 2;
-	  if ((unsigned int) shndx2 < ssymbuf2[mid].st_shndx)
+	  if (shndx2 < ssymbuf2[mid].st_shndx)
 	    hi = mid;
-	  else if ((unsigned int) shndx2 > ssymbuf2[mid].st_shndx)
+	  else if (shndx2 > ssymbuf2[mid].st_shndx)
 	    lo = mid + 1;
 	  else
 	    {
@@ -7099,12 +7094,12 @@ bfd_elf_match_symbols_in_sections (asect
   /* Count definitions in the section.  */
   count1 = 0;
   for (isym = isymbuf1, isymend = isym + symcount1; isym < isymend; isym++)
-    if (isym->st_shndx == (unsigned int) shndx1)
+    if (isym->st_shndx == shndx1)
       symtable1[count1++].u.isym = isym;
 
   count2 = 0;
   for (isym = isymbuf2, isymend = isym + symcount2; isym < isymend; isym++)
-    if (isym->st_shndx == (unsigned int) shndx2)
+    if (isym->st_shndx == shndx2)
       symtable2[count2++].u.isym = isym;
 
   if (count1 == 0 || count2 == 0 || count1 != count2)
@@ -8904,28 +8899,26 @@ elf_link_input_bfd (struct elf_final_lin
 
       if (isym->st_shndx == SHN_UNDEF)
 	isec = bfd_und_section_ptr;
-      else if (isym->st_shndx < SHN_LORESERVE
-	       || isym->st_shndx > SHN_HIRESERVE)
-	{
-	  isec = bfd_section_from_elf_index (input_bfd, isym->st_shndx);
-	  if (isec
-	      && isec->sec_info_type == ELF_INFO_TYPE_MERGE
-	      && ELF_ST_TYPE (isym->st_info) != STT_SECTION)
-	    isym->st_value =
-	      _bfd_merged_section_offset (output_bfd, &isec,
-					  elf_section_data (isec)->sec_info,
-					  isym->st_value);
-	}
       else if (isym->st_shndx == SHN_ABS)
 	isec = bfd_abs_section_ptr;
       else if (isym->st_shndx == SHN_COMMON)
 	isec = bfd_com_section_ptr;
       else
 	{
-	  /* Don't attempt to output symbols with st_shnx in the
-	     reserved range other than SHN_ABS and SHN_COMMON.  */
-	  *ppsection = NULL;
-	  continue;
+	  isec = bfd_section_from_elf_index (input_bfd, isym->st_shndx);
+	  if (isec == NULL)
+	    {
+	      /* Don't attempt to output symbols with st_shnx in the
+		 reserved range other than SHN_ABS and SHN_COMMON.  */
+	      *ppsection = NULL;
+	      continue;
+	    }
+	  else if (isec->sec_info_type == ELF_INFO_TYPE_MERGE
+		   && ELF_ST_TYPE (isym->st_info) != STT_SECTION)
+	    isym->st_value =
+	      _bfd_merged_section_offset (output_bfd, &isec,
+					  elf_section_data (isec)->sec_info,
+					  isym->st_value);
 	}
 
       *ppsection = isec;
@@ -10491,13 +10484,10 @@ bfd_elf_final_link (bfd *abfd, struct bf
 		 the original st_name with the dynstr_index.  */
 	      sym = e->isym;
 
-	      if (e->isym.st_shndx != SHN_UNDEF
-		  && (e->isym.st_shndx < SHN_LORESERVE
-		      || e->isym.st_shndx > SHN_HIRESERVE))
+	      s = bfd_section_from_elf_index (e->input_bfd,
+					      e->isym.st_shndx);
+	      if (s != NULL)
 		{
-		  s = bfd_section_from_elf_index (e->input_bfd,
-						  e->isym.st_shndx);
-
 		  sym.st_shndx =
 		    elf_section_data (s->output_section)->this_idx;
 		  if (! check_dynsym (abfd, &sym))
@@ -11864,12 +11854,9 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma 
 
 	  /* Need to: get the symbol; get the section.  */
 	  isym = &rcookie->locsyms[r_symndx];
-	  if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
-	    {
-	      isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx);
-	      if (isec != NULL && elf_discarded_section (isec))
-		return TRUE;
-	    }
+	  isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx);
+	  if (isec != NULL && elf_discarded_section (isec))
+	    return TRUE;
 	}
       return FALSE;
     }

-- 
Alan Modra
Australia Development Lab, IBM


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