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]

[patch] aix ld import symbols


New handling of XMC_XO and syscall symbols from import files.  Cleaned up old
broken method. 

Tom
-- 
Tom Rix 
GCC Engineer
trix@redhat.com
256.704.9201
2001-08-20  Tom Rix <trix@redhat.com> 

	* xcofflink.c (bfd_xcoff_import_symbol): Handle import file XMC_XO 
	and syscall symbols.
	(write_global_symbol) : Same.	
	(bfd_xcoff_export_symbol): Remove unused syscall param.
	* libxcoff.h: Change prototype of bfd_xcoff_export symbol and 
	bfd_xcoff_import_symbol.
 
Index: libxcoff.h
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/libxcoff.h,v
retrieving revision 1.1.2.1
diff -c -p -r1.1.2.1 libxcoff.h
*** libxcoff.h	2001/01/30 21:37:03	1.1.2.1
--- libxcoff.h	2001/08/20 17:48:47
*************** extern boolean bfd_xcoff_link_record_set
*** 229,238 ****
  	   bfd_size_type));
  extern boolean bfd_xcoff_import_symbol
    PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
! 	   bfd_vma, const char *, const char *, const char *));
  extern boolean bfd_xcoff_export_symbol
!   PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
! 	   boolean));
  extern boolean bfd_xcoff_link_count_reloc
    PARAMS ((bfd *, struct bfd_link_info *, const char *));
  extern boolean bfd_xcoff_record_link_assignment
--- 229,237 ----
  	   bfd_size_type));
  extern boolean bfd_xcoff_import_symbol
    PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
! 	   bfd_vma, const char *, const char *, const char *, unsigned int));
  extern boolean bfd_xcoff_export_symbol
!   PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *));
  extern boolean bfd_xcoff_link_count_reloc
    PARAMS ((bfd *, struct bfd_link_info *, const char *));
  extern boolean bfd_xcoff_record_link_assignment
Index: xcofflink.c
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/xcofflink.c,v
retrieving revision 1.75.86.5
diff -c -p -r1.75.86.5 xcofflink.c
*** xcofflink.c	2001/08/13 17:55:42	1.75.86.5
--- xcofflink.c	2001/08/20 17:48:47
*************** bfd_xcoff_link_record_set (output_bfd, i
*** 2620,2626 ****
  
  boolean
  bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
! 			 impmember)
       bfd *output_bfd;
       struct bfd_link_info *info;
       struct bfd_link_hash_entry *harg;
--- 2620,2626 ----
  
  boolean
  bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
! 			 impmember, syscall_flag)
       bfd *output_bfd;
       struct bfd_link_info *info;
       struct bfd_link_hash_entry *harg;
*************** bfd_xcoff_import_symbol (output_bfd, inf
*** 2628,2633 ****
--- 2628,2634 ----
       const char *imppath;
       const char *impfile;
       const char *impmember;
+      unsigned int syscall_flag;
  {
    struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
  
*************** bfd_xcoff_import_symbol (output_bfd, inf
*** 2670,2676 ****
  	h = hds;
      }
  
!   h->flags |= XCOFF_IMPORT;
  
    if (val != (bfd_vma) -1)
      {
--- 2671,2677 ----
  	h = hds;
      }
  
!   h->flags |= (XCOFF_IMPORT | syscall_flag);
  
    if (val != (bfd_vma) -1)
      {
*************** bfd_xcoff_import_symbol (output_bfd, inf
*** 2737,2747 ****
  /* Export a symbol.  */
  
  boolean
! bfd_xcoff_export_symbol (output_bfd, info, harg, syscall)
       bfd *output_bfd;
       struct bfd_link_info *info;
       struct bfd_link_hash_entry *harg;
-      boolean syscall ATTRIBUTE_UNUSED;
  {
    struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
  
--- 2738,2747 ----
  /* Export a symbol.  */
  
  boolean
! bfd_xcoff_export_symbol (output_bfd, info, harg)
       bfd *output_bfd;
       struct bfd_link_info *info;
       struct bfd_link_hash_entry *harg;
  {
    struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
  
*************** xcoff_write_global_symbol (h, p)
*** 5477,5483 ****
      if (((h->flags & XCOFF_DEF_REGULAR) == 0 && 
  	 (h->flags & XCOFF_DEF_DYNAMIC) != 0) || 
  	(h->flags & XCOFF_IMPORT) != 0) {
!       ldsym->l_smtype |= L_IMPORT;
      }
  
      if (((h->flags & XCOFF_DEF_REGULAR) != 0 && 
--- 5477,5486 ----
      if (((h->flags & XCOFF_DEF_REGULAR) == 0 && 
  	 (h->flags & XCOFF_DEF_DYNAMIC) != 0) || 
  	(h->flags & XCOFF_IMPORT) != 0) {
!       /* Clear l_smtype 
! 	 Import symbols are defined so the check above will make the l_smtype
! 	 XTY_SD.  But this is not correct, it should be cleared. */
!       ldsym->l_smtype = L_IMPORT;
      }
  
      if (((h->flags & XCOFF_DEF_REGULAR) != 0 && 
*************** xcoff_write_global_symbol (h, p)
*** 5496,5501 ****
--- 5499,5527 ----
  
      ldsym->l_smclas = h->smclas;
  
+     if (ldsym->l_smtype & L_IMPORT)
+       {
+ 	if ((h->root.type == bfd_link_hash_defined ||
+ 	     h->root.type == bfd_link_hash_defweak) &&
+ 	    (h->root.u.def.value != 0))
+ 	  {
+ 	    ldsym->l_smclas = XMC_XO;
+ 	  }
+ 	else if ((h->flags & (XCOFF_SYSCALL32 | XCOFF_SYSCALL64)) ==
+ 		 (XCOFF_SYSCALL32 | XCOFF_SYSCALL64))
+ 	  {
+ 	    ldsym->l_smclas = XMC_SV3264;
+ 	  }
+ 	else if (h->flags & XCOFF_SYSCALL32) 
+ 	  {
+ 	    ldsym->l_smclas = XMC_SV;
+ 	  }
+ 	else if (h->flags & XCOFF_SYSCALL64) 
+ 	  {
+ 	    ldsym->l_smclas = XMC_SV64;
+ 	  }
+       }
+        
      if (ldsym->l_ifile == (bfd_size_type) -1) {
        ldsym->l_ifile = 0;
  
2001-08-20  Tom Rix <trix@redhat.com>

	* emultempl/aix.em : Handle import file XMC_XO and syscall symbols.

Index: emultempl/aix.em
===================================================================
RCS file: /cvs/cvsfiles/devo/ld/emultempl/aix.em,v
retrieving revision 1.23.192.2
diff -c -p -r1.23.192.2 aix.em
*** aix.em	2001/03/08 15:25:05	1.23.192.2
--- aix.em	2001/08/20 17:37:46
*************** struct export_symbol_list
*** 100,106 ****
  {
    struct export_symbol_list *next;
    const char *name;
-   boolean syscall;
  };
  
  static struct export_symbol_list *export_symbols;
--- 100,105 ----
*************** gld${EMULATION_NAME}_before_allocation (
*** 617,623 ****
      h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
      if (h == NULL)
        einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
!     if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h, el->syscall))
        einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
    }
  
--- 616,622 ----
      h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
      if (h == NULL)
        einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
!     if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h))
        einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
    }
  
*************** static int change_symbol_mode (char *inp
*** 805,811 ****
  }
  
  
! static int is_syscall(char *input)
  {
    /*
     * 1 : yes
--- 804,810 ----
  }
  
  
! static int is_syscall(char *input, unsigned int *flag)
  {
    /*
     * 1 : yes
*************** static int is_syscall(char *input)
*** 815,841 ****
    unsigned int bit;
    char *string;
    
!   char *syscall_string[] = {
!     "svc",	     /* 0x01 */
!     "svc32",	     /* 0x02 */
!     "svc3264",	     /* 0x04 */
!     "svc64",	     /* 0x08 */
!     "syscall",	     /* 0x10 */
!     "syscall32",     /* 0x20 */
!     "syscall3264",   /* 0x40 */
!     "syscall64",     /* 0x80 */
!     NULL
    };
  
    for (bit = 0; ;bit++) {
      
!     string = syscall_string[bit];
      if (NULL == string) {
        return -1;
      }
  
      if (0 == strcmp(input, string)) {
        if (1 << bit & ${SYSCALL_MASK}) {
  	return 1;
        } else {
  	return 0;
--- 814,846 ----
    unsigned int bit;
    char *string;
    
!   struct sc {
!     char *syscall_string;
!     unsigned int flag;
!   } s [] = {
!     { "svc"	    /* 0x01 */, XCOFF_SYSCALL32 },
!     { "svc32"	    /* 0x02 */, XCOFF_SYSCALL32 },
!     { "svc3264"     /* 0x04 */, XCOFF_SYSCALL32 | XCOFF_SYSCALL64 },
!     { "svc64"	    /* 0x08 */, XCOFF_SYSCALL64 },
!     { "syscall"     /* 0x10 */, XCOFF_SYSCALL32 },
!     { "syscall32"   /* 0x20 */, XCOFF_SYSCALL32 },
!     { "syscall3264" /* 0x40 */, XCOFF_SYSCALL32 | XCOFF_SYSCALL64 },
!     { "syscall64"   /* 0x80 */, XCOFF_SYSCALL64 },
!     { NULL, 0 },
    };
  
+   *flag = 0;
+ 
    for (bit = 0; ;bit++) {
      
!     string = s[bit].syscall_string;
      if (NULL == string) {
        return -1;
      }
  
      if (0 == strcmp(input, string)) {
        if (1 << bit & ${SYSCALL_MASK}) {
+ 	*flag = s[bit].flag;
  	return 1;
        } else {
  	return 0;
*************** gld${EMULATION_NAME}_read_file (filename
*** 895,901 ****
      {
        char *s;
        char *symname;
!       boolean syscall;
        bfd_vma address;
        struct bfd_link_hash_entry *h;
  
--- 900,906 ----
      {
        char *s;
        char *symname;
!       unsigned int syscall_flag = 0;
        bfd_vma address;
        struct bfd_link_hash_entry *h;
  
*************** gld${EMULATION_NAME}_read_file (filename
*** 998,1004 ****
  
  	/* This is a symbol to be imported or exported.  */
  	symname = s;
! 	syscall = false;
  	address = (bfd_vma) -1;
  
  	while (! isspace ((unsigned char) *s) && *s != '\0')
--- 1003,1009 ----
  
  	/* This is a symbol to be imported or exported.  */
  	symname = s;
! 	syscall_flag = 0;
  	address = (bfd_vma) -1;
  
  	while (! isspace ((unsigned char) *s) && *s != '\0')
*************** gld${EMULATION_NAME}_read_file (filename
*** 1029,1047 ****
  	      int status;
  	      char *end;
  			  
! 	      status = is_syscall(s);
  			  
! 	      switch (status) {
! 	      case 1:
! 		/* this is a system call */
! 		syscall = true;
! 		break;
! 					  
! 	      case 0:
! 		/* ignore this system call */
! 		break;
! 					  
! 	      default:
  		/* not a system call, check for address */
  		address = strtoul (s, &end, 0);
  		if (*end != '\0') {
--- 1034,1042 ----
  	      int status;
  	      char *end;
  			  
! 	      status = is_syscall(s, &syscall_flag);
  			  
! 	      if (0 > status) {
  		/* not a system call, check for address */
  		address = strtoul (s, &end, 0);
  		if (*end != '\0') {
*************** gld${EMULATION_NAME}_read_file (filename
*** 1061,1067 ****
  		 xmalloc (sizeof (struct export_symbol_list)));
  	    n->next = export_symbols;
  	    n->name = buystring (symname);
- 	    n->syscall = syscall;
  	    export_symbols = n;
  	  }
  	else
--- 1056,1061 ----
*************** gld${EMULATION_NAME}_read_file (filename
*** 1077,1083 ****
  	      {
  		if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
  					       address, imppath, impfile,
! 					       impmember))
  		  einfo ("%X%s:%d: failed to import symbol %s: %E\n",
  			 filename, lineno, symname);
  	      }
--- 1071,1077 ----
  	      {
  		if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
  					       address, imppath, impfile,
! 					       impmember, syscall_flag))
  		  einfo ("%X%s:%d: failed to import symbol %s: %E\n",
  			 filename, lineno, symname);
  	      }

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