This is the mail archive of the binutils@sources.redhat.com 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]

Re: please prepend "warning: " to messages emitted because of.gnu.warning sections


Hi Zack,

> I brought this up with the libc people and they suggested that ld
> ought to be responsible for prepending "warning: " to messages emitted
> because of .gnu.warning sections.  On reflection I agree.  Any chance
> this could be done for the next binutils release?

You mean something like this ?

Cheers
        Nick

bfd/ChangeLog        
2003-08-01  Nick Clifton  <nickc@redhat.com>

	* elflink.h (elf_link_add_object_symbols): Prepend "warning: "
	to messages produced for .gnu.warning.SYMBOL sections.

ld/ChangeLog        
2003-08-01  Nick Clifton  <nickc@redhat.com>

	* emultempl/elf32.em (before_allocation): Prepend "warning: "
	to messages produced for .gnu.warning.SYMBOL sections.

Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.235
diff -c -3 -p -r1.235 elflink.h
*** bfd/elflink.h	10 Jul 2003 00:37:27 -0000	1.235
--- bfd/elflink.h	1 Aug 2003 09:39:29 -0000
*************** elf_link_add_object_symbols (abfd, info)
*** 487,492 ****
--- 487,494 ----
  	    {
  	      char *msg;
  	      bfd_size_type sz;
+ 	      bfd_size_type prefix_len;
+ 	      const char * gnu_warning_prefix = _("warning: ");
  
  	      name += sizeof ".gnu.warning." - 1;
  
*************** elf_link_add_object_symbols (abfd, info)
*** 520,533 ****
  		}
  
  	      sz = bfd_section_size (abfd, s);
! 	      msg = (char *) bfd_alloc (abfd, sz + 1);
  	      if (msg == NULL)
  		goto error_return;
  
! 	      if (! bfd_get_section_contents (abfd, s, msg, (file_ptr) 0, sz))
  		goto error_return;
  
! 	      msg[sz] = '\0';
  
  	      if (! (_bfd_generic_link_add_one_symbol
  		     (info, abfd, name, BSF_WARNING, s, (bfd_vma) 0, msg,
--- 522,538 ----
  		}
  
  	      sz = bfd_section_size (abfd, s);
! 	      prefix_len = strlen (gnu_warning_prefix);
! 	      msg = (char *) bfd_alloc (abfd, prefix_len + sz + 1);
  	      if (msg == NULL)
  		goto error_return;
  
! 	      strcpy (msg, gnu_warning_prefix);
! 	      if (! bfd_get_section_contents (abfd, s, msg + prefix_len,
! 					      (file_ptr) 0, sz))
  		goto error_return;
  
! 	      msg[prefix_len + sz] = '\0';
  
  	      if (! (_bfd_generic_link_add_one_symbol
  		     (info, abfd, name, BSF_WARNING, s, (bfd_vma) 0, msg,
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.101
diff -c -3 -p -r1.101 elf32.em
*** ld/emultempl/elf32.em	27 Jun 2003 00:38:25 -0000	1.101
--- ld/emultempl/elf32.em	1 Aug 2003 09:39:30 -0000
*************** ${ELF_INTERPRETER_SET_DEFAULT}
*** 880,887 ****
--- 880,889 ----
        {
  	asection *s;
  	bfd_size_type sz;
+ 	bfd_size_type prefix_len;
  	char *msg;
  	bfd_boolean ret;
+ 	const char * gnu_warning_prefix = _("warning: ");
  
  	if (is->just_syms_flag)
  	  continue;
*************** ${ELF_INTERPRETER_SET_DEFAULT}
*** 891,901 ****
  	  continue;
  
  	sz = bfd_section_size (is->the_bfd, s);
! 	msg = xmalloc ((size_t) sz + 1);
! 	if (! bfd_get_section_contents (is->the_bfd, s, msg, (file_ptr) 0, sz))
  	  einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n",
  		 is->the_bfd);
! 	msg[sz] = '\0';
  	ret = link_info.callbacks->warning (&link_info, msg,
  					    (const char *) NULL,
  					    is->the_bfd, (asection *) NULL,
--- 893,906 ----
  	  continue;
  
  	sz = bfd_section_size (is->the_bfd, s);
! 	prefix_len = strlen (gnu_warning_prefix);
! 	msg = xmalloc ((size_t) (prefix_len + sz + 1));
! 	strcpy (msg, gnu_warning_prefix);
! 	if (! bfd_get_section_contents (is->the_bfd, s,	msg + prefix_len,
! 					(file_ptr) 0, sz))
  	  einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n",
  		 is->the_bfd);
! 	msg[prefix_len + sz] = '\0';
  	ret = link_info.callbacks->warning (&link_info, msg,
  					    (const char *) NULL,
  					    is->the_bfd, (asection *) NULL,


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