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]

[vms/committed]: Handle LIB$INITIALIZE


Hi,

this patch adds support for LIB$INITIALIZE, which is roughly speaking the equivalent of the ELF _init
feature.

Tristan.

bfd/
2010-06-01  Tristan Gingold  <gingold@adacore.com>

	* vms-alpha.c (struct vms_private_data_struct): Add
	transfer_address field.  Remove unused dst_info field.
	(alpha_vms_write_exec): Use transfer_address.
	(_bfd_vms_write_egsd): Add a comment about LIB$INITIALIZE.
	(alpha_vms_bfd_final_link): Set transfer_address.

ld/
2010-06-01  Tristan Gingold  <gingold@adacore.com>

	* scripttempl/alphavms.sc: Add comments. Move $LINK$ to the
	readonly output-section. Handle LIB$INITIALIZE and sections
	created by gcc.
	* emultempl/vms.em (vms_place_orphan): Add comments.

Index: bfd/vms-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-alpha.c,v
retrieving revision 1.19
diff -c -r1.19 vms-alpha.c
*** bfd/vms-alpha.c	31 May 2010 15:03:14 -0000	1.19
--- bfd/vms-alpha.c	1 Jun 2010 09:40:57 -0000
***************
*** 273,278 ****
--- 273,281 ----
    struct hdr_struct hdr_data;		/* data from HDR/EMH record  */
    struct eom_struct eom_data;		/* data from EOM/EEOM record  */
  
+   /* Transfer addresses (entry points).  */
+   bfd_vma transfer_address[4];
+ 
    /* Array of GSD sections to get the correspond BFD one.  */
    unsigned int section_max; 		/* Size of the sections array.  */
    unsigned int section_count;		/* Number of GSD sections.  */
***************
*** 301,307 ****
  
    struct module *modules;		/* list of all compilation units */
  
-   struct dst_info *dst_info;
    asection *dst_section;
  
    unsigned int dst_ptr_offsets_count;	/* # of offsets in following array  */
--- 304,309 ----
***************
*** 2983,2993 ****
  
    bfd_putl32 (sizeof (struct vms_eiha), eiha->size);
    bfd_putl32 (0, eiha->spare);
!   bfd_putl32 (0x00000340, eiha->tfradr1);	/* SYS$IMGACT */
!   bfd_putl32 (0xffffffff, eiha->tfradr1_h);
!   bfd_putl64 (bfd_get_start_address (abfd), eiha->tfradr2);
!   bfd_putl64 (0, eiha->tfradr3);
!   bfd_putl64 (0, eiha->tfradr4);
    bfd_putl64 (0, eiha->inishr);
  
    /* Alloc EIHI.  */
--- 2985,2994 ----
  
    bfd_putl32 (sizeof (struct vms_eiha), eiha->size);
    bfd_putl32 (0, eiha->spare);
!   bfd_putl64 (PRIV (transfer_address[0]), eiha->tfradr1);
!   bfd_putl64 (PRIV (transfer_address[1]), eiha->tfradr2);
!   bfd_putl64 (PRIV (transfer_address[2]), eiha->tfradr3);
!   bfd_putl64 (PRIV (transfer_address[3]), eiha->tfradr4);
    bfd_putl64 (0, eiha->inishr);
  
    /* Alloc EIHI.  */
***************
*** 3389,3409 ****
        char *hash;
  
        symbol = abfd->outsymbols[symnum];
        if (*(symbol->name) == '_')
  	{
  	  if (strcmp (symbol->name, "__main") == 0)
  	    bfd_set_start_address (abfd, (bfd_vma)symbol->value);
  	}
-       old_flags = symbol->flags;
  
        if (old_flags & BSF_FILE)
  	continue;
  
!       if ((old_flags & BSF_GLOBAL) == 0		   /* Not xdef...  */
! 	  && !bfd_is_und_section (symbol->section) /* and not xref... */
! 	  && !((old_flags & BSF_SECTION_SYM) != 0  /* and not LIB$INITIALIZE.  */
! 	       && strcmp (symbol->section->name, "LIB$INITIALIZE") == 0))
! 	continue;
  
        /* 13 bytes egsd, max 64 chars name -> should be 77 bytes.  */
        if (_bfd_vms_output_check (recwr, 80) < 0)
--- 3390,3417 ----
        char *hash;
  
        symbol = abfd->outsymbols[symnum];
+       old_flags = symbol->flags;
+ 
+       /* Work-around a missing feature:  consider __main as the main entry point.  */
        if (*(symbol->name) == '_')
  	{
  	  if (strcmp (symbol->name, "__main") == 0)
  	    bfd_set_start_address (abfd, (bfd_vma)symbol->value);
  	}
  
+       /* Only put in the GSD the global and the undefined symbols.  */
        if (old_flags & BSF_FILE)
  	continue;
  
!       if ((old_flags & BSF_GLOBAL) == 0 && !bfd_is_und_section (symbol->section))
!         {
!           /* If the LIB$INITIIALIZE section is present, add a reference to
!              LIB$INITIALIZE symbol.  FIXME: this should be done explicitely
!              in the assembly file.  */
!           if (!((old_flags & BSF_SECTION_SYM) != 0
!                 && strcmp (symbol->section->name, "LIB$INITIALIZE") == 0))
!             continue;
!         }
  
        /* 13 bytes egsd, max 64 chars name -> should be 77 bytes.  */
        if (_bfd_vms_output_check (recwr, 80) < 0)
***************
*** 8668,8673 ****
--- 8676,8697 ----
          }
      }
  
+   /* Set transfer addresses.  */
+   {
+     int i;
+     struct bfd_link_hash_entry *h;
+ 
+     i = 0;
+     PRIV (transfer_address[i++]) = 0xffffffff00000340;	/* SYS$IMGACT */
+     h = bfd_link_hash_lookup (info->hash, "LIB$INITIALIZE", FALSE, FALSE, TRUE);
+     if (h != NULL && h->type == bfd_link_hash_defined)
+       PRIV (transfer_address[i++]) =
+         alpha_vms_get_sym_value (h->u.def.section, h->u.def.value);
+     PRIV (transfer_address[i++]) = bfd_get_start_address (abfd);
+     while (i < 4)
+       PRIV (transfer_address[i++]) = 0;
+   }
+ 
    /* Allocate contents.  */
    base_addr = (bfd_vma)-1;
    last_addr = 0;
Index: ld/emultempl/vms.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/vms.em,v
retrieving revision 1.1
diff -c -r1.1 vms.em
*** ld/emultempl/vms.em	14 Apr 2010 09:27:27 -0000	1.1
--- ld/emultempl/vms.em	1 Jun 2010 09:40:58 -0000
***************
*** 94,104 ****
        0, 0, 0, 0
      };
  
!   /* We have nothing to say for anything other than a final link.  */
    if (link_info.relocatable
        || (s->flags & (SEC_EXCLUDE | SEC_LOAD)) != SEC_LOAD)
      return NULL;
  
    /* Only handle data sections.  */
    if ((s->flags & SEC_DATA) == 0)
      return NULL;
--- 94,107 ----
        0, 0, 0, 0
      };
  
!   /* We have nothing to say for anything other than a final link or an excluded
!      section.  */
    if (link_info.relocatable
        || (s->flags & (SEC_EXCLUDE | SEC_LOAD)) != SEC_LOAD)
      return NULL;
  
+   /* FIXME: we should place sections by VMS program section flags.  */
+ 
    /* Only handle data sections.  */
    if ((s->flags & SEC_DATA) == 0)
      return NULL;
Index: ld/scripttempl/alphavms.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/alphavms.sc,v
retrieving revision 1.1
diff -c -r1.1 alphavms.sc
*** ld/scripttempl/alphavms.sc	14 Apr 2010 09:27:27 -0000	1.1
--- ld/scripttempl/alphavms.sc	1 Jun 2010 09:40:58 -0000
***************
*** 11,30 ****
  {
    ${RELOCATING+. = ${PAGESIZE};}
  
    \$DATA\$ ALIGN (${PAGESIZE}) : {
      *(\$DATA\$)
-     *(\$LINK\$)
    }
    \$BSS\$ ALIGN (${PAGESIZE}) : {
      *(\$BSS\$)
    }
    \$CODE\$ ALIGN (${PAGESIZE}) : {
      *(\$CODE\$)
    }
    \$LITERAL\$ ALIGN (${PAGESIZE}) : {
      *(\$LITERAL\$)
      *(\$READONLY\$)
      *(\$READONLY_ADDR\$)
    }
  
    \$DST\$ 0 : {
--- 11,45 ----
  {
    ${RELOCATING+. = ${PAGESIZE};}
  
+   /* RW initialized data.  */
    \$DATA\$ ALIGN (${PAGESIZE}) : {
      *(\$DATA\$)
    }
+   /* RW data unmodified (zero-initialized).  */
    \$BSS\$ ALIGN (${PAGESIZE}) : {
      *(\$BSS\$)
    }
+   /* RO, executable code.  */
    \$CODE\$ ALIGN (${PAGESIZE}) : {
      *(\$CODE\$)
    }
+   /* RO initialized data.  */
    \$LITERAL\$ ALIGN (${PAGESIZE}) : {
+     *(\$LINK\$)
      *(\$LITERAL\$)
      *(\$READONLY\$)
      *(\$READONLY_ADDR\$)
+     *(eh_frame)
+     *(jcr)
+     *(ctors)
+     *(dtors)
+     *(gcc_except_table)
+ 
+     /* LIB$INITIALIZE stuff.  */
+     *(LIB\$INITIALIZDZ)	/* Start marker.  */
+     *(LIB\$INITIALIZD_)	/* Hi priority.  */
+     *(LIB\$INITIALIZE)	/* User.  */
+     *(LIB\$INITIALIZE$)	/* End marker.  */
    }
  
    \$DST\$ 0 : {


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