elf_section_data

Alan Modra amodra@bigpond.net.au
Tue Feb 4 12:30:00 GMT 2003


This patch moves some fields from struct bfd_elf_section_data into
struct sec.  While this is probably a retrograde step in terms of
cleanliness, they fit nicely in what is currently padding and can
be accessed without the used_by_bfd indirection.  I've also defined
a new flag, has_tls_reloc, that I'll be using in ppc64 TLS support,
and a bunch of as yet unused flags.

bfd/ChangeLog
	* elf-bfd.h (enum elf_link_info_type): Remove.
	(struct bfd_elf_section_data): Move sec_info_type, use_rela_p fields
	to struct sec.  Remove linkonce_p field.
	(elf_linkonce_p): Delete.
	(elf_discarded_section): Update for sec_info_type change.
	* section.c (struct sec): Add sec_info_type, use_rela_p, has_tls_reloc,
	flag11, flag12, flag13, flag14, flag15, flag16, flag20, flag24.
	(ELF_INFO_TYPE_NONE): Define.
	(ELF_INFO_TYPE_STABS): Define.
	(ELF_INFO_TYPE_MERGE): Define.
	(ELF_INFO_TYPE_EH_FRAME): Define.
	(ELF_INFO_TYPE_JUST_SYMS): Define.
	(STD_SECTION): Update struct sec initializer.
	* ecoff.c (bfd_debug_section): Likewise.
	* elf.c: Likewise.  Update occurrences of sec_info_type and use_rela_p.
	* elflink.h: Likewise.
	* elf-eh-frame.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elfxx-ia64.c: Likewise.
	* elfxx-mips.c: Likewise.
	* bfd-in2.h: Regenerate.

	* elf32-sparc.c (sec_do_relax): Use elf_section_data macro rather than
	referring to used_by_bfd.
	* elf64-sparc.c (sec_do_relax): Likewise.
	* elf64-mmix.c (mmix_elf_section_data): Likewise.
	* elfxx-mips.c (mips_elf_section_data): Likewise.
	* ieee.c (ieee_slurp_section_data): Use ieee_per_section macro.
	(ieee_get_section_contents): Likewise.
	(ieee_new_section_hook): Formatting.
	(ieee_canonicalize_reloc): Remove commented out code.
	* mmo.c (mmo_section_data): Define.  Use throughout file.
	* oasys.c (oasys_get_section_contents): Use oasys_per_section macro.

gas/ChangeLog
	* config/obj-elf.c (obj_elf_change_section): Set SEC_LINK_ONCE and
	SEC_LINK_DUPLICATES_DISCARD directly rather than using elf_linkonce_p.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.91
diff -u -p -r1.91 elf-bfd.h
--- bfd/elf-bfd.h	23 Jan 2003 11:51:32 -0000	1.91
+++ bfd/elf-bfd.h	4 Feb 2003 10:33:26 -0000
@@ -229,16 +229,6 @@ struct elf_link_loaded_list
   bfd *abfd;
 };
 
-enum elf_link_info_type
-{
-  ELF_INFO_TYPE_NONE,
-  ELF_INFO_TYPE_STABS,
-  ELF_INFO_TYPE_MERGE,
-  ELF_INFO_TYPE_EH_FRAME,
-  ELF_INFO_TYPE_JUST_SYMS,
-  ELF_INFO_TYPE_LAST
-};
-
 /* Structures used by the eh_frame optimization code.  */
 struct cie_header
 {
@@ -989,29 +979,19 @@ struct bfd_elf_section_data
 
   /* A pointer used for various section optimizations.  */
   PTR sec_info;
-
-  /* Type of sec_info information.  */
-  enum elf_link_info_type sec_info_type;
-
-  /* Nonzero if this section uses RELA relocations, rather than REL.  */
-  unsigned int use_rela_p:1;
-
-  /* Nonzero when a group is COMDAT.  */
-  unsigned int linkonce_p:1;
 };
 
 #define elf_section_data(sec)  ((struct bfd_elf_section_data*)sec->used_by_bfd)
 #define elf_group_name(sec)    (elf_section_data(sec)->group.name)
 #define elf_group_id(sec)      (elf_section_data(sec)->group.id)
 #define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group)
-#define elf_linkonce_p(sec)    (elf_section_data(sec)->linkonce_p)
 
 /* Return TRUE if section has been discarded.  */
-#define elf_discarded_section(sec)					\
-  (!bfd_is_abs_section(sec)						\
-   && bfd_is_abs_section((sec)->output_section)				\
-   && elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_MERGE	\
-   && elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
+#define elf_discarded_section(sec)				\
+  (!bfd_is_abs_section (sec)					\
+   && bfd_is_abs_section ((sec)->output_section)		\
+   && sec->sec_info_type != ELF_INFO_TYPE_MERGE			\
+   && sec->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
 
 #define get_elf_backend_data(abfd) \
   ((struct elf_backend_data *) (abfd)->xvec->backend_data)
Index: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.52
diff -u -p -r1.52 section.c
--- bfd/section.c	30 Nov 2002 08:39:40 -0000	1.52
+++ bfd/section.c	4 Feb 2003 10:33:26 -0000
@@ -1,6 +1,6 @@
 /* Object file "section" support for the BFD library.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002
+   2000, 2001, 2002, 2003
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -377,10 +377,35 @@ CODE_FRAGMENT
 .  {* A mark flag used by some linker backends for garbage collection.  *}
 .  unsigned int gc_mark : 1;
 .
-.  {* Used by the ELF code to mark sections which have been allocated
-.     to segments.  *}
+.  {* The following flags are used by the ELF linker. *}
+.
+.  {* Mark sections which have been allocated to segments.  *}
 .  unsigned int segment_mark : 1;
 .
+.  {* Type of sec_info information.  *}
+.  unsigned int sec_info_type:3;
+.#define ELF_INFO_TYPE_NONE      0
+.#define ELF_INFO_TYPE_STABS     1
+.#define ELF_INFO_TYPE_MERGE     2
+.#define ELF_INFO_TYPE_EH_FRAME  3
+.#define ELF_INFO_TYPE_JUST_SYMS 4
+.
+.  {* Nonzero if this section uses RELA relocations, rather than REL.  *}
+.  unsigned int use_rela_p:1;
+.
+.  {* Bits used by various backends.  *}
+.  unsigned int has_tls_reloc:1;
+.
+.  {* Usused bits.  *}
+.  unsigned int flag11:1;
+.  unsigned int flag12:1;
+.  unsigned int flag13:1;
+.  unsigned int flag14:1;
+.  unsigned int flag15:1;
+.  unsigned int flag16:4;
+.  unsigned int flag20:4;
+.  unsigned int flag24:8;
+.
 .  {* End of internal packed boolean fields.  *}
 .
 .  {*  The virtual memory address of the section - where it will be
@@ -589,6 +614,12 @@ static const asymbol global_syms[] =
 									\
     /* linker_mark, linker_has_input, gc_mark, segment_mark,         */	\
        0,           0,                1,       0,			\
+									\
+    /* sec_info_type, use_rela_p, has_tls_reloc, flag11, flag12,     */ \
+       0,	      0,	  0,		 0,	 0,		\
+									\
+    /* flag13, flag14, flag15, flag16, flag20, flag24,               */ \
+       0,      0,      0,      0,      0,      0,			\
 									\
     /* vma, lma, _cooked_size, _raw_size,                            */	\
        0,   0,   0,            0,					\
Index: bfd/ecoff.c
===================================================================
RCS file: /cvs/src/src/bfd/ecoff.c,v
retrieving revision 1.23
diff -u -p -r1.23 ecoff.c
--- bfd/ecoff.c	30 Nov 2002 08:39:36 -0000	1.23
+++ bfd/ecoff.c	4 Feb 2003 10:33:29 -0000
@@ -1,6 +1,6 @@
 /* Generic ECOFF (Extended-COFF) routines.
-   Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
-   Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+   2002, 2003 Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, ian@cygnus.com.
 
@@ -81,6 +81,10 @@ static asection bfd_debug_section =
   "*DEBUG*", 0,   0,     NULL, 0,     0,            0,
   /* linker_mark, linker_has_input, gc_mark, segment_mark,         */
      0,           0,                0,       0,
+  /* sec_info_type, use_rela_p, has_tls_reloc, flag11, flag12,     */
+     0,		    0,		0,	       0,      0,
+  /* flag13, flag14, flag15, flag16, flag20, flag24,               */
+     0,      0,      0,      0,      0,	     0,
   /* vma, lma, _cooked_size, _raw_size,                            */
      0,   0,   0,            0,
   /* output_offset, output_section, alignment_power,               */
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.175
diff -u -p -r1.175 elf.c
--- bfd/elf.c	23 Jan 2003 11:51:32 -0000	1.175
+++ bfd/elf.c	4 Feb 2003 10:33:34 -0000
@@ -969,11 +969,8 @@ merge_sections_remove_hook (abfd, sec)
      bfd *abfd ATTRIBUTE_UNUSED;
      asection *sec;
 {
-  struct bfd_elf_section_data *sec_data;
-
-  sec_data = elf_section_data (sec);
-  BFD_ASSERT (sec_data->sec_info_type == ELF_INFO_TYPE_MERGE);
-  sec_data->sec_info_type = ELF_INFO_TYPE_NONE;
+  BFD_ASSERT (sec->sec_info_type == ELF_INFO_TYPE_MERGE);
+  sec->sec_info_type = ELF_INFO_TYPE_NONE;
 }
 
 /* Finish SHF_MERGE section merging.  */
@@ -1001,7 +998,7 @@ _bfd_elf_link_just_syms (sec, info)
   if (!is_elf_hash_table (info))
     return;
 
-  elf_section_data (sec)->sec_info_type = ELF_INFO_TYPE_JUST_SYMS;
+  sec->sec_info_type = ELF_INFO_TYPE_JUST_SYMS;
 }
 
 /* Copy the program header and other data from one object module to
@@ -2007,8 +2004,7 @@ bfd_section_from_shdr (abfd, shindex)
 	/* In the section to which the relocations apply, mark whether
 	   its relocations are of the REL or RELA variety.  */
 	if (hdr->sh_size != 0)
-	  elf_section_data (target_sect)->use_rela_p
-	    = (hdr->sh_type == SHT_RELA);
+	  target_sect->use_rela_p = hdr->sh_type == SHT_RELA;
 	abfd->flags |= HAS_RELOC;
 	return TRUE;
       }
@@ -2148,8 +2144,7 @@ _bfd_elf_new_section_hook (abfd, sec)
     }
 
   /* Indicate whether or not this section should use RELA relocations.  */
-  sdata->use_rela_p
-    = get_elf_backend_data (abfd)->default_use_rela_p;
+  sec->use_rela_p = get_elf_backend_data (abfd)->default_use_rela_p;
 
   return TRUE;
 }
@@ -2507,7 +2502,7 @@ elf_fake_sections (abfd, asect, failedpt
       && !_bfd_elf_init_reloc_shdr (abfd,
 				    &elf_section_data (asect)->rel_hdr,
 				    asect,
-				    elf_section_data (asect)->use_rela_p))
+				    asect->use_rela_p))
     *failedptr = TRUE;
 }
 
@@ -5190,8 +5185,7 @@ _bfd_elf_copy_private_section_data (ibfd
   elf_next_in_group (osec) = elf_next_in_group (isec);
   elf_group_name (osec) = elf_group_name (isec);
 
-  elf_section_data (osec)->use_rela_p
-    = elf_section_data (isec)->use_rela_p;
+  osec->use_rela_p = isec->use_rela_p;
 
   return TRUE;
 }
@@ -7336,7 +7330,7 @@ _bfd_elf_rela_local_sym (abfd, sym, sec,
 		+ sym->st_value);
   if ((sec->flags & SEC_MERGE)
       && ELF_ST_TYPE (sym->st_info) == STT_SECTION
-      && elf_section_data (sec)->sec_info_type == ELF_INFO_TYPE_MERGE)
+      && sec->sec_info_type == ELF_INFO_TYPE_MERGE)
     {
       asection *msec;
 
@@ -7361,7 +7355,7 @@ _bfd_elf_rel_local_sym (abfd, sym, psec,
 {
   asection *sec = *psec;
 
-  if (elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_MERGE)
+  if (sec->sec_info_type != ELF_INFO_TYPE_MERGE)
     return sym->st_value + addend;
 
   return _bfd_merged_section_offset (abfd, psec,
@@ -7379,7 +7373,7 @@ _bfd_elf_section_offset (abfd, info, sec
   struct bfd_elf_section_data *sec_data;
 
   sec_data = elf_section_data (sec);
-  switch (sec_data->sec_info_type)
+  switch (sec->sec_info_type)
     {
     case ELF_INFO_TYPE_STABS:
       return _bfd_stab_section_offset (abfd,
Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.202
diff -u -p -r1.202 elflink.h
--- bfd/elflink.h	23 Dec 2002 11:53:59 -0000	1.202
+++ bfd/elflink.h	4 Feb 2003 10:33:38 -0000
@@ -1,5 +1,5 @@
 /* ELF linker support.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -1304,7 +1304,7 @@ elf_link_add_object_symbols (abfd, info)
 	 Test for --just-symbols by looking at info set up by
 	 _bfd_elf_link_just_syms.  */
       if ((s = abfd->sections) != NULL
-	  && elf_section_data (s)->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
+	  && s->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
 	goto error_return;
 
       /* Find the name to use in a DT_NEEDED entry that refers to this
@@ -2234,7 +2234,7 @@ elf_link_add_object_symbols (abfd, info)
 					     &secdata->sec_info))
 		goto error_return;
 	      if (secdata->sec_info)
-		secdata->sec_info_type = ELF_INFO_TYPE_STABS;
+		stab->sec_info_type = ELF_INFO_TYPE_STABS;
 	    }
 	}
     }
@@ -2256,7 +2256,7 @@ elf_link_add_object_symbols (abfd, info)
 				      s, &secdata->sec_info))
 	      goto error_return;
 	    else if (secdata->sec_info)
-	      secdata->sec_info_type = ELF_INFO_TYPE_MERGE;
+	      s->sec_info_type = ELF_INFO_TYPE_MERGE;
 	  }
     }
 
@@ -5916,7 +5916,7 @@ elf_link_sec_merge_syms (h, data)
   if ((h->root.type == bfd_link_hash_defined
        || h->root.type == bfd_link_hash_defweak)
       && ((sec = h->root.u.def.section)->flags & SEC_MERGE)
-      && elf_section_data (sec)->sec_info_type == ELF_INFO_TYPE_MERGE)
+      && sec->sec_info_type == ELF_INFO_TYPE_MERGE)
     {
       bfd *output_bfd = (bfd *) data;
 
@@ -6522,7 +6522,7 @@ elf_link_input_bfd (finfo, input_bfd)
 	{
 	  isec = section_from_elf_index (input_bfd, isym->st_shndx);
 	  if (isec
-	      && elf_section_data (isec)->sec_info_type == ELF_INFO_TYPE_MERGE
+	      && 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,
@@ -7015,7 +7015,7 @@ elf_link_input_bfd (finfo, input_bfd)
 	{
 	  /* Section written out.  */
 	}
-      else switch (elf_section_data (o)->sec_info_type)
+      else switch (o->sec_info_type)
 	{
 	case ELF_INFO_TYPE_STABS:
 	  if (! (_bfd_write_section_stabs
@@ -8268,7 +8268,7 @@ elf_bfd_discard_info (output_bfd, info)
       if (stab != NULL
 	  && (stab->_raw_size == 0
 	      || bfd_is_abs_section (stab->output_section)
-	      || elf_section_data (stab)->sec_info_type != ELF_INFO_TYPE_STABS))
+	      || stab->sec_info_type != ELF_INFO_TYPE_STABS))
 	stab = NULL;
 
       if (stab == NULL
@@ -8374,7 +8374,7 @@ elf_section_ignore_discarded_relocs (sec
 {
   struct elf_backend_data *bed;
 
-  switch (elf_section_data (sec)->sec_info_type)
+  switch (sec->sec_info_type)
     {
     case ELF_INFO_TYPE_STABS:
     case ELF_INFO_TYPE_EH_FRAME:
Index: bfd/elf-eh-frame.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v
retrieving revision 1.20
diff -u -p -r1.20 elf-eh-frame.c
--- bfd/elf-eh-frame.c	30 Nov 2002 08:39:37 -0000	1.20
+++ bfd/elf-eh-frame.c	4 Feb 2003 10:33:38 -0000
@@ -1,5 +1,5 @@
 /* .eh_frame section optimization.
-   Copyright 2001, 2002 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -605,7 +605,7 @@ _bfd_elf_discard_section_eh_frame (abfd,
     }
 
   elf_section_data (sec)->sec_info = sec_info;
-  elf_section_data (sec)->sec_info_type = ELF_INFO_TYPE_EH_FRAME;
+  sec->sec_info_type = ELF_INFO_TYPE_EH_FRAME;
 
   /* Ok, now we can assign new offsets.  */
   offset = 0;
@@ -758,7 +758,7 @@ _bfd_elf_eh_frame_section_offset (output
   struct eh_frame_sec_info *sec_info;
   unsigned int lo, hi, mid;
 
-  if (elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
+  if (sec->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
     return offset;
   sec_info = (struct eh_frame_sec_info *)
 	     elf_section_data (sec)->sec_info;
@@ -828,7 +828,7 @@ _bfd_elf_write_section_eh_frame (abfd, i
   ptr_size = (elf_elfheader (sec->owner)->e_ident[EI_CLASS]
 	      == ELFCLASS64) ? 8 : 4;
 
-  if (elf_section_data (sec)->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
+  if (sec->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
     return bfd_set_section_contents (abfd, sec->output_section,
 				     contents,
 				     (file_ptr) sec->output_offset,
Index: bfd/elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.91
diff -u -p -r1.91 elf64-alpha.c
--- bfd/elf64-alpha.c	22 Jan 2003 00:47:58 -0000	1.91
+++ bfd/elf64-alpha.c	4 Feb 2003 10:33:41 -0000
@@ -4438,8 +4438,7 @@ elf64_alpha_relocate_section (output_bfd
 	     unless it has been done already.  */
 	  if ((sec->flags & SEC_MERGE)
 	      && ELF_ST_TYPE (sym->st_info) == STT_SECTION
-	      && (elf_section_data (sec)->sec_info_type
-		  == ELF_INFO_TYPE_MERGE)
+	      && sec->sec_info_type == ELF_INFO_TYPE_MERGE
 	      && gotent
 	      && !gotent->reloc_xlated)
 	    {
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.66
diff -u -p -r1.66 elfxx-ia64.c
--- bfd/elfxx-ia64.c	17 Jan 2003 23:27:55 -0000	1.66
+++ bfd/elfxx-ia64.c	4 Feb 2003 10:33:44 -0000
@@ -3763,8 +3763,7 @@ elfNN_ia64_relocate_section (output_bfd,
 	  value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
 	  if ((sym_sec->flags & SEC_MERGE)
 	      && ELF_ST_TYPE (sym->st_info) == STT_SECTION
-	      && (elf_section_data (sym_sec)->sec_info_type
-		  == ELF_INFO_TYPE_MERGE))
+	      && sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE)
  	    {
 	      struct elfNN_ia64_local_hash_entry *loc_h;
 
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.41
diff -u -p -r1.41 elfxx-mips.c
--- bfd/elfxx-mips.c	29 Jan 2003 08:29:34 -0000	1.41
+++ bfd/elfxx-mips.c	4 Feb 2003 10:33:49 -0000
@@ -148,7 +148,7 @@ struct _mips_elf_section_data
 };
 
 #define mips_elf_section_data(sec) \
-  ((struct _mips_elf_section_data *) (sec)->used_by_bfd)
+  ((struct _mips_elf_section_data *) elf_section_data (sec))
 
 /* This structure is passed to mips_elf_sort_hash_table_f when sorting
    the dynamic symbols.  */
@@ -4600,8 +4600,7 @@ _bfd_mips_elf_fake_sections (abfd, hdr, 
       esd->rel_hdr2 = (Elf_Internal_Shdr *) bfd_zalloc (abfd, amt);
       if (!esd->rel_hdr2)
 	return FALSE;
-      _bfd_elf_init_reloc_shdr (abfd, esd->rel_hdr2, sec,
-				!elf_section_data (sec)->use_rela_p);
+      _bfd_elf_init_reloc_shdr (abfd, esd->rel_hdr2, sec, !sec->use_rela_p);
     }
 
   return TRUE;
Index: bfd/elf32-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sparc.c,v
retrieving revision 1.46
diff -u -p -r1.46 elf32-sparc.c
--- bfd/elf32-sparc.c	25 Jan 2003 08:20:38 -0000	1.46
+++ bfd/elf32-sparc.c	4 Feb 2003 10:33:51 -0000
@@ -2058,7 +2058,7 @@ struct elf32_sparc_section_data
 };
 
 #define sec_do_relax(sec) \
-  ((struct elf32_sparc_section_data *) (sec)->used_by_bfd)->do_relax
+  ((struct elf32_sparc_section_data *) elf_section_data (sec))->do_relax
 
 static bfd_boolean
 elf32_sparc_new_section_hook (abfd, sec)
Index: bfd/elf64-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sparc.c,v
retrieving revision 1.67
diff -u -p -r1.67 elf64-sparc.c
--- bfd/elf64-sparc.c	24 Jan 2003 23:44:44 -0000	1.67
+++ bfd/elf64-sparc.c	4 Feb 2003 11:10:21 -0000
@@ -1925,7 +1925,7 @@ struct sparc64_elf_section_data
 };
 
 #define sec_do_relax(sec) \
-  ((struct sparc64_elf_section_data *) (sec)->used_by_bfd)->do_relax
+  ((struct sparc64_elf_section_data *) elf_section_data (sec))->do_relax
 
 static bfd_boolean
 sparc64_elf_new_section_hook (abfd, sec)
Index: bfd/elf64-mmix.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mmix.c,v
retrieving revision 1.22
diff -u -p -r1.22 elf64-mmix.c
--- bfd/elf64-mmix.c	23 Jan 2003 11:51:32 -0000	1.22
+++ bfd/elf64-mmix.c	4 Feb 2003 10:33:52 -0000
@@ -52,7 +52,7 @@ struct _mmix_elf_section_data
 };
 
 #define mmix_elf_section_data(sec) \
-  ((struct _mmix_elf_section_data *) (sec)->used_by_bfd)
+  ((struct _mmix_elf_section_data *) elf_section_data (sec))
 
 /* For each section containing a base-plus-offset (BPO) reloc, we attach
    this struct as mmix_elf_section_data (section)->bpo, which is otherwise
Index: bfd/ieee.c
===================================================================
RCS file: /cvs/src/src/bfd/ieee.c,v
retrieving revision 1.29
diff -u -p -r1.29 ieee.c
--- bfd/ieee.c	30 Nov 2002 08:39:39 -0000	1.29
+++ bfd/ieee.c	4 Feb 2003 10:33:54 -0000
@@ -1,6 +1,6 @@
 /* BFD back-end for ieee-695 objects.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002
+   2000, 2001, 2002, 2003
    Free Software Foundation, Inc.
 
    Written by Steve Chamberlain of Cygnus Support.
@@ -2074,7 +2074,7 @@ ieee_slurp_section_data (abfd)
 
   for (s = abfd->sections; s != (asection *) NULL; s = s->next)
     {
-      ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
+      ieee_per_section_type *per = ieee_per_section (s);
       if ((s->flags & SEC_DEBUGGING) != 0)
 	continue;
       per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
@@ -2098,7 +2098,7 @@ ieee_slurp_section_data (abfd)
 	  section_number = must_parse_int (&(ieee->h));
 	  s = ieee->section_table[section_number];
 	  s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
-	  current_map = (ieee_per_section_type *) s->used_by_bfd;
+	  current_map = ieee_per_section (s);
 	  location_ptr = current_map->data - s->vma;
 	  /* The document I have says that Microtec's compilers reset */
 	  /* this after a sec section, even though the standard says not */
@@ -2192,8 +2192,8 @@ ieee_new_section_hook (abfd, newsect)
      bfd *abfd;
      asection *newsect;
 {
-  newsect->used_by_bfd = (PTR)
-    bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type));
+  newsect->used_by_bfd
+    = (PTR) bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type));
   if (!newsect->used_by_bfd)
     return FALSE;
   ieee_per_section (newsect)->data = (bfd_byte *) NULL;
@@ -2221,7 +2221,7 @@ ieee_get_section_contents (abfd, section
      file_ptr offset;
      bfd_size_type count;
 {
-  ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;
+  ieee_per_section_type *p = ieee_per_section (section);
   if ((section->flags & SEC_DEBUGGING) != 0)
     return _bfd_generic_get_section_contents (abfd, section, location,
 					      offset, count);
@@ -2237,7 +2237,6 @@ ieee_canonicalize_reloc (abfd, section, 
      arelent **relptr;
      asymbol **symbols;
 {
-/*  ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
   ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation);
   ieee_data_type *ieee = IEEE_DATA (abfd);
 
Index: bfd/mmo.c
===================================================================
RCS file: /cvs/src/src/bfd/mmo.c,v
retrieving revision 1.13
diff -u -p -r1.13 mmo.c
--- bfd/mmo.c	30 Nov 2002 08:39:40 -0000	1.13
+++ bfd/mmo.c	4 Feb 2003 10:33:56 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for mmo objects (MMIX-specific object-format).
-   Copyright 2001, 2002
+   Copyright 2001, 2002, 2003
    Free Software Foundation, Inc.
    Written by Hans-Peter Nilsson (hp@bitrange.com).
    Infrastructure and other bits originally copied from srec.c and
@@ -335,6 +335,9 @@ struct mmo_section_data_struct
     mmo_data_list_type *tail;
   };
 
+#define mmo_section_data(sec) \
+  ((struct mmo_section_data_struct *) (sec)->used_by_bfd)
+
 /* These structures are used in bfd_map_over_sections constructs.  */
 
 /* Used when writing out sections; all but the register contents section
@@ -1177,12 +1180,11 @@ mmo_get_spec_section (abfd, spec_data_nu
     }
 
   loc->next = NULL;
-  if (((struct mmo_section_data_struct *) (sec->used_by_bfd))->tail != NULL)
-    ((struct mmo_section_data_struct *) (sec->used_by_bfd))->tail->next
-      = loc;
+  if (mmo_section_data (sec)->tail != NULL)
+    mmo_section_data (sec)->tail->next = loc;
   else
-    ((struct mmo_section_data_struct *) (sec->used_by_bfd))->head = loc;
-  ((struct mmo_section_data_struct *) (sec->used_by_bfd))->tail = loc;
+    mmo_section_data (sec)->head = loc;
+  mmo_section_data (sec)->tail = loc;
   loc->where = section_vma;
 
   return sec;
@@ -1517,8 +1519,7 @@ mmo_get_loc (sec, vma, size)
      int size;
 {
   bfd_size_type allocated_size;
-  struct mmo_section_data_struct *sdatap
-    = (struct mmo_section_data_struct *) sec->used_by_bfd;
+  struct mmo_section_data_struct *sdatap = mmo_section_data (sec);
   struct mmo_data_list_struct *datap = sdatap->head;
   struct mmo_data_list_struct *entry;
 
@@ -2463,15 +2464,9 @@ mmo_internal_write_section (abfd, sec)
 
   if (strcmp (sec->name, MMO_TEXT_SECTION_NAME) == 0)
     /* FIXME: Output source file name and line number.  */
-    return
-      mmo_write_loc_chunk_list (abfd,
-				((struct mmo_section_data_struct *)
-				 (sec->used_by_bfd))->head);
+    return mmo_write_loc_chunk_list (abfd, mmo_section_data (sec)->head);
   else if (strcmp (sec->name, MMO_DATA_SECTION_NAME) == 0)
-    return
-      mmo_write_loc_chunk_list (abfd,
-				((struct mmo_section_data_struct *)
-				 (sec->used_by_bfd))->head);
+    return mmo_write_loc_chunk_list (abfd, mmo_section_data (sec)->head);
   else if (strcmp (sec->name, MMIX_REG_CONTENTS_SECTION_NAME) == 0)
     /* Not handled here.  */
     {
@@ -2486,9 +2481,7 @@ mmo_internal_write_section (abfd, sec)
       int n = atoi (sec->name + strlen (MMIX_OTHER_SPEC_SECTION_PREFIX));
       mmo_write_tetra_raw (abfd, (LOP << 24) | (LOP_SPEC << 16) | n);
       return (! abfd->tdata.mmo_data->have_error
-	      && mmo_write_chunk_list (abfd,
-				       ((struct mmo_section_data_struct *)
-					(sec->used_by_bfd))->head));
+	      && mmo_write_chunk_list (abfd, mmo_section_data (sec)->head));
     }
   /* Ignore sections that are just allocated or empty; we write out
      _contents_ here.  */
@@ -2605,16 +2598,11 @@ EXAMPLE
       /* Writing a LOP_LOC ends the LOP_SPEC data, and makes data actually
 	 loaded.  */
       if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
-	  return
-	    ! abfd->tdata.mmo_data->have_error
-	    && mmo_write_loc_chunk_list (abfd,
-					 ((struct mmo_section_data_struct *)
-					  (sec->used_by_bfd))->head);
-      return
-	! abfd->tdata.mmo_data->have_error
-	&& mmo_write_chunk_list (abfd,
-				 ((struct mmo_section_data_struct *)
-				  (sec->used_by_bfd))->head);
+	return (! abfd->tdata.mmo_data->have_error
+		&& mmo_write_loc_chunk_list (abfd,
+					     mmo_section_data (sec)->head));
+      return (! abfd->tdata.mmo_data->have_error
+	      && mmo_write_chunk_list (abfd, mmo_section_data (sec)->head));
     }
   return TRUE;
 }
Index: bfd/oasys.c
===================================================================
RCS file: /cvs/src/src/bfd/oasys.c,v
retrieving revision 1.18
diff -u -p -r1.18 oasys.c
--- bfd/oasys.c	30 Nov 2002 08:39:40 -0000	1.18
+++ bfd/oasys.c	4 Feb 2003 10:33:57 -0000
@@ -1,6 +1,6 @@
 /* BFD back-end for oasys objects.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002
-   Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001,
+   2002, 2003 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -864,7 +864,7 @@ oasys_get_section_contents (abfd, sectio
      file_ptr offset;
      bfd_size_type count;
 {
-  oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd;
+  oasys_per_section_type *p = oasys_per_section (section);
   oasys_slurp_section_data (abfd);
   if (! p->initialized)
     {
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.196
diff -u -p -r1.196 bfd-in2.h
--- bfd/bfd-in2.h	31 Jan 2003 10:04:16 -0000	1.196
+++ bfd/bfd-in2.h	4 Feb 2003 10:34:00 -0000
@@ -1261,9 +1261,34 @@ typedef struct sec
   /* A mark flag used by some linker backends for garbage collection.  */
   unsigned int gc_mark : 1;
 
-  /* Used by the ELF code to mark sections which have been allocated
-     to segments.  */
+  /* The following flags are used by the ELF linker. */
+
+  /* Mark sections which have been allocated to segments.  */
   unsigned int segment_mark : 1;
+
+  /* Type of sec_info information.  */
+  unsigned int sec_info_type:3;
+#define ELF_INFO_TYPE_NONE      0
+#define ELF_INFO_TYPE_STABS     1
+#define ELF_INFO_TYPE_MERGE     2
+#define ELF_INFO_TYPE_EH_FRAME  3
+#define ELF_INFO_TYPE_JUST_SYMS 4
+
+  /* Nonzero if this section uses RELA relocations, rather than REL.  */
+  unsigned int use_rela_p:1;
+
+  /* Bits used by various backends.  */
+  unsigned int has_tls_reloc:1;
+
+  /* Usused bits.  */
+  unsigned int flag11:1;
+  unsigned int flag12:1;
+  unsigned int flag13:1;
+  unsigned int flag14:1;
+  unsigned int flag15:1;
+  unsigned int flag16:4;
+  unsigned int flag20:4;
+  unsigned int flag24:8;
 
   /* End of internal packed boolean fields.  */
 
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.61
diff -u -p -r1.61 obj-elf.c
--- gas/config/obj-elf.c	24 Jan 2003 23:44:44 -0000	1.61
+++ gas/config/obj-elf.c	4 Feb 2003 10:34:01 -0000
@@ -755,11 +755,12 @@ obj_elf_change_section (name, type, attr
       if (type == SHT_NOBITS)
         seg_info (sec)->bss = 1;
 
+      if (linkonce)
+	flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
       bfd_set_section_flags (stdoutput, sec, flags);
       if (flags & SEC_MERGE)
 	sec->entsize = entsize;
       elf_group_name (sec) = group_name;
-      elf_linkonce_p (sec) = linkonce;
 
       /* Add a symbol for this section to the symbol table.  */
       secsym = symbol_find (name);
@@ -776,8 +777,8 @@ obj_elf_change_section (name, type, attr
       if (((old_sec->flags ^ flags)
 	   & (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
 	      | SEC_EXCLUDE | SEC_SORT_ENTRIES | SEC_MERGE | SEC_STRINGS
-	      | SEC_THREAD_LOCAL))
-	  || linkonce != elf_linkonce_p (sec))
+	      | SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
+	      | SEC_THREAD_LOCAL)))
 	as_warn (_("ignoring changed section attributes for %s"), name);
       if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize)
 	as_warn (_("ignoring changed section entity size for %s"), name);
@@ -2037,7 +2038,7 @@ elf_frob_file ()
 
       flags = SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_GROUP;
       for (s = list.head[i]; s != NULL; s = elf_next_in_group (s))
-	if (elf_linkonce_p (s) != ((flags & SEC_LINK_ONCE) != 0))
+	if ((s->flags ^ flags) & SEC_LINK_ONCE)
 	  {
 	    flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
 	    if (s != list.head[i])

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list