This is the mail archive of the binutils@sourceware.cygnus.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]

Re: nonfunctional.


On 18 Apr 2000, Ian Lance Taylor wrote:

> I also think that the second and subsequent times a section appears in
> a file, we should permit it to have no flags specification at all, and
> to inherit any earlier specification with no warning.  That will make
> life easier for hand written assembler code.

OK, how's this then?

-- 
Linuxcare.  Support for the Revolution.

gas/ChangeLog
	* config/obj-elf.c (obj_elf_change_section): Check for changed
	section attributes.

Index: config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.15
diff -u -p -c -p -r1.15 obj-elf.c
*** obj-elf.c	2000/02/28 04:17:36	1.15
--- obj-elf.c	2000/04/19 14:13:07
*************** obj_elf_change_section (name, type, attr
*** 617,624 ****
       char *name;
       int type, attr, push;
  {
!   int new_sec;
    segT sec;
  
  #ifdef md_flush_pending_output
    md_flush_pending_output ();
--- 617,626 ----
       char *name;
       int type, attr, push;
  {
!   asection *old_sec;
    segT sec;
+   flagword flags;
+   int i;
  
  #ifdef md_flush_pending_output
    md_flush_pending_output ();
*************** obj_elf_change_section (name, type, attr
*** 639,687 ****
    previous_section = now_seg;
    previous_subsection = now_subseg;
  
!   new_sec = bfd_get_section_by_name (stdoutput, name) == NULL;
    sec = subseg_new (name, 0);
  
!   if (new_sec)
!     {
!       flagword flags;
!       symbolS *secsym;
!       int i;
! 
!       /* See if this is one of the special sections.  */
!       for (i = 0; special_sections[i].name != NULL; i++)
!         if (strcmp (name, special_sections[i].name) == 0)
!           {
! 	    if (type == SHT_NULL)
! 	      type = special_sections[i].type;
! 	    else if (type != special_sections[i].type)
! 	      as_warn (_("Setting incorrect section type for %s"), name);
! 
! 	    if ((attr &~ special_sections[i].attributes) != 0)
  	      {
! 	        /* As a GNU extension, we permit a .note section to be
! 		   allocatable.  If the linker sees an allocateable .note
! 		   section, it will create a PT_NOTE segment in the output
! 		   file.  */
! 		if (strcmp (name, ".note") != 0
! 		    || attr != SHF_ALLOC)
! 		  as_warn (_("Setting incorrect section attributes for %s"),
! 			   name);
  	      }
! 	    attr |= special_sections[i].attributes;
! 	    break;
  	  }
! 
!       /* Convert ELF type and flags to BFD flags.  */
!       flags = (SEC_RELOC
! 	       | ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
! 	       | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0)
! 	       | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0)
! 	       | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0));
  #ifdef md_elf_section_flags
!       flags = md_elf_section_flags (flags, attr, type);
  #endif
  
        /* Prevent SEC_HAS_CONTENTS from being inadvertently set.  */
        if (type == SHT_NOBITS)
          seg_info (sec)->bss = 1;
--- 641,697 ----
    previous_section = now_seg;
    previous_subsection = now_subseg;
  
!   old_sec = bfd_get_section_by_name (stdoutput, name);
    sec = subseg_new (name, 0);
  
!   /* See if this is one of the special sections.  */
!   for (i = 0; special_sections[i].name != NULL; i++)
!     if (strcmp (name, special_sections[i].name) == 0)
!       {
! 	if (type == SHT_NULL)
! 	  type = special_sections[i].type;
! 	else if (type != special_sections[i].type)
! 	  {
! 	    if (old_sec == NULL)
  	      {
! 		as_warn (_("Setting incorrect section type for %s"), name);
  	      }
! 	    else
! 	      {
! 		as_warn (_("Ignoring incorrect section type for %s"), name);
! 		type = special_sections[i].type;
! 	      }
  	  }
! 	if ((attr &~ special_sections[i].attributes) != 0
! 	    && old_sec == NULL)
! 	  {
! 	    /* As a GNU extension, we permit a .note section to be
! 	       allocatable.  If the linker sees an allocateable .note
! 	       section, it will create a PT_NOTE segment in the output
! 	       file.  */
! 	    if (strcmp (name, ".note") != 0
! 		|| attr != SHF_ALLOC)
! 	      as_warn (_("Setting incorrect section attributes for %s"),
! 		       name);
! 	  }
! 	attr |= special_sections[i].attributes;
! 	break;
!       }
! 
!   /* Convert ELF type and flags to BFD flags.  */
!   flags = (SEC_RELOC
! 	   | ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
! 	   | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0)
! 	   | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0)
! 	   | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0));
  #ifdef md_elf_section_flags
!   flags = md_elf_section_flags (flags, attr, type);
  #endif
  
+   if (old_sec == NULL)
+     {
+       symbolS *secsym;
+ 
        /* Prevent SEC_HAS_CONTENTS from being inadvertently set.  */
        if (type == SHT_NOBITS)
          seg_info (sec)->bss = 1;
*************** obj_elf_change_section (name, type, attr
*** 695,703 ****
        else
          symbol_table_insert (section_symbol (sec));
      }
  
  #ifdef md_elf_section_change_hook
!       md_elf_section_change_hook ();
  #endif
  }
  
--- 705,723 ----
        else
          symbol_table_insert (section_symbol (sec));
      }
+   else if (attr != 0)
+     {
+       /* If section attributes are specified the second time we see a
+ 	 particular section, then check that they are the same as we
+ 	 saw the first time.  */
+       if ((old_sec->flags ^ flags)
+ 	  & (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
+ 	     | SEC_EXCLUDE | SEC_SORT_ENTRIES))
+ 	as_warn (_("Ignoring changed section attributes for %s"), name);
+     }
  
  #ifdef md_elf_section_change_hook
!   md_elf_section_change_hook ();
  #endif
  }
  


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