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]

RFC: PATCH: Avoid reading debug symbols


Hi,

"ld -s" and strip will remove debug symbols. This patch adds
strip_debug to bfd so that we can
avoid reading debug symbols which will be removed in the final output.
Does this patch
make senses?

Thanks.

H.J.
bfd/

2008-03-18  H.J. Lu  <hongjiu.lu@intel.com>

	* bfd.c (bfd): Add strip_debug.

	* elf-bfd.h (bfd_elf_get_elf_syms): Updated.

	* elf.c (INITIAL_SYMBOL_TABLE_SIZE): New.
	(bfd_elf_get_elf_syms): Updated to check strip_debug and return
	symbol count in a pointer argument.
	(group_signature): Updated bfd_elf_get_elf_syms call.
	(bfd_section_from_r_symndx): Likewise.
	* elf32-arm.c (bfd_elf32_arm_init_maps): Likewise.
	* elf32-avr.c (elf32_avr_relax_delete_bytes): Likewise.
	(elf32_avr_relax_section): Likewise.
	(elf32_avr_get_relocated_section_contents): Likewise.
	(get_local_syms): Likewise.
	* elf32-bfin.c (bfd_bfin_elf32_create_embedded_relocs): Likewise.
	* elf32-cr16.c (elf32_cr16_get_relocated_section_content): Likewise.
	(elf32_cr16_relax_section): Likewise.
	* elf32-crx.c (elf32_crx_get_relocated_section_contents): Likewise.
	(elf32_crx_relax_section): Likewise.
	* elf32-h8300.c (elf32_h8_relax_section): Likewise.
	(elf32_h8_get_relocated_section_contents): Likewise.
	* elf32-hppa.c (get_local_syms): Likewise.
	* elf32-ip2k.c (ip2k_elf_relax_section): Likewise.
	* elf32-m32c.c (dump_symtab): Likewise.
	(m32c_elf_relax_plt_section): Likewise.
	* elf32-m68hc11.c (m68hc11_elf_relax_section): Likewise. 
	* elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise.
	* elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Likewise.
	* elf32-msp430.c (msp430_elf_relax_section): Likewise.
	* elf32-ppc.c (ppc_elf_tls_optimize): Likewise.
	(ppc_elf_relax_section): Likewise.
	* elf32-sh.c (sh_elf_relax_section): Likewise.
	(sh_elf_get_relocated_section_contents): Likewise.
	* elf32-spu.c (get_sym_h): Likewise.
	(discover_functions): Likewise.
	* elf32-v850.c (v850_elf_relax_section): Likewise.
	* elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise.
	* elf32-xtensa.c (retrieve_local_syms): Likewise.
	* elf64-alpha.c (elf64_alpha_relax_section): Likewise.
	* elf64-hppa.c (elf64_hppa_check_relocs): Likewise.
	* elf64-mmix.c (mmix_elf_relax_section): Likewise.
	* elf64-ppc.c (opd_entry_value): Likewise.
	(get_sym_h): Likewise.
	* elf64-sh64.c (sh_elf64_get_relocated_section_contents): Likewise.
	* elfxx-ia64.c (elfNN_ia64_relax_section): Likewise.
	* elfxx-mips.c (_bfd_mips_relax_section): Likewise.
	* elf-m10200.c (mn10200_elf_relax_section): Likewise.
	(mn10200_elf_get_relocated_section_conten): Likewise.
	* elf-m10300.c (mn10300_elf_check_relocs): Likewise.
	(mn10300_elf_relax_section): Likewise.
	(mn10300_elf_get_relocated_section_conten): Likewise.
	* elfcode.h (elf_slurp_symbol_table): Likewise.
	* elflink.c (bfd_elf_link_record_local_dynamic_symbol): Likewise.
	(elf_link_is_defined_archive_symbol): Likewise.
	(elf_link_add_object_symbols): Likewise.
	(bfd_elf_match_symbols_in_sections): Likewise.
	(elf_link_check_versioned_symbol): Likewise.
	(elf_link_input_bfd): Likewise.
	(init_reloc_cookie): Likewise.

	* opncls.c (_bfd_new_bfd): Set strip_debug to false.
	(bfd_make_readable): Likewise.

binutils/

	* objcopy.c (copy_file): Set ibfd->strip_debug.

2008-03-18  H.J. Lu  <hongjiu.lu@intel.com>

ld/

2008-03-18  H.J. Lu  <hongjiu.lu@intel.com>

	* ldfile.c (ldfile_try_open_bfd): Set entry->the_bfd->strip_debug.

Index: ld/ldfile.c
===================================================================
--- ld/ldfile.c	(revision 1859)
+++ ld/ldfile.c	(working copy)
@@ -146,6 +146,9 @@ ldfile_try_open_bfd (const char *attempt
       return FALSE;
     }
 
+  entry->the_bfd->strip_debug = (link_info.strip == strip_debugger
+				 || link_info.strip == strip_all);
+
   /* If we are searching for this file, see if the architecture is
      compatible with the output file.  If it isn't, keep searching.
      If we can't open the file as an object file, stop the search
Index: binutils/objcopy.c
===================================================================
--- binutils/objcopy.c	(revision 1859)
+++ binutils/objcopy.c	(working copy)
@@ -2004,6 +2004,11 @@ copy_file (const char *input_filename, c
       return;
     }
 
+  ibfd->strip_debug = (strip_symbols == STRIP_DEBUG
+		       || strip_symbols == STRIP_UNNEEDED
+		       || strip_symbols == STRIP_ALL
+		       || discard_locals == LOCALS_ALL);
+
   if (bfd_check_format (ibfd, bfd_archive))
     {
       bfd_boolean force_output_target;
Index: bfd/elf32-m68hc11.c
===================================================================
--- bfd/elf32-m68hc11.c	(revision 1859)
+++ bfd/elf32-m68hc11.c	(working copy)
@@ -807,7 +807,7 @@ m68hc11_elf_relax_section (bfd *abfd, as
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
Index: bfd/elf.c
===================================================================
--- bfd/elf.c	(revision 1859)
+++ bfd/elf.c	(working copy)
@@ -332,6 +332,10 @@ bfd_elf_string_from_elf_section (bfd *ab
   return ((char *) hdr->contents) + strindex;
 }
 
+#ifndef INITIAL_SYMBOL_TABLE_SIZE
+#define INITIAL_SYMBOL_TABLE_SIZE 1000000
+#endif
+
 /* Read and convert symbols to internal format.
    SYMCOUNT specifies the number of symbols to read, starting from
    symbol SYMOFFSET.  If any of INTSYM_BUF, EXTSYM_BUF or EXTSHNDX_BUF
@@ -343,28 +347,33 @@ bfd_elf_string_from_elf_section (bfd *ab
 Elf_Internal_Sym *
 bfd_elf_get_elf_syms (bfd *ibfd,
 		      Elf_Internal_Shdr *symtab_hdr,
-		      size_t symcount,
+		      size_t symcount_ext,
 		      size_t symoffset,
 		      Elf_Internal_Sym *intsym_buf,
 		      void *extsym_buf,
-		      Elf_External_Sym_Shndx *extshndx_buf)
+		      Elf_External_Sym_Shndx *extshndx_buf,
+		      size_t *symcount_p)
 {
   Elf_Internal_Shdr *shndx_hdr;
   void *alloc_ext;
   const bfd_byte *esym;
+  const bfd_byte *esymend;
   Elf_External_Sym_Shndx *alloc_extshndx;
   Elf_External_Sym_Shndx *shndx;
   Elf_Internal_Sym *isym;
   Elf_Internal_Sym *isymend;
+  Elf_Internal_Sym sym;
   const struct elf_backend_data *bed;
   size_t extsym_size;
   bfd_size_type amt;
   file_ptr pos;
+  size_t symcount_int, symcount_max;
+  bfd_boolean strip_debug;
 
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
     abort ();
 
-  if (symcount == 0)
+  if (symcount_ext == 0)
     return intsym_buf;
 
   /* Normal syms might have section extension entries.  */
@@ -377,11 +386,11 @@ bfd_elf_get_elf_syms (bfd *ibfd,
   alloc_extshndx = NULL;
   bed = get_elf_backend_data (ibfd);
   extsym_size = bed->s->sizeof_sym;
-  amt = symcount * extsym_size;
+  amt = symcount_ext * extsym_size;
   pos = symtab_hdr->sh_offset + symoffset * extsym_size;
   if (extsym_buf == NULL)
     {
-      alloc_ext = bfd_malloc2 (symcount, extsym_size);
+      alloc_ext = bfd_malloc2 (symcount_ext, extsym_size);
       extsym_buf = alloc_ext;
     }
   if (extsym_buf == NULL
@@ -396,11 +405,11 @@ bfd_elf_get_elf_syms (bfd *ibfd,
     extshndx_buf = NULL;
   else
     {
-      amt = symcount * sizeof (Elf_External_Sym_Shndx);
+      amt = symcount_ext * sizeof (Elf_External_Sym_Shndx);
       pos = shndx_hdr->sh_offset + symoffset * sizeof (Elf_External_Sym_Shndx);
       if (extshndx_buf == NULL)
 	{
-	  alloc_extshndx = bfd_malloc2 (symcount,
+	  alloc_extshndx = bfd_malloc2 (symcount_ext,
 					sizeof (Elf_External_Sym_Shndx));
 	  extshndx_buf = alloc_extshndx;
 	}
@@ -415,24 +424,87 @@ bfd_elf_get_elf_syms (bfd *ibfd,
 
   if (intsym_buf == NULL)
     {
-      intsym_buf = bfd_malloc2 (symcount, sizeof (Elf_Internal_Sym));
+      if (symcount_p && symcount_ext > INITIAL_SYMBOL_TABLE_SIZE)
+	{
+	  symcount_max = INITIAL_SYMBOL_TABLE_SIZE;
+	  intsym_buf = bfd_malloc2 (symcount_max, sizeof (Elf_Internal_Sym));
+	}
+      else
+	{
+	  symcount_max = 0;
+	  intsym_buf = bfd_malloc2 (symcount_ext, sizeof (Elf_Internal_Sym));
+	}
       if (intsym_buf == NULL)
 	goto out;
     }
+  else
+    symcount_max = 0;
 
   /* Convert the symbols to internal form.  */
-  isymend = intsym_buf + symcount;
-  for (esym = extsym_buf, isym = intsym_buf, shndx = extshndx_buf;
-       isym < isymend;
-       esym += extsym_size, isym++, shndx = shndx != NULL ? shndx + 1 : NULL)
-    if (!(*bed->s->swap_symbol_in) (ibfd, esym, shndx, isym))
-      {
-	symoffset += (esym - (bfd_byte *) extsym_buf) / extsym_size;
-	(*_bfd_error_handler) (_("%B symbol number %lu references "
-				 "nonexistent SHT_SYMTAB_SHNDX section"),
-			       ibfd, (unsigned long) symoffset);
-	intsym_buf = NULL;
-	goto out;
+  if (symcount_max)
+    {
+      strip_debug = ibfd->strip_debug;
+      esymend = extsym_buf + extsym_size * symcount_ext; 
+      symcount_int = 0;
+      for (esym = extsym_buf, isym = intsym_buf, shndx = extshndx_buf;
+	   esym < esymend;
+	   esym += extsym_size, shndx = shndx != NULL ? shndx + 1 : NULL)
+	{
+	  if (!(*bed->s->swap_symbol_in) (ibfd, esym, shndx, &sym))
+	    {
+	      symoffset += (esym - (bfd_byte *) extsym_buf) / extsym_size;
+	      (*_bfd_error_handler) (_("%B symbol number %lu references "
+				       "nonexistent SHT_SYMTAB_SHNDX section"),
+				     ibfd, (unsigned long) symoffset);
+	      intsym_buf = NULL;
+	      goto out;
+	    }
+
+	  /* Skip debug symbols if they will be removed later.  */
+	  if (strip_debug
+	      && (sym.st_shndx > SHN_UNDEF
+		  && sym.st_shndx < SHN_LORESERVE))
+	    {
+	      Elf_Internal_Shdr *hdr
+		= elf_elfsections (ibfd)[sym.st_shndx];
+	      if (hdr->bfd_section
+		  && (hdr->bfd_section->flags & SEC_DEBUGGING))
+		continue;
+	    }
+
+	  if (symcount_int == symcount_max)
+	    {
+	      BFD_ASSERT (symcount_max < symcount_ext);
+	      symcount_max += symcount_max;
+	      if (symcount_max >= symcount_ext)
+		symcount_max = symcount_ext;
+	      intsym_buf = bfd_realloc_or_free (intsym_buf,
+						symcount_max * sizeof (Elf_Internal_Sym));
+	      if (intsym_buf == NULL)
+		goto out;
+	      isym = intsym_buf + symcount_int;
+	    }
+	  *isym++ = sym;
+	  symcount_int++;
+	}
+      *symcount_p = symcount_int;
+    }
+  else
+    {
+      isymend = intsym_buf + symcount_ext; 
+      for (esym = extsym_buf, isym = intsym_buf, shndx = extshndx_buf;
+	   isym < isymend;
+	  esym += extsym_size, isym++,
+	  shndx = shndx != NULL ? shndx + 1 : NULL)
+	if (!(*bed->s->swap_symbol_in) (ibfd, esym, shndx, isym))
+	  {
+	    symoffset += (esym - (bfd_byte *) extsym_buf) / extsym_size;
+	    (*_bfd_error_handler) (_("%B symbol number %lu references "
+				     "nonexistent SHT_SYMTAB_SHNDX section"),
+				   ibfd, (unsigned long) symoffset);
+	    intsym_buf = NULL;
+	    goto out;
+	  }
       }
 
  out:
@@ -504,7 +576,7 @@ group_signature (bfd *abfd, Elf_Internal
   /* Go read the symbol.  */
   hdr = &elf_tdata (abfd)->symtab_hdr;
   if (bfd_elf_get_elf_syms (abfd, hdr, 1, ghdr->sh_info,
-			    &isym, esym, &eshndx) == NULL)
+			    &isym, esym, &eshndx, NULL) == NULL)
     return NULL;
 
   return bfd_elf_sym_name (abfd, hdr, &isym, NULL);
@@ -1972,7 +2044,7 @@ bfd_section_from_r_symndx (bfd *abfd,
 
       symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
       if (bfd_elf_get_elf_syms (abfd, symtab_hdr, 1, r_symndx,
-				&isym, esym, &eshndx) == NULL)
+				&isym, esym, &eshndx, NULL) == NULL)
 	return NULL;
 
       if (cache->abfd != abfd)
Index: bfd/elf32-m68hc1x.c
===================================================================
--- bfd/elf32-m68hc1x.c	(revision 1859)
+++ bfd/elf32-m68hc1x.c	(working copy)
@@ -360,7 +360,7 @@ elf32_m68hc11_size_stubs (bfd *output_bf
 	{
 	  local_syms = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					     symtab_hdr->sh_info, 0,
-					     NULL, NULL, NULL);
+					     NULL, NULL, NULL, NULL);
 	  /* Cache them for elf_link_input_bfd.  */
 	  symtab_hdr->contents = (unsigned char *) local_syms;
 	}
Index: bfd/elf32-h8300.c
===================================================================
--- bfd/elf32-h8300.c	(revision 1859)
+++ bfd/elf32-h8300.c	(working copy)
@@ -755,7 +755,7 @@ elf32_h8_relax_section (bfd *abfd, asect
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
@@ -1456,7 +1456,7 @@ elf32_h8_get_relocated_section_contents 
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
Index: bfd/elf32-ppc.c
===================================================================
--- bfd/elf32-ppc.c	(revision 1859)
+++ bfd/elf32-ppc.c	(working copy)
@@ -4233,7 +4233,8 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUT
 			  if (locsyms == NULL)
 			    locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
 							    symtab_hdr->sh_info,
-							    0, NULL, NULL, NULL);
+							    0, NULL, NULL,
+							    NULL, NULL);
 			  if (locsyms == NULL)
 			    {
 			      if (elf_section_data (sec)->relocs != relstart)
@@ -5353,7 +5354,7 @@ ppc_elf_relax_section (bfd *abfd,
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == 0)
 		goto error_return;
 	    }
Index: bfd/elf32-msp430.c
===================================================================
--- bfd/elf32-msp430.c	(revision 1859)
+++ bfd/elf32-msp430.c	(working copy)
@@ -969,7 +969,7 @@ msp430_elf_relax_section (bfd * abfd, as
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
Index: bfd/elf32-hppa.c
===================================================================
--- bfd/elf32-hppa.c	(revision 1859)
+++ bfd/elf32-hppa.c	(working copy)
@@ -2738,7 +2738,7 @@ get_local_syms (bfd *output_bfd, bfd *in
 	{
 	  local_syms = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					     symtab_hdr->sh_info, 0,
-					     NULL, NULL, NULL);
+					     NULL, NULL, NULL, NULL);
 	  /* Cache them for elf_link_input_bfd.  */
 	  symtab_hdr->contents = (unsigned char *) local_syms;
 	}
Index: bfd/elf32-spu.c
===================================================================
--- bfd/elf32-spu.c	(revision 1859)
+++ bfd/elf32-spu.c	(working copy)
@@ -394,7 +394,7 @@ get_sym_h (struct elf_link_hash_entry **
 	      if ((unsigned char **) locsymsp == &symtab_hdr->contents)
 		symcount = symtab_hdr->sh_size / symtab_hdr->sh_entsize;
 	      locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, symcount, 0,
-					      NULL, NULL, NULL);
+					      NULL, NULL, NULL, NULL);
 	    }
 	  if (locsyms == NULL)
 	    return FALSE;
@@ -2181,7 +2181,7 @@ discover_functions (bfd *output_bfd, str
       if (syms == NULL)
 	{
 	  syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, symcount, 0,
-				       NULL, NULL, NULL);
+				       NULL, NULL, NULL, NULL);
 	  symtab_hdr->contents = (void *) syms;
 	  if (syms == NULL)
 	    return FALSE;
Index: bfd/elf64-ppc.c
===================================================================
--- bfd/elf64-ppc.c	(revision 1859)
+++ bfd/elf64-ppc.c	(working copy)
@@ -5018,7 +5018,8 @@ opd_entry_value (asection *opd_sec,
 		    {
 		      sym = bfd_elf_get_elf_syms (opd_bfd, symtab_hdr,
 						  symtab_hdr->sh_info,
-						  0, NULL, NULL, NULL);
+						  0, NULL, NULL, NULL,
+						  NULL);
 		      if (sym == NULL)
 			break;
 		      symtab_hdr->contents = (bfd_byte *) sym;
@@ -6042,7 +6043,7 @@ get_sym_h (struct elf_link_hash_entry **
 	  if (locsyms == NULL)
 	    locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
 					    symtab_hdr->sh_info,
-					    0, NULL, NULL, NULL);
+					    0, NULL, NULL, NULL, NULL);
 	  if (locsyms == NULL)
 	    return FALSE;
 	  *locsymsp = locsyms;
Index: bfd/elf-m10300.c
===================================================================
--- bfd/elf-m10300.c	(revision 1859)
+++ bfd/elf-m10300.c	(working copy)
@@ -891,7 +891,7 @@ mn10300_elf_check_relocs (bfd *abfd,
 		  if (isymbuf == NULL)
 		    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						    symtab_hdr->sh_info, 0,
-						    NULL, NULL, NULL);
+						    NULL, NULL, NULL, NULL);
 		  if (isymbuf)
 		    {
 		      isym = isymbuf + r_symndx;
@@ -2131,7 +2131,7 @@ mn10300_elf_relax_section (bfd *abfd,
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == NULL)
 		goto error_return;
 	    }
@@ -2476,7 +2476,7 @@ mn10300_elf_relax_section (bfd *abfd,
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == NULL)
 		goto error_return;
 	    }
@@ -2781,7 +2781,7 @@ mn10300_elf_relax_section (bfd *abfd,
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
@@ -3880,7 +3880,7 @@ mn10300_elf_get_relocated_section_conten
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
Index: bfd/elf64-sh64.c
===================================================================
--- bfd/elf64-sh64.c	(revision 1859)
+++ bfd/elf64-sh64.c	(working copy)
@@ -2171,7 +2171,7 @@ sh_elf64_get_relocated_section_contents 
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
Index: bfd/elfxx-ia64.c
===================================================================
--- bfd/elfxx-ia64.c	(revision 1859)
+++ bfd/elfxx-ia64.c	(working copy)
@@ -883,7 +883,7 @@ elfNN_ia64_relax_section (bfd *abfd, ase
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == 0)
 		goto error_return;
 	    }
Index: bfd/elf32-avr.c
===================================================================
--- bfd/elf32-avr.c	(revision 1859)
+++ bfd/elf32-avr.c	(working copy)
@@ -1469,7 +1469,7 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
                if (isymbuf == NULL)
                  isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
                                                  symtab_hdr->sh_info, 0,
-                                                 NULL, NULL, NULL);
+                                                 NULL, NULL, NULL, NULL);
                if (isymbuf == NULL)
                  return FALSE;
              }
@@ -1686,7 +1686,7 @@ elf32_avr_relax_section (bfd *abfd,
           if (isymbuf == NULL)
             isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
                                             symtab_hdr->sh_info, 0,
-                                            NULL, NULL, NULL);
+                                            NULL, NULL, NULL, NULL);
           if (isymbuf == NULL)
             goto error_return;
         }
@@ -2104,7 +2104,7 @@ elf32_avr_relax_section (bfd *abfd,
 				       (abfd,
 					symtab_hdr,
 					symtab_hdr->sh_info, 0,
-					NULL, NULL, NULL);
+					NULL, NULL, NULL, NULL);
                                    if (isymbuf == NULL)
                                      break;
                                   }
@@ -2269,7 +2269,7 @@ elf32_avr_get_relocated_section_contents
           if (isymbuf == NULL)
             isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
                                             symtab_hdr->sh_info, 0,
-                                            NULL, NULL, NULL);
+                                            NULL, NULL, NULL, NULL);
           if (isymbuf == NULL)
             goto error_return;
         }
@@ -2622,7 +2622,7 @@ get_local_syms (bfd *input_bfd, struct b
 	{
 	  local_syms = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					     symtab_hdr->sh_info, 0,
-					     NULL, NULL, NULL);
+					     NULL, NULL, NULL, NULL);
 	  /* Cache them for elf_link_input_bfd.  */
 	  symtab_hdr->contents = (unsigned char *) local_syms;
 	}
Index: bfd/elf32-xstormy16.c
===================================================================
--- bfd/elf32-xstormy16.c	(revision 1859)
+++ bfd/elf32-xstormy16.c	(working copy)
@@ -633,7 +633,7 @@ xstormy16_elf_relax_section (bfd *dynobj
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    return FALSE;
 	}
Index: bfd/elf64-hppa.c
===================================================================
--- bfd/elf64-hppa.c	(revision 1859)
+++ bfd/elf64-hppa.c	(working copy)
@@ -667,7 +667,7 @@ elf64_hppa_check_relocs (abfd, info, sec
 	  if (local_syms == NULL)
 	    local_syms = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					       symtab_hdr->sh_info, 0,
-					       NULL, NULL, NULL);
+					       NULL, NULL, NULL, NULL);
 	  if (local_syms == NULL)
 	    return FALSE;
 	}
Index: bfd/elf32-sh.c
===================================================================
--- bfd/elf32-sh.c	(revision 1859)
+++ bfd/elf32-sh.c	(working copy)
@@ -586,7 +586,7 @@ sh_elf_relax_section (bfd *abfd, asectio
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
@@ -4452,7 +4452,7 @@ sh_elf_get_relocated_section_contents (b
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
Index: bfd/elfxx-mips.c
===================================================================
--- bfd/elfxx-mips.c	(revision 1859)
+++ bfd/elfxx-mips.c	(working copy)
@@ -7211,7 +7211,7 @@ _bfd_mips_relax_section (bfd *abfd, asec
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == NULL)
 		goto relax_return;
 	    }
Index: bfd/elf32-cr16.c
===================================================================
--- bfd/elf32-cr16.c	(revision 1859)
+++ bfd/elf32-cr16.c	(working copy)
@@ -1035,7 +1035,7 @@ elf32_cr16_get_relocated_section_content
           if (isymbuf == NULL)
             isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
                                             symtab_hdr->sh_info, 0,
-                                            NULL, NULL, NULL);
+                                            NULL, NULL, NULL, NULL);
           if (isymbuf == NULL)
             goto error_return;
         }
@@ -1165,7 +1165,7 @@ elf32_cr16_relax_section (bfd *abfd, ase
           if (isymbuf == NULL)
             isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
                                             symtab_hdr->sh_info, 0,
-                                            NULL, NULL, NULL);
+                                            NULL, NULL, NULL, NULL);
           if (isymbuf == NULL)
             goto error_return;
         }
Index: bfd/elflink.c
===================================================================
--- bfd/elflink.c	(revision 1859)
+++ bfd/elflink.c	(working copy)
@@ -611,7 +611,8 @@ bfd_elf_link_record_local_dynamic_symbol
 
   /* Go find the symbol, so that we can find it's name.  */
   if (!bfd_elf_get_elf_syms (input_bfd, &elf_tdata (input_bfd)->symtab_hdr,
-			     1, input_indx, &entry->isym, esym, &eshndx))
+			     1, input_indx, &entry->isym, esym, &eshndx,
+			     NULL))
     {
       bfd_release (input_bfd, entry);
       return 0;
@@ -2913,8 +2914,8 @@ static bfd_boolean
 elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef)
 {
   Elf_Internal_Shdr * hdr;
-  bfd_size_type symcount;
-  bfd_size_type extsymcount;
+  size_t symcount;
+  size_t extsymcount;
   bfd_size_type extsymoff;
   Elf_Internal_Sym *isymbuf;
   Elf_Internal_Sym *isym;
@@ -2961,7 +2962,7 @@ elf_link_is_defined_archive_symbol (bfd 
 
   /* Read in the symbol table.  */
   isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff,
-				  NULL, NULL, NULL);
+				  NULL, NULL, NULL, &extsymcount);
   if (isymbuf == NULL)
     return FALSE;
 
@@ -3292,8 +3293,8 @@ static bfd_boolean
 elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 {
   Elf_Internal_Shdr *hdr;
-  bfd_size_type symcount;
-  bfd_size_type extsymcount;
+  size_t symcount;
+  size_t extsymcount;
   bfd_size_type extsymoff;
   struct elf_link_hash_entry **sym_hash;
   bfd_boolean dynamic;
@@ -3658,7 +3659,7 @@ elf_link_add_object_symbols (bfd *abfd, 
   if (extsymcount != 0)
     {
       isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff,
-				      NULL, NULL, NULL);
+				      NULL, NULL, NULL, &extsymcount);
       if (isymbuf == NULL)
 	goto error_return;
 
@@ -6974,7 +6975,7 @@ bfd_elf_match_symbols_in_sections (asect
   if (ssymbuf1 == NULL)
     {
       isymbuf1 = bfd_elf_get_elf_syms (bfd1, hdr1, symcount1, 0,
-				       NULL, NULL, NULL);
+				       NULL, NULL, NULL, NULL);
       if (isymbuf1 == NULL)
 	goto done;
 
@@ -6986,7 +6987,7 @@ bfd_elf_match_symbols_in_sections (asect
   if (ssymbuf1 == NULL || ssymbuf2 == NULL)
     {
       isymbuf2 = bfd_elf_get_elf_syms (bfd2, hdr2, symcount2, 0,
-				       NULL, NULL, NULL);
+				       NULL, NULL, NULL, NULL);
       if (isymbuf2 == NULL)
 	goto done;
 
@@ -8262,8 +8263,8 @@ elf_link_check_versioned_symbol (struct 
     {
       bfd *input;
       Elf_Internal_Shdr *hdr;
-      bfd_size_type symcount;
-      bfd_size_type extsymcount;
+      size_t symcount;
+      size_t extsymcount;
       bfd_size_type extsymoff;
       Elf_Internal_Shdr *versymhdr;
       Elf_Internal_Sym *isym;
@@ -8298,7 +8299,7 @@ elf_link_check_versioned_symbol (struct 
 	continue;
 
       isymbuf = bfd_elf_get_elf_syms (input, hdr, extsymcount, extsymoff,
-				      NULL, NULL, NULL);
+				      NULL, NULL, NULL, &extsymcount);
       if (isymbuf == NULL)
 	return FALSE;
 
@@ -8869,7 +8870,8 @@ elf_link_input_bfd (struct elf_final_lin
       isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, locsymcount, 0,
 				      finfo->internal_syms,
 				      finfo->external_syms,
-				      finfo->locsym_shndx);
+				      finfo->locsym_shndx,
+				      NULL);
       if (isymbuf == NULL)
 	return FALSE;
     }
@@ -10972,7 +10974,8 @@ init_reloc_cookie (struct elf_reloc_cook
     {
       cookie->locsyms = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					      cookie->locsymcount, 0,
-					      NULL, NULL, NULL);
+					      NULL, NULL, NULL,
+					      NULL);
       if (cookie->locsyms == NULL)
 	{
 	  info->callbacks->einfo (_("%P%X: can not read symbols: %E\n"));
Index: bfd/elf64-alpha.c
===================================================================
--- bfd/elf64-alpha.c	(revision 1859)
+++ bfd/elf64-alpha.c	(working copy)
@@ -3724,7 +3724,7 @@ elf64_alpha_relax_section (bfd *abfd, as
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == NULL)
 		goto error_return;
 	    }
Index: bfd/elf-bfd.h
===================================================================
--- bfd/elf-bfd.h	(revision 1859)
+++ bfd/elf-bfd.h	(working copy)
@@ -1644,7 +1644,7 @@ extern char *bfd_elf_get_str_section
   (bfd *, unsigned);
 extern Elf_Internal_Sym *bfd_elf_get_elf_syms
   (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *,
-   Elf_External_Sym_Shndx *);
+   Elf_External_Sym_Shndx *, size_t *);
 extern const char *bfd_elf_sym_name
   (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, asection *);
 
Index: bfd/elfcode.h
===================================================================
--- bfd/elfcode.h	(revision 1859)
+++ bfd/elfcode.h	(working copy)
@@ -1129,7 +1129,7 @@ elf_slurp_symbol_table (bfd *abfd, asymb
 {
   Elf_Internal_Shdr *hdr;
   Elf_Internal_Shdr *verhdr;
-  unsigned long symcount;	/* Number of external ELF symbols */
+  size_t symcount;		/* Number of external ELF symbols */
   elf_symbol_type *sym;		/* Pointer to current bfd symbol */
   elf_symbol_type *symbase;	/* Buffer for generated bfd symbols */
   Elf_Internal_Sym *isym;
@@ -1179,7 +1179,7 @@ elf_slurp_symbol_table (bfd *abfd, asymb
   else
     {
       isymbuf = bfd_elf_get_elf_syms (abfd, hdr, symcount, 0,
-				      NULL, NULL, NULL);
+				      NULL, NULL, NULL, &symcount);
       if (isymbuf == NULL)
 	return -1;
 
Index: bfd/elf32-m68k.c
===================================================================
--- bfd/elf32-m68k.c	(revision 1859)
+++ bfd/elf32-m68k.c	(working copy)
@@ -2420,7 +2420,7 @@ bfd_m68k_elf32_create_embedded_relocs (a
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == NULL)
 		goto error_return;
 	    }
Index: bfd/opncls.c
===================================================================
--- bfd/opncls.c	(revision 1859)
+++ bfd/opncls.c	(working copy)
@@ -89,6 +89,7 @@ _bfd_new_bfd (void)
   nbfd->cacheable = FALSE;
   nbfd->flags = BFD_NO_FLAGS;
   nbfd->mtime_set = FALSE;
+  nbfd->strip_debug = FALSE;
 
   return nbfd;
 }
@@ -860,6 +861,7 @@ bfd_make_readable (bfd *abfd)
   abfd->cacheable = FALSE;
   abfd->flags = BFD_IN_MEMORY;
   abfd->mtime_set = FALSE;
+  abfd->strip_debug = FALSE;
 
   abfd->target_defaulted = TRUE;
   abfd->direction = read_direction;
Index: bfd/elf32-xtensa.c
===================================================================
--- bfd/elf32-xtensa.c	(revision 1859)
+++ bfd/elf32-xtensa.c	(working copy)
@@ -5770,7 +5770,7 @@ retrieve_local_syms (bfd *input_bfd)
   isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
   if (isymbuf == NULL && locsymcount != 0)
     isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, locsymcount, 0,
-				    NULL, NULL, NULL);
+				    NULL, NULL, NULL, NULL);
 
   /* Save the symbols for this input file so they won't be read again.  */
   if (isymbuf && isymbuf != (Elf_Internal_Sym *) symtab_hdr->contents)
Index: bfd/elf32-m32c.c
===================================================================
--- bfd/elf32-m32c.c	(revision 1859)
+++ bfd/elf32-m32c.c	(working copy)
@@ -914,7 +914,8 @@ dump_symtab (bfd * abfd, void *internal_
   if (free_internal)
     isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 				    symtab_hdr->sh_info, 0,
-				    internal_syms, external_syms, NULL);
+				    internal_syms, external_syms,
+				    NULL, NULL);
   else
     isymbuf = internal_syms;
   isymend = isymbuf + locsymcount;
@@ -1093,7 +1094,7 @@ m32c_elf_relax_plt_section (bfd *dynobj,
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    return FALSE;
 	}
@@ -1389,7 +1390,9 @@ m32c_elf_relax_section
     }
   else
     {
-      intsyms = bfd_elf_get_elf_syms (abfd, symtab_hdr, symtab_hdr->sh_info, 0, NULL, NULL, NULL);
+      intsyms = bfd_elf_get_elf_syms (abfd, symtab_hdr,
+				      symtab_hdr->sh_info, 0, NULL,
+				      NULL, NULL, NULL);
       symtab_hdr->contents = (bfd_byte *) intsyms;
     }
 
Index: bfd/elf32-crx.c
===================================================================
--- bfd/elf32-crx.c	(revision 1859)
+++ bfd/elf32-crx.c	(working copy)
@@ -769,7 +769,7 @@ elf32_crx_get_relocated_section_contents
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
@@ -1032,7 +1032,7 @@ elf32_crx_relax_section (bfd *abfd, asec
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
Index: bfd/elf64-mmix.c
===================================================================
--- bfd/elf64-mmix.c	(revision 1859)
+++ bfd/elf64-mmix.c	(working copy)
@@ -2697,7 +2697,7 @@ mmix_elf_relax_section (abfd, sec, link_
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == 0)
 		goto error_return;
 	    }
Index: bfd/bfd.c
===================================================================
--- bfd/bfd.c	(revision 1859)
+++ bfd/bfd.c	(working copy)
@@ -265,6 +265,9 @@ CODE_FRAGMENT
 .
 .  {* Have archive map.  *}
 .  unsigned int has_armap : 1;
+.
+.  {* Strip debug symbols.  *}
+.  unsigned int strip_debug : 1;
 .};
 .
 */
Index: bfd/elf32-ip2k.c
===================================================================
--- bfd/elf32-ip2k.c	(revision 1859)
+++ bfd/elf32-ip2k.c	(working copy)
@@ -1155,7 +1155,7 @@ ip2k_elf_relax_section (bfd *abfd,
       if (isymbuf == NULL)
 	isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					symtab_hdr->sh_info, 0,
-					NULL, NULL, NULL);
+					NULL, NULL, NULL, NULL);
       if (isymbuf == NULL)
 	goto error_return;
     }
Index: bfd/elf-m10200.c
===================================================================
--- bfd/elf-m10200.c	(revision 1859)
+++ bfd/elf-m10200.c	(working copy)
@@ -578,7 +578,7 @@ mn10200_elf_relax_section (abfd, sec, li
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
@@ -1358,7 +1358,7 @@ mn10200_elf_get_relocated_section_conten
 	  if (isymbuf == NULL)
 	    isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
 					    symtab_hdr->sh_info, 0,
-					    NULL, NULL, NULL);
+					    NULL, NULL, NULL, NULL);
 	  if (isymbuf == NULL)
 	    goto error_return;
 	}
Index: bfd/elf32-arm.c
===================================================================
--- bfd/elf32-arm.c	(revision 1859)
+++ bfd/elf32-arm.c	(working copy)
@@ -3415,7 +3415,7 @@ bfd_elf32_arm_init_maps (bfd *abfd)
      should contain the number of local symbols, which should come before any
      global symbols.  Mapping symbols are always local.  */
   isymbuf = bfd_elf_get_elf_syms (abfd, hdr, localsyms, 0, NULL, NULL,
-				  NULL);
+				  NULL, NULL);
 
   /* No internal symbols read?  Skip this BFD.  */
   if (isymbuf == NULL)
Index: bfd/elf32-v850.c
===================================================================
--- bfd/elf32-v850.c	(revision 1859)
+++ bfd/elf32-v850.c	(working copy)
@@ -2526,7 +2526,7 @@ v850_elf_relax_section (bfd *abfd,
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == NULL)
 		goto error_return;
 	    }
Index: bfd/elf32-bfin.c
===================================================================
--- bfd/elf32-bfin.c	(revision 1859)
+++ bfd/elf32-bfin.c	(working copy)
@@ -5541,7 +5541,7 @@ bfd_bfin_elf32_create_embedded_relocs (
 	      if (isymbuf == NULL)
 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
 						symtab_hdr->sh_info, 0,
-						NULL, NULL, NULL);
+						NULL, NULL, NULL, NULL);
 	      if (isymbuf == NULL)
 		goto error_return;
 	    }

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