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]

PATCH BFD section load page support


TI COFF stores the load-time memory page of each section.  These mods
keep track of it.

* bfd-in.h: regenerate
* bfd-in2.h: regenerate
* coffcode.h (coff_write_object_contents): Set output section load page
field.
* coffgen.c (make_a_section_from_file): initialize load page, if
appropriate
   (coff_real_object_p): Set arch/mach *before* swapping section headers
in, so that
   section header swapping routines can  use that information.
* section.c: add load_page field to section structure.  Add load page
initialization to
   STD_SECTION macro and the standard section statics.

(note that the diff in linker.c is a change that got lost in the
application of the octets vs bytes patch)


Index: bfd-in.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/bfd-in.h,v
retrieving revision 1.5
diff -c -3 -p -r1.5 bfd-in.h
*** bfd-in.h	1999/07/12 11:06:02	1.5
--- bfd-in.h	2000/01/14 01:11:53
*************** typedef enum bfd_format {
*** 253,258 ****
--- 253,261 ----
  /* This flag indicates that the BFD contents are actually cached in
     memory.  If this is set, iostream points to a bfd_in_memory struct.  */
  #define BFD_IN_MEMORY 0x800
+ 
+ /* The sections in this BFD specify a memory page */
+ #define HAS_LOAD_PAGE 0x1000
  
  /* symbols and relocation */
  
*************** typedef struct sec *sec_ptr;
*** 313,318 ****
--- 316,322 ----
  #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
  #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
  #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
+ #define bfd_get_section_load_page(bfd, ptr) ((ptr)->load_page)
  #define bfd_section_name(bfd, ptr) ((ptr)->name)
  #define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
  #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
*************** typedef struct sec *sec_ptr;
*** 325,330 ****
--- 329,335 ----
  
  #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
  #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
+ #define bfd_set_section_load_page(bfd, ptr, val) ((ptr)->load_page = (val), true)
  #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
  
  typedef struct stat stat_type; 
Index: bfd-in2.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/bfd-in2.h,v
retrieving revision 1.28
diff -c -3 -p -r1.28 bfd-in2.h
*** bfd-in2.h	2000/01/13 22:10:36	1.28
--- bfd-in2.h	2000/01/14 01:11:56
*************** typedef enum bfd_format {
*** 253,258 ****
--- 253,261 ----
  /* This flag indicates that the BFD contents are actually cached in
     memory.  If this is set, iostream points to a bfd_in_memory struct.  */
  #define BFD_IN_MEMORY 0x800
+ 
+ /* The sections in this BFD specify a memory page */
+ #define HAS_LOAD_PAGE 0x1000
  
  /* symbols and relocation */
  
*************** typedef struct sec *sec_ptr;
*** 313,318 ****
--- 316,322 ----
  #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
  #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
  #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
+ #define bfd_get_section_load_page(bfd, ptr) ((ptr)->load_page)
  #define bfd_section_name(bfd, ptr) ((ptr)->name)
  #define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
  #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
*************** typedef struct sec *sec_ptr;
*** 325,330 ****
--- 329,335 ----
  
  #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
  #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
+ #define bfd_set_section_load_page(bfd, ptr, val) ((ptr)->load_page = (val), true)
  #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
  
  typedef struct stat stat_type; 
*************** typedef struct sec
*** 1065,1070 ****
--- 1070,1081 ----
             information. */
  
     bfd_vma lma;
+ 
+          /*  The memory page of the section (for TI COFF, usually PROG or DATA)
+            Needed on targets with a multiple address space.  The
+            file flag HAS_LOAD_PAGE should be set if this field is used.  */
+ 
+    int load_page;
  
           /* The size of the section in octets, as it will be output.
             Contains a value even if the section has no contents (e.g., the
Index: coffcode.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/coffcode.h,v
retrieving revision 1.27
diff -c -3 -p -r1.27 coffcode.h
*** coffcode.h	2000/01/13 23:55:21	1.27
--- coffcode.h	2000/01/14 01:11:59
*************** coff_write_object_contents (abfd)
*** 3126,3131 ****
--- 3126,3132 ----
  #endif
        section.s_vaddr = current->vma;
        section.s_paddr = current->lma;
+       section.s_page = current->load_page; 
        section.s_size =  current->_raw_size;
  
  #ifdef COFF_WITH_PE
Index: coffgen.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/coffgen.c,v
retrieving revision 1.10
diff -c -3 -p -r1.10 coffgen.c
*** coffgen.c	2000/01/13 22:10:36	1.10
--- coffgen.c	2000/01/14 01:12:00
*************** make_a_section_from_file (abfd, hdr, tar
*** 128,133 ****
--- 128,134 ----
  
    return_section->vma = hdr->s_vaddr;
    return_section->lma = hdr->s_paddr;
+   return_section->load_page = hdr->s_page;
    return_section->_raw_size = hdr->s_size;
    return_section->filepos = hdr->s_scnptr;
    return_section->rel_filepos = hdr->s_relptr;
*************** coff_real_object_p (abfd, nscns, interna
*** 182,187 ****
--- 183,190 ----
      abfd->flags |= HAS_LINENO;
    if (!(internal_f->f_flags & F_LSYMS))
      abfd->flags |= HAS_LOCALS;
+   if (internal_f->f_flags & F_LDPAGE)
+     abfd->flags |= HAS_LOAD_PAGE;
  
    /* FIXME: How can we set D_PAGED correctly?  */
    if ((internal_f->f_flags & F_EXEC) != 0)
*************** coff_real_object_p (abfd, nscns, interna
*** 211,216 ****
--- 214,224 ----
    if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
      goto fail;
  
+   /* set the arch/mach *before* swapping in sections; section header swapping
+      may depend on arch/mach info */
+   if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false)
+     goto fail;
+ 
    /* Now copy data as required; construct all asections etc */
    if (nscns != 0)
      {
*************** coff_real_object_p (abfd, nscns, interna
*** 227,235 ****
      }
  
    /*  make_abs_section (abfd); */
- 
-   if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false)
-     goto fail;
  
    return abfd->xvec;
  
--- 235,240 ----
Index: linker.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/linker.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 linker.c
*** linker.c	2000/01/13 22:10:36	1.4
--- linker.c	2000/01/14 01:12:05
*************** default_indirect_link_order (output_bfd,
*** 2749,2755 ****
    /* Output the section contents.  */
    if (! bfd_set_section_contents (output_bfd, output_section,
  				  (PTR) new_contents,
! 				  link_order->offset, link_order->size))
      goto error_return;
  
    if (contents != NULL)
--- 2749,2758 ----
    /* Output the section contents.  */
    if (! bfd_set_section_contents (output_bfd, output_section,
  				  (PTR) new_contents,
! 				  (file_ptr)
!                                   (link_order->offset * 
!                                    bfd_octets_per_byte (output_bfd)), 
!                                   link_order->size))
      goto error_return;
  
    if (contents != NULL)
Index: section.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/section.c,v
retrieving revision 1.10
diff -c -3 -p -r1.10 section.c
*** section.c	2000/01/13 22:10:36	1.10
--- section.c	2000/01/14 01:12:07
*************** CODE_FRAGMENT
*** 369,374 ****
--- 369,380 ----
  .
  .   bfd_vma lma;
  .
+ .        {*  The memory page of the section (for TI COFF, usually PROG or DATA)
+ .           Needed on targets with a multiple address space.  The
+ .           file flag HAS_LOAD_PAGE should be set if this field is used.  *}
+ .
+ .   int load_page;
+ .
  .        {* The size of the section in octets, as it will be output.
  .           Contains a value even if the section has no contents (e.g., the
  .           size of <<.bss>>).  This will be filled in after relocation.  *}
*************** static const asymbol global_syms[] =
*** 536,549 ****
    GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &bfd_ind_section)
  };
  
! #define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX)	\
    const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
    const asection SEC = \
      /* name, index, next, flags, set_vma, reloc_done, linker_mark, gc_mark */ \
      { NAME,  0,     0,    FLAGS, 0,       0,          0,           0,	      \
  									      \
!     /* vma, lma, _cooked_size, _raw_size, output_offset, output_section, */   \
!        0,   0,   0,            0,         0,             (struct sec *) &SEC, \
  									      \
      /* alig..., reloc..., orel..., reloc_count, filepos, rel_..., line_... */ \
         0,       0,        0,       0,           0,       0, 	   0,	      \
--- 542,555 ----
    GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &bfd_ind_section)
  };
  
! #define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX, PAGE)	\
    const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
    const asection SEC = \
      /* name, index, next, flags, set_vma, reloc_done, linker_mark, gc_mark */ \
      { NAME,  0,     0,    FLAGS, 0,       0,          0,           0,	      \
  									      \
!     /* vma, lma, page, _cooked_size, _raw_size, output_offset, output_section, */   \
!        0,   0,   PAGE, 0,            0,         0,             (struct sec *) &SEC, \
  									      \
      /* alig..., reloc..., orel..., reloc_count, filepos, rel_..., line_... */ \
         0,       0,        0,       0,           0,       0, 	   0,	      \
*************** static const asymbol global_syms[] =
*** 562,571 ****
      }
  
  STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol,
! 	     BFD_COM_SECTION_NAME, 0);
! STD_SECTION (bfd_und_section, 0, bfd_und_symbol, BFD_UND_SECTION_NAME, 1);
! STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2);
! STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3);
  #undef STD_SECTION
  
  /*
--- 568,577 ----
      }
  
  STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol,
! 	     BFD_COM_SECTION_NAME, 0, 1);
! STD_SECTION (bfd_und_section, 0, bfd_und_symbol, BFD_UND_SECTION_NAME, 1, 0);
! STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2, 0);
! STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3, 0);
  #undef STD_SECTION
  
  /*

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