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] HP-UX specific target vector for IA64


Here is another patch for IA64 HP-UX support.  I believe that after this
I will have just one more patch to gas, readelf, and the toplevel
configure script to finish the binutils support for this platform.

This patch creates HP-UX specific vectors in bfd and I had to add some
HP specific defines to src/include/elf/ia64.h.  I don't know if the
names I chose are acceptable or if there was a better place to put
platform specific defines but this seemed like the best approach.

The names I added to elf/ia64.h were picked out from the HP-UX elf.h
file, I can change the names if anyone has an objection to them, I
wasn't sure if I should put add _HP_ to the names of SHT_HP_OPT_ANOT and
SHN_IA_64_ANSI_COMMON or not.  In the end I left them with the same
names that HP is using in the standard HP-UX header file.

The rest is pretty standard changes to add a new vector.  I also added
an include of alloca.h to elfxx-ia64.c since it was using alloca.  I am
not sure if bfd should be using alloca, only one or two other files
reference it but it seems to work OK.

Steve Ellcey
sje@cup.hp.com


==================================


2001-07-12  Steve Ellcey  <sje@cup.hp.com>

        * src/include/elf/ia64.h (ELF_STRING_ia64_unwind_hdr, SHT_HP_OPT_ANOT,
	PT_HP_OPT_ANNOT, PT_HP_HSL_ANNOT, PT_HP_STACK, SHN_IA_64_ANSI_COMMON):
	New Macros for HP-UX.
	* src/bfd/config.bfd (bfd_elf64_ia64_hpux_big_vec,
        bfd_elf32_ia64_hpux_big_vec): Add new vectors
	* src/bfd/targets.c: Likewise.
	* src/bfd/configure.in: Likewise.
	* src/bfd/configure: Regenerate
	* src/bfd/elfxx-ia64.c: Include alloca.h
	(is_unwind_section_name): Add bfd pointer as argument so it can be
	tested.
	(elfNN_ia64_hpux_vec, elfNN_hpux_post_process_headers,
	elfNN_hpux_backend_section_from_bfd_section):
	New Routines for HP-UX support.

*** src/include/elf/ia64.h.orig	Thu Jul 12 09:02:05 2001
--- src/include/elf/ia64.h	Thu Jul 12 09:12:05 2001
*************** Foundation, Inc., 59 Temple Place - Suit
*** 49,54 ****
--- 49,56 ----
  #define ELF_STRING_ia64_unwind_info	".IA_64.unwind_info"
  #define ELF_STRING_ia64_unwind_once	".gnu.linkonce.ia64unw."
  #define ELF_STRING_ia64_unwind_info_once ".gnu.linkonce.ia64unwi."
+ /* unwind_hdr is only used by HP-UX */
+ #define ELF_STRING_ia64_unwind_hdr	".IA_64.unwind_hdr"
  
  /* Bits in the sh_flags field of Elf64_Shdr:  */
  
*************** Foundation, Inc., 59 Temple Place - Suit
*** 60,65 ****
--- 62,72 ----
  #define SHT_IA_64_EXT		(SHT_LOPROC + 0)	/* extension bits */
  #define SHT_IA_64_UNWIND	(SHT_LOPROC + 1)	/* unwind bits */
  
+ /* This header is only found on HPUX for its optimization annotation section.
+    Do not use two capital Ns in annotate or sed will turn it into 32 or 64
+    during the build. */
+ #define SHT_HP_OPT_ANOT		0x60000004
+ 
  /* Bits in the p_flags field of Elf64_Phdr:  */
  
  #define PF_IA_64_NORECOV	0x80000000
*************** Foundation, Inc., 59 Temple Place - Suit
*** 69,77 ****
--- 76,98 ----
  #define PT_IA_64_ARCHEXT	(PT_LOPROC + 0)	/* arch extension bits */
  #define PT_IA_64_UNWIND 	(PT_LOPROC + 1)	/* ia64 unwind bits */
  
+ /* HP-UX specific values for p_type in Elf64_Phdr.
+    These values are currently just used to make
+    readelf more usable on HP-UX. */
+ 
+ #define PT_HP_OPT_ANNOT		(PT_LOOS + 0x12)
+ #define PT_HP_HSL_ANNOT		(PT_LOOS + 0x13)
+ #define PT_HP_STACK		(PT_LOOS + 0x14)
+ 
  /* Possible values for d_tag in Elf64_Dyn:  */
  
  #define DT_IA_64_PLT_RESERVE	(DT_LOPROC + 0)
+ 
+ /* This section only used by HP-UX, The HP linker gives weak symbols
+    precedence over regular common symbols.  We want common to override
+    weak.  Using this common instead of SHN_COMMON on HP-UX does that.  */
+ 
+ #define SHN_IA_64_ANSI_COMMON	0xFF00
  
  /* ia64-specific relocation types: */
  
*** src/bfd/config.bfd.orig	Thu Jul 12 09:02:19 2001
--- src/bfd/config.bfd	Thu Jul 12 09:17:13 2001
*************** case "${targ}" in
*** 95,102 ****
      targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec"
      ;;
    ia64*-*-hpux*)
!     targ_defvec=bfd_elf64_ia64_big_vec
!     targ_selvecs="bfd_elf32_ia64_big_vec"
      ;;
    sparc64-*-freebsd* | sparc64-*-netbsd*)
      targ_defvec=bfd_elf64_sparc_vec
--- 95,102 ----
      targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec"
      ;;
    ia64*-*-hpux*)
!     targ_defvec=bfd_elf32_ia64_hpux_big_vec
!     targ_selvecs="bfd_elf64_ia64_hpux_big_vec"
      ;;
    sparc64-*-freebsd* | sparc64-*-netbsd*)
      targ_defvec=bfd_elf64_sparc_vec
*** src/bfd/configure.in.orig	Thu Jul 12 09:02:27 2001
--- src/bfd/configure.in	Thu Jul 12 09:27:48 2001
*************** do
*** 501,506 ****
--- 501,511 ----
  				target64=true ;;
      bfd_elf64_ia64_aix_big_vec)	tb="$tb elf64-ia64.lo elf64.lo $elf"
  				target64=true ;;
+     bfd_elf64_ia64_hpux_big_vec)
+ 				tb="$tb elf64-ia64.lo elf64.lo $elf"
+ 				target64=true ;;
+     bfd_elf32_ia64_hpux_big_vec)
+ 				tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
      bfd_elf32_ia64_big_vec)	tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
      bfd_elf32_avr_vec)		tb="$tb elf32-avr.lo elf32.lo $elf" ;;
      bfd_elf32_littlearc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
*** src/bfd/targets.c.orig	Thu Jul 12 09:02:48 2001
--- src/bfd/targets.c	Thu Jul 12 09:32:31 2001
*************** extern const bfd_target bfd_elf32_i860_l
*** 529,534 ****
--- 529,535 ----
  extern const bfd_target bfd_elf32_i860_vec;
  extern const bfd_target bfd_elf32_i960_vec;
  extern const bfd_target bfd_elf32_ia64_big_vec;
+ extern const bfd_target bfd_elf32_ia64_hpux_big_vec;
  extern const bfd_target bfd_elf32_little_generic_vec;
  extern const bfd_target bfd_elf32_littlearc_vec;
  extern const bfd_target bfd_elf32_littlearm_oabi_vec;
*************** extern const bfd_target bfd_elf64_hppa_v
*** 566,571 ****
--- 567,573 ----
  extern const bfd_target bfd_elf64_ia64_aix_big_vec;
  extern const bfd_target bfd_elf64_ia64_aix_little_vec;
  extern const bfd_target bfd_elf64_ia64_big_vec;
+ extern const bfd_target bfd_elf64_ia64_hpux_big_vec;
  extern const bfd_target bfd_elf64_ia64_little_vec;
  extern const bfd_target bfd_elf64_little_generic_vec;
  extern const bfd_target bfd_elf64_littlemips_vec;
*************** static const bfd_target * const _bfd_tar
*** 731,742 ****
--- 733,746 ----
  	   --enable-targets=all, objdump or gdb should be able to examine
  	   the file even if we don't recognize the machine type.  */
  	&bfd_elf32_big_generic_vec,
+ 	&bfd_elf32_ia64_hpux_big_vec,
  #ifdef BFD64
  	&bfd_elf64_alpha_vec,
  	&bfd_elf64_hppa_vec,
  	&bfd_elf64_hppa_linux_vec,
  	&bfd_elf64_ia64_aix_little_vec,
  	&bfd_elf64_ia64_aix_big_vec,
+ 	&bfd_elf64_ia64_hpux_big_vec,
  	&bfd_elf64_ia64_little_vec,
  	&bfd_elf64_ia64_big_vec,
  #endif
*** src/bfd/elfxx-ia64.c.orig	Thu Jul 12 09:02:36 2001
--- src/bfd/elfxx-ia64.c	Thu Jul 12 09:58:00 2001
*************** Foundation, Inc., 59 Temple Place - Suit
*** 24,29 ****
--- 24,32 ----
  #include "elf-bfd.h"
  #include "opcode/ia64.h"
  #include "elf/ia64.h"
+ #ifdef HAVE_ALLOCA_H
+ #include <alloca.h>
+ #endif
  
  /*
   * THE RULES for all the stuff the linker creates --
*************** static boolean elfNN_ia64_relax_section
*** 158,164 ****
    PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
  	  boolean *again));
  static boolean is_unwind_section_name
!   PARAMS ((const char *));
  static boolean elfNN_ia64_section_from_shdr
    PARAMS ((bfd *, ElfNN_Internal_Shdr *, char *));
  static boolean elfNN_ia64_fake_sections
--- 161,167 ----
    PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
  	  boolean *again));
  static boolean is_unwind_section_name
!   PARAMS ((bfd *, const char *));
  static boolean elfNN_ia64_section_from_shdr
    PARAMS ((bfd *, ElfNN_Internal_Shdr *, char *));
  static boolean elfNN_ia64_fake_sections
*************** static boolean elfNN_ia64_merge_private_
*** 285,290 ****
--- 288,300 ----
    PARAMS ((bfd *ibfd, bfd *obfd));
  static boolean elfNN_ia64_print_private_bfd_data
    PARAMS ((bfd *abfd, PTR ptr));
+ 
+ static boolean elfNN_ia64_hpux_vec
+   PARAMS ((const bfd_target *vec));
+ static void elfNN_hpux_post_process_headers
+   PARAMS ((bfd *abfd, struct bfd_link_info *info));
+ boolean elfNN_hpux_backend_section_from_bfd_section
+   PARAMS ((bfd *abfd, ElfNN_Internal_Shdr *hdr, asection *sec, int *retval));
  
  /* ia64-specific relocation */
  
*************** elfNN_ia64_relax_section (abfd, sec, lin
*** 723,729 ****
  	    continue;	/* We can't do anthing with undefined symbols.  */
  	  else if (isym.st_shndx == SHN_ABS)
  	    tsec = bfd_abs_section_ptr;
! 	  else if (isym.st_shndx == SHN_COMMON)
  	    tsec = bfd_com_section_ptr;
  	  else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
  	    tsec = bfd_section_from_elf_index (abfd, isym.st_shndx);
--- 733,740 ----
  	    continue;	/* We can't do anthing with undefined symbols.  */
  	  else if (isym.st_shndx == SHN_ABS)
  	    tsec = bfd_abs_section_ptr;
! 	  else if (isym.st_shndx == SHN_COMMON
! 		   || isym.st_shndx == SHN_IA_64_ANSI_COMMON)
  	    tsec = bfd_com_section_ptr;
  	  else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
  	    tsec = bfd_section_from_elf_index (abfd, isym.st_shndx);
*************** elfNN_ia64_relax_section (abfd, sec, lin
*** 922,932 ****
  /* Return true if NAME is an unwind table section name.  */
  
  static inline boolean
! is_unwind_section_name (name)
  	const char *name;
  {
    size_t len1, len2, len3;
  
    len1 = sizeof (ELF_STRING_ia64_unwind) - 1;
    len2 = sizeof (ELF_STRING_ia64_unwind_info) - 1;
    len3 = sizeof (ELF_STRING_ia64_unwind_once) - 1;
--- 933,948 ----
  /* Return true if NAME is an unwind table section name.  */
  
  static inline boolean
! is_unwind_section_name (abfd, name)
! 	bfd *abfd;
  	const char *name;
  {
    size_t len1, len2, len3;
  
+   if (elfNN_ia64_hpux_vec (abfd->xvec)
+       && !strcmp(name,ELF_STRING_ia64_unwind_hdr))
+     return false;
+ 
    len1 = sizeof (ELF_STRING_ia64_unwind) - 1;
    len2 = sizeof (ELF_STRING_ia64_unwind_info) - 1;
    len3 = sizeof (ELF_STRING_ia64_unwind_once) - 1;
*************** elfNN_ia64_fake_sections (abfd, hdr, sec
*** 1001,1007 ****
  
    name = bfd_get_section_name (abfd, sec);
  
!   if (is_unwind_section_name (name))
      {
        /* We don't have the sections numbered at this point, so sh_info
  	 is set later, in elfNN_ia64_final_write_processing.  */
--- 1017,1023 ----
  
    name = bfd_get_section_name (abfd, sec);
  
!   if (is_unwind_section_name (abfd, name))
      {
        /* We don't have the sections numbered at this point, so sh_info
  	 is set later, in elfNN_ia64_final_write_processing.  */
*************** elfNN_ia64_additional_program_headers (a
*** 1261,1267 ****
  
    /* Count how many PT_IA_64_UNWIND segments we need.  */
    for (s = abfd->sections; s; s = s->next)
!     if (is_unwind_section_name(s->name) && (s->flags & SEC_LOAD))
        ++ret;
  
    return ret;
--- 1277,1283 ----
  
    /* Count how many PT_IA_64_UNWIND segments we need.  */
    for (s = abfd->sections; s; s = s->next)
!     if (is_unwind_section_name(abfd, s->name) && (s->flags & SEC_LOAD))
        ++ret;
  
    return ret;
*************** elfNN_ia64_print_private_bfd_data (abfd,
*** 4309,4314 ****
--- 4325,4364 ----
    _bfd_elf_print_private_bfd_data (abfd, ptr);
    return true;
  }
+ 
+ static boolean
+ elfNN_ia64_hpux_vec (const bfd_target *vec)
+ {
+   extern const bfd_target bfd_elfNN_ia64_hpux_big_vec;
+ 
+   return (vec == & bfd_elfNN_ia64_hpux_big_vec);
+ }
+ 
+ static void
+ elfNN_hpux_post_process_headers (abfd, info)
+      bfd *abfd;
+      struct bfd_link_info *info ATTRIBUTE_UNUSED;
+ {
+   Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
+ 
+   i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_HPUX;
+   i_ehdrp->e_ident[EI_ABIVERSION] = 1;
+ }
+ 
+ boolean
+ elfNN_hpux_backend_section_from_bfd_section (abfd, hdr, sec, retval)
+      bfd *abfd ATTRIBUTE_UNUSED;
+      Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED;
+      asection *sec;
+      int *retval;
+ {
+   if (bfd_is_com_section(sec))
+     {
+       *retval = SHN_IA_64_ANSI_COMMON;
+       return true;
+     }
+   return false;
+ }
  
  #define TARGET_LITTLE_SYM		bfd_elfNN_ia64_little_vec
  #define TARGET_LITTLE_NAME		"elfNN-ia64-little"
*************** elfNN_ia64_print_private_bfd_data (abfd,
*** 4406,4410 ****
--- 4456,4483 ----
  #define bfd_elfNN_bfd_link_add_symbols 	elfNN_ia64_aix_link_add_symbols
  
  #define elfNN_bed elfNN_ia64_aix_bed
+ 
+ #include "elfNN-target.h"
+ 
+ /* HPUX-specific vectors.  */
+ 
+ #undef  TARGET_LITTLE_SYM
+ #undef  TARGET_LITTLE_NAME
+ #undef  TARGET_BIG_SYM
+ #define TARGET_BIG_SYM                  bfd_elfNN_ia64_hpux_big_vec
+ #undef  TARGET_BIG_NAME
+ #define TARGET_BIG_NAME                 "elfNN-ia64-hpux-big"
+ 
+ #undef  elf_backend_post_process_headers
+ #define elf_backend_post_process_headers elfNN_hpux_post_process_headers
+ 
+ #undef  elf_backend_section_from_bfd_section
+ #define elf_backend_section_from_bfd_section elfNN_hpux_backend_section_from_bfd_section
+ 
+ #undef  ELF_MAXPAGESIZE
+ #define ELF_MAXPAGESIZE                 0x1000  /* 1K */
+ 
+ #undef  elfNN_bed
+ #define elfNN_bed elfNN_ia64_hpux_bed
  
  #include "elfNN-target.h"


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