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]

hppa patchset 1 of 4


I'd like to merge my current work on parisc binutils into
sourceware.  Now is an appropriate time, since this should result in
working elf32hppa support, at least for static linking and non-pic
code.  Expect some more changes later for shared libraries and other
goodies.

This lot is bfd/ minus changes to elf32-hppa.c.  I'm not posting them
(unless requested) because they're rather major and Jeff has said he is
happy to pass "ownership" of the elf32-hppa code to me.

Regards, Alan Modra
-- 
Linuxcare.  Support for the Revolution.

bfd/ChangeLog
	* elf64-hppa.c (elf64_hppa_dyn_hash_table_init): Add
	ATTRIBUTE_UNUSED to unused args.
	(get_opd): Likewise.
	(get_plt): Likewise.
	(get_dlt): Likewise.
	(get_stub): Likewise.
	(elf64_hppa_adjust_dynamic_symbol): Likewise.
	(elf64_hppa_link_output_symbol_hook): Likewise.
	(elf64_hppa_check_relocs): Delete unused var.
	(elf64_hppa_size_dynamic_sections): Likewise.
	(elf64_hppa_finalize_opd): Likewise.
	(elf64_hppa_finalize_dynreloc): Likewise.
	(elf64_hppa_modify_segment_map): Likewise.
	(elf64_hppa_finish_dynamic_sections): Likewise.

	* elf-hppa.h (elf_hppa_final_write_processing): Add
	ATTRIBUTE_UNUSED to unused args.
	(elf_hppa_final_link_relocate): Likewise.
	(elf_hppa_record_segment_addrs): Add paretheses.
	(elf_hppa_relocate_section): Constify dyn_name.

	From  David Huggins-Daines  <dhd@linuxcare.com>
	* config.bfd: Add hppa*64*-*-linux-gnu 64-bit target, and
	rearrange case statement so that it gets preferred to 32-bit ones.

	* elf32-hppa.c (elf32_hppa_bfd_final_link_relocate): Use
	asection->id instead of address of asection structure.
	(elf32_hppa_size_stubs): Likewise.

	* elf32-hppa.c (elf32_hppa_size_stubs): Use just one stub section
	for .init* and .fini*.

	* elf32-hppa.c (elf32_hppa_bfd_final_link_relocate): Mask pointers
	and addends used in stub names to 32 bits.
	(elf32_hppa_size_stubs): Likewise.

	* elf-hppa.h (elf_hppa_final_link_relocate): Don't sum addend
	twice for R_PARISC_GPREL64.  Use bfd_put_32 for R_PARISC_PCREL32,
	not bfd_put_64.  Fix minor comment typo and formatting.

	Changes to create multiple linker stubs, positioned immediately
	before the section where they are required.
	* elf32-hppa.c: Don't include hppa_stubs.h.
	(elf32_hppa_stub_hash_entry): Add a pointer to the stub section.
	(elf32_hppa_stub_hash_table): Delete.
	(elf32_hppa_link_hash_entry): Delete.
	(elf32_hppa_link_hash_table): Use plain bfd_hash_table for
	stub_hash_table, and store the struct here rather than a pointer.
	Delete output_symbol_count.  Add offset array.  Change
	global_value to a bfd_vma.
	(elf32_hppa_stub_hash_lookup): Use table instead of table->root.
	(elf32_hppa_stub_hash_traverse): Delete.
	(elf32_hppa_name_of_stub): Delete.
	(elf32_hppa_link_hash_lookup): Delete.
	(elf32_hppa_link_hash_traverse): Delete.
	(elf32_hppa_stub_hash_table_init): Delete.
	(elf32_hppa_size_of_stub): Pass input section and offset rather
	than location and calculate location here.  Don't pass name as all
	stubs are now the same size.
	(elf32_hppa_stub_hash_newfunc): Init new fields.
	(elf32_hppa_link_hash_table_create): Likewise, and stub_hash_table
	too.
	(elf32_hppa_bfd_final_link_relocate): Cast enums to int before
	comparing against ints.  Rewrite stub handling code.
	(elf32_hppa_relocate_section): Make r_type and r_symndx unsigned.
	Case enums to int before comparing against ints.  Remove
	bfd_reloc_dangerous case.
	(elf32_hppa_build_one_stub): Rewrite.
	(elf32_hppa_size_one_stub): New function.
	(elf32_hppa_build_stubs): Rewrite.
	(elf32_hppa_size_stubs): Pass in linker call-back functions.
	Rewrite stub-handling specific code.

	* elf32-hppa.h (elf32_hppa_size_stubs): Update prototype.

	* elf64-hppa.c (elf64_hppa_dyn_hash_entry): Fix a comment typo.

	* hppa_stubs.h: Delete.
	* Makefile.am (SOURCE_HFILES): Remove hppa_stubs.h
	(elf32-hppa.lo): Remove hppa_stubs.h from dependencies.
	* Makefile.in: Regenerate.

	* elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): Handle e_nlsel and
	e_nlrsel.

	* libhppa.h (hppa_field_adjust): Correct e_nsel case.

	* elf32-hppa.c (elf32_hppa_relocate_section): Mention the offset
	and section name for bfd_reloc_notsupported error message.
	(elf32_hppa_bfd_final_link_relocate): Print reasons for returning
	bfd_reloc_notsupported.
	(elf32_hppa_relocate_section): Add ATTRIBUTE_UNUSED to output_bfd.

	* elf32-hppa.c (elf32_hppa_bfd_final_link_relocate): Handle
	undefined weak symbols for all relocs.
	(elf32_hppa_size_of_stub): Adjust calculation by 8 since branch
	offsets are relative to one past the delay slot.
	(elf32_hppa_size_stubs): Account for reloc addend when calculating
	branch destination.  Put addend into stub name too.
	(elf32_hppa_bfd_final_link_relocate): Account for reloc addend and
	adjust by 8 when deciding whether a linker stub is needed.  Put
	addend into stub name as for above.

	* elf32-hppa.c (hppa_elf_relocate_insn): Change signed/unsigned on
	various args and vars.
	(elf32_hppa_bfd_final_link_relocate): Here too.
	(elf32_hppa_size_stubs): Rename index -> indx.  Use e_indx for
	inner block var to avoid shadowing.

	* elf32-hppa.h (_bfd_elf32_hppa_gen_reloc_type):  Make `field' arg
	unsigned.
	* elf64-hppa.h (_bfd_elf64_hppa_gen_reloc_type): Ditto.
	* elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): Ditto.
	(elf_hppa_fake_sections): Rename local var to avoid shadowing.

	* libhppa.h: Change practically all unsigned ints to plain ints.
	Remove tests on gcc version.  Instead use ATTRIBUTE_UNUSED for
	prototypes.

	From Ryan Bradetich  <rbradetich@uswest.net>
	* libhppa.h (hppa_opcode_type): New enum to replace #define's.
	* elf32-hppa.c (elf32_hppa_bfd_final_link_relocate): Modify to
	suit above.
	From  David Huggins-Daines  <dhd@linuxcare.com>
	* elf-hppa.h (elf_hppa_relocate_insn): Update the opcode constants
	to the new OP_* ones.

	* elf32-hppa.c (elf32_hppa_size_stubs): Consolidate freeing on
	error exit.  Bail out earlier on plabel relocs that we aren't
	interested in.  Don't tell elf32_hppa_stub_hash_lookup to copy
	string, and then don't free our copy.
	(elf32_hppa_build_one_stub): Make insn unsigned int.

	* libhppa.h (bfd_hppa_insn2fmt): 22 bit branches are only
	available with BL, not BE and BLE.

	* elf32-hppa.c (hppa_elf_relocate_insn): Add some more example
	code for elf arg relocs.
	(elf32_hppa_bfd_final_link_relocate): Replace boolean is_local
	argument with elf_link_hash_entry h.  Handle undefined weak
	symbols.  Move $global$ lookup from here...
	(elf32_hppa_relocate_section): ...to here.  Return correct error
	message for non-handled relocs.
	(elf32_hppa_size_of_stub): Correctly test branch range.  Previous
	wrong test was -0x3ffff to +0x40000.

	* elf-hppa.h (elf_hppa_final_link_relocate): R_PARISC_DIR17R,
	R_PARISC_DIR17F, and R_PARISC_DIR21L are for absolute branches;
	Handle them as such.
	(elf_hppa_relocate_insn): Fix a typo.

	* libhppa.h (GET_FIELD, GET_BIT, MASK, CATENATE, ELEVEN): Delete.
	(assemble_3, assemble_6, assemble_12, assemble_16, assemble_16a,
	assemble_17, assemble_21): Delete.
	Supply defines for all 64 possible opcodes.
	(bfd_hppa_insn2fmt): Add bfd argument, and use to select wide mode
	formats.  Handle COMICLR.
	(hppa_rebuild_insn): Delete bfd argument.  Handle formats 10, -11,
	-10, -16, 16, 22.

	* elf32-hppa.c (hppa_elf_relocate_insn): Complete rewrite.
	(elf32_hppa_bfd_final_link_relocate): Major rewrite.
	(elf32_hppa_build_one_stub): Modify hppa_elf_relocate_insn calls
	to suit.
	(elf32_hppa_size_stubs): Don't free stub_name twice.  Read in all
	the local syms - did this code get deleted accidentally?  Ignore
	undefined and undefweak syms.

	* elf-hppa.h (elf_hppa_final_link): Move hppa_info to outermost
	block.  Use it instead of elf64_hppa_hash_table (info).
	(elf_hppa_final_link_relocate): Use hppa_info instead of
	elf64_hppa_hash_table (info).

	* libhppa.h (re_assemble_3, re_assemble_12, re_assemble_16,
	re_assemble_17, re_assemble_21, re_assemble_22): Don't mask insn.
	(hppa_rebuild_insn): Mask immediate bits here instead.
	* elf-hppa.h (elf_hppa_relocate_insn): Mask here too.

Index: bfd/Makefile.am
===================================================================
RCS file: /cvs/src/src/bfd/Makefile.am,v
retrieving revision 1.36
diff -u -p -r1.36 Makefile.am
--- Makefile.am	2000/07/01 01:41:08	1.36
+++ Makefile.am	2000/07/08 13:44:51
@@ -470,7 +470,7 @@ SOURCE_HFILES = \
 	aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h ecoffswap.h \
 	elf-bfd.h elf-hppa.h elf32-arm.h elf32-hppa.h elf64-hppa.h \
 	elfcode.h elfcore.h elflink.h freebsd.h genlink.h go32stub.h \
-	hppa_stubs.h libaout.h libbfd.h libcoff.h libecoff.h libhppa.h \
+	libaout.h libbfd.h libcoff.h libecoff.h libhppa.h \
 	libieee.h libnlm.h liboasys.h libpei.h netbsd.h nlm-target.h \
 	nlmcode.h nlmswap.h ns32k.h peicode.h som.h vms.h xcoff-target.h
 
@@ -931,7 +931,7 @@ elf32-gen.lo: elf32-gen.c $(INCDIR)/file
 elf32-hppa.lo: elf32-hppa.c $(INCDIR)/filenames.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.h \
-  libhppa.h elf32-hppa.h elf-hppa.h hppa_stubs.h elf32-target.h
+  libhppa.h elf32-hppa.h elf-hppa.h elf32-target.h
 elf32-i370.lo: elf32-i370.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
   $(INCDIR)/elf/external.h $(INCDIR)/elf/i370.h elf32-target.h
Index: bfd/config.bfd
===================================================================
RCS file: /cvs/src/src/bfd/config.bfd,v
retrieving revision 1.35
diff -u -p -r1.35 config.bfd
--- config.bfd	2000/07/02 01:17:52	1.35
+++ config.bfd	2000/07/08 13:44:57
@@ -230,15 +230,20 @@ case "${targ}" in
     targ_underscore=yes
     ;;
 
-  hppa*-*-*elf* | hppa*-*-linux-gnu* | hppa*-*-lites* | hppa*-*-sysv4* | hppa*-*-rtems*)
-    targ_defvec=bfd_elf32_hppa_vec
-    ;;
 #ifdef BFD64
+  hppa*64*-*-linux-gnu*)
+    targ_defvec=bfd_elf64_hppa_vec
+    ;;
   hppa*64*-*-hpux11*)
     targ_defvec=bfd_elf64_hppa_vec
     targ_cflags=-DHPUX_LARGE_AR_IDS
     ;;
 #endif
+
+  hppa*-*-*elf* | hppa*-*-linux-gnu* | hppa*-*-lites* | hppa*-*-sysv4* | hppa*-*-rtems*)
+    targ_defvec=bfd_elf32_hppa_vec
+    ;;
+
 #if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) || defined (HOST_HPPAMPEIX)
   hppa*-*-bsd*)
     targ_defvec=som_vec
Index: bfd/elf-hppa.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-hppa.h,v
retrieving revision 1.43
diff -u -p -r1.43 elf-hppa.h
--- elf-hppa.h	2000/05/31 09:00:00	1.43
+++ elf-hppa.h	2000/07/08 13:45:02
@@ -45,7 +45,7 @@ Foundation, Inc., 59 Temple Place - Suit
 #endif
 
 elf_hppa_reloc_type ** _bfd_elf_hppa_gen_reloc_type
-  PARAMS ((bfd *, elf_hppa_reloc_type, int, int, int, asymbol *));
+  PARAMS ((bfd *, elf_hppa_reloc_type, int, unsigned int, int, asymbol *));
 
 static void elf_hppa_info_to_howto
   PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
@@ -604,7 +604,7 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base
      bfd *abfd;
      elf_hppa_reloc_type base_type;
      int format;
-     int field;
+     unsigned int field;
      int ignore ATTRIBUTE_UNUSED;
      asymbol *sym ATTRIBUTE_UNUSED;
 {
@@ -688,6 +688,8 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base
 	    {
 	    case e_lsel:
 	    case e_lrsel:
+	    case e_nlsel:
+	    case e_nlrsel:
 	      final_type = R_PARISC_DIR21L;
 	      break;
 	    case e_ltsel:
@@ -751,9 +753,11 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base
 	    {
 	    case e_rsel:
 	    case e_rrsel:
+	      /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32  */
 	      final_type = base_type + OFFSET_14R_FROM_21L;
 	      break;
 	    case e_fsel:
+	      /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32  */
 	      final_type = base_type + OFFSET_14F_FROM_21L;
 	      break;
 	    default:
@@ -764,8 +768,11 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base
 	case 21:
 	  switch (field)
 	    {
-	    case e_lrsel:
 	    case e_lsel:
+	    case e_lrsel:
+	    case e_nlsel:
+	    case e_nlrsel:
+	      /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32  */
 	      final_type = base_type;
 	      break;
 	    default:
@@ -812,23 +819,25 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base
 	    }
 	  break;
 
-	case 22:
+	case 21:
 	  switch (field)
 	    {
-	    case e_fsel:
-	      final_type = R_PARISC_PCREL22F;
+	    case e_lsel:
+	    case e_lrsel:
+	    case e_nlsel:
+	    case e_nlrsel:
+	      final_type = R_PARISC_PCREL21L;
 	      break;
 	    default:
 	      return NULL;
 	    }
 	  break;
 
-	case 21:
+	case 22:
 	  switch (field)
 	    {
-	    case e_lsel:
-	    case e_lrsel:
-	      final_type = R_PARISC_PCREL21L;
+	    case e_fsel:
+	      final_type = R_PARISC_PCREL22F;
 	      break;
 	    default:
 	      return NULL;
@@ -920,7 +929,7 @@ elf_hppa_fake_sections (abfd, hdr, sec)
   if (strcmp (name, ".PARISC.unwind") == 0)
     {
       int indx;
-      asection *sec;
+      asection *asec;
 #if ARCH_SIZE == 64
       hdr->sh_type = SHT_LOPROC + 1;
 #else
@@ -935,9 +944,9 @@ elf_hppa_fake_sections (abfd, hdr, sec)
 
 	 So we (gasp) recompute it here.  Hopefully nobody ever changes the
 	 way sections are numbered in elf.c!  */
-      for (sec = abfd->sections, indx = 1; sec; sec = sec->next, indx++)
+      for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++)
 	{
-	  if (sec->name && strcmp (sec->name, ".text") == 0)
+	  if (asec->name && strcmp (asec->name, ".text") == 0)
 	    {
 	      hdr->sh_info = indx;
 	      break;
@@ -954,7 +963,7 @@ elf_hppa_fake_sections (abfd, hdr, sec)
 static void
 elf_hppa_final_write_processing (abfd, linker)
      bfd *abfd;
-     boolean linker;
+     boolean linker ATTRIBUTE_UNUSED;
 {
   int mach = bfd_get_mach (abfd);
 
@@ -1095,13 +1104,13 @@ elf_hppa_record_segment_addrs (abfd, sec
 
   value = section->vma - section->filepos;
 
-  if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
+  if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
        == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
       && value < hppa_info->text_segment_base)
     hppa_info->text_segment_base = value;
-  else if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
-       == (SEC_ALLOC | SEC_LOAD))
-      && value < hppa_info->data_segment_base)
+  else if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
+	    == (SEC_ALLOC | SEC_LOAD))
+	   && value < hppa_info->data_segment_base)
     hppa_info->data_segment_base = value;
 }
 
@@ -1117,14 +1126,12 @@ elf_hppa_final_link (abfd, info)
      struct bfd_link_info *info;
 {
   boolean retval;
+  struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
 
   if (! info->relocateable)
     {
       struct elf_link_hash_entry *gp;
       bfd_vma gp_val;
-      struct elf64_hppa_link_hash_table *hppa_info;
-
-      hppa_info = elf64_hppa_hash_table (info);
 
       /* The linker script defines a value for __gp iff it was referenced
 	 by one of the objects being linked.  First try to find the symbol
@@ -1139,7 +1146,7 @@ elf_hppa_final_link (abfd, info)
 	  /* Adjust the value of __gp as we may want to slide it into the
 	     .plt section so that the stubs can access PLT entries without
 	     using an addil sequence.  */
-	  gp->root.u.def.value += elf64_hppa_hash_table (info)->gp_offset;
+	  gp->root.u.def.value += hppa_info->gp_offset;
 
 	  gp_val = (gp->root.u.def.section->output_section->vma
 		    + gp->root.u.def.section->output_offset
@@ -1181,10 +1188,10 @@ elf_hppa_final_link (abfd, info)
     }
 
   /* We need to know the base of the text and data segments so that we
-     can perform SEGREL relocations.  We will recore the base addresses
+     can perform SEGREL relocations.  We will record the base addresses
      when we encounter the first SEGREL relocation.  */
-  elf64_hppa_hash_table (info)->text_segment_base = (bfd_vma)-1;
-  elf64_hppa_hash_table (info)->data_segment_base = (bfd_vma)-1;
+  hppa_info->text_segment_base = (bfd_vma)-1;
+  hppa_info->data_segment_base = (bfd_vma)-1;
 
   /* HP's shared libraries have references to symbols that are not
      defined anywhere.  The generic ELF BFD linker code will complaim
@@ -1243,7 +1250,7 @@ elf_hppa_relocate_section (output_bfd, i
       bfd_vma relocation;
       bfd_reloc_status_type r;
       const char *sym_name;
-      char *dyn_name;
+      const char *dyn_name;
       char *dynh_buf = NULL;
       size_t dynh_buflen = 0;
       struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
@@ -1442,7 +1449,7 @@ elf_hppa_final_link_relocate (rel, input
      bfd_vma value;
      struct bfd_link_info *info;
      asection *sym_sec;
-     struct elf_link_hash_entry *h;
+     struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
      struct elf64_hppa_dyn_hash_entry *dyn_h;
 {
   unsigned int insn;
@@ -1560,7 +1567,7 @@ elf_hppa_final_link_relocate (rel, input
     case R_PARISC_LTOFF16DF:
       {
 	/* If this relocation was against a local symbol, then we still
-	   have not set up the DLT entry (it's not convienent to do so
+	   have not set up the DLT entry (it's not convenient to do so
 	   in the "finalize_dlt" routine because it is difficult to get
 	   to the local symbol's value).
 
@@ -1822,7 +1829,6 @@ elf_hppa_final_link_relocate (rel, input
       /* Subtract out the global pointer value to make value a DLT
 	 relative address.  */
       value -= _bfd_get_gp_value (output_bfd);
-      value += addend;
 
       bfd_put_64 (input_bfd, value + addend, hit_data);
       return bfd_reloc_ok;
@@ -1855,7 +1861,7 @@ elf_hppa_final_link_relocate (rel, input
 
 	value += addend;
 	value -= 8;
-	bfd_put_64 (input_bfd, value, hit_data);
+	bfd_put_32 (input_bfd, value, hit_data);
 	return bfd_reloc_ok;
       }
 
@@ -1913,8 +1919,7 @@ elf_hppa_final_link_relocate (rel, input
 
     case R_PARISC_SECREL32:
       bfd_put_32 (input_bfd,
-		  (value + addend
-		   - sym_sec->output_section->vma),
+		  value + addend - sym_sec->output_section->vma,
 		  hit_data);
       return bfd_reloc_ok;
 
@@ -1925,7 +1930,7 @@ elf_hppa_final_link_relocate (rel, input
 	   the segment base values.  */
 	if (hppa_info->text_segment_base == (bfd_vma) -1)
 	  bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs,
-				 elf64_hppa_hash_table (info));
+				 hppa_info);
 
 	/* VALUE holds the absolute address.  We want to include the
 	   addend, then turn it into a segment relative address.
@@ -1955,7 +1960,7 @@ elf_hppa_final_link_relocate (rel, input
 
   /* Update the instruction word.  */
   bfd_put_32 (input_bfd, insn, hit_data);
-  return (bfd_reloc_ok);
+  return bfd_reloc_ok;
 }
 
 /* Relocate the given INSN.  VALUE should be the actual value we want
@@ -1976,7 +1981,7 @@ elf_hppa_relocate_insn (insn, sym_value,
        the "B" instruction.  */
     case R_PARISC_PCREL22F:
     case R_PARISC_PCREL22C:
-      return re_assemble_22 (insn & ~ 0x3ff1ffd, sym_value);
+      return (insn & ~ 0x3ff1ffd) | re_assemble_22 (sym_value);
 
     /* This is any 17bit branch.  In PA2.0 syntax it also corresponds to
        the "B" instruction as well as BE.  */
@@ -1985,7 +1990,7 @@ elf_hppa_relocate_insn (insn, sym_value,
     case R_PARISC_DIR17R:
     case R_PARISC_PCREL17C:
     case R_PARISC_PCREL17R:
-      return re_assemble_17 (insn & ~ 0x1f1ffd, sym_value);
+      return (insn & ~ 0x1f1ffd) | re_assemble_17 (sym_value);
 
     /* ADDIL or LDIL instructions.  */
     case R_PARISC_DLTREL21L:
@@ -1996,7 +2001,7 @@ elf_hppa_relocate_insn (insn, sym_value,
     case R_PARISC_DPREL21L:
     case R_PARISC_PLTOFF21L:
     case R_PARISC_DIR21L:
-      return re_assemble_21 (insn & ~ 0x1fffff, sym_value);
+      return (insn & ~ 0x1fffff) | re_assemble_21 (sym_value);
 
     /* LDO and integer loads/stores with 14bit displacements.  */
     case R_PARISC_DLTREL14R:
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.1
diff -u -p -r1.1 elf64-hppa.c
--- elf64-hppa.c	2000/04/24 08:17:57	1.1
+++ elf64-hppa.c	2000/07/08 13:45:12
@@ -55,7 +55,7 @@ struct elf64_hppa_dyn_hash_entry
   bfd_vma opd_offset;
   bfd_vma stub_offset;
 
-  /* The symbol table entry, if any, that this was derrived from.  */
+  /* The symbol table entry, if any, that this was derived from.  */
   struct elf_link_hash_entry *h;
 
   /* The index of the (possibly local) symbol in the input bfd and its
@@ -262,7 +262,7 @@ static boolean get_stub
 static boolean
 elf64_hppa_dyn_hash_table_init (ht, abfd, new)
      struct elf64_hppa_dyn_hash_table *ht;
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      new_hash_entry_func new;
 {
   memset (ht, 0, sizeof(*ht));
@@ -575,7 +575,6 @@ elf64_hppa_check_relocs (abfd, info, sec
   if (info->shared && hppa_info->section_syms_bfd != abfd)
     {
       int i, highest_shndx;
-      asection *section;
       Elf_Internal_Sym *local_syms, *isym;
       Elf64_External_Sym *ext_syms, *esym;
 
@@ -1177,7 +1176,7 @@ elf64_hppa_post_process_headers (abfd, l
 static boolean
 get_opd (abfd, info, hppa_info)
      bfd *abfd;
-     struct bfd_link_info *info;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
      struct elf64_hppa_link_hash_table *hppa_info;
 {
   asection *opd;
@@ -1215,7 +1214,7 @@ get_opd (abfd, info, hppa_info)
 static boolean
 get_plt (abfd, info, hppa_info)
      bfd *abfd;
-     struct bfd_link_info *info;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
      struct elf64_hppa_link_hash_table *hppa_info;
 {
   asection *plt;
@@ -1253,7 +1252,7 @@ get_plt (abfd, info, hppa_info)
 static boolean
 get_dlt (abfd, info, hppa_info)
      bfd *abfd;
-     struct bfd_link_info *info;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
      struct elf64_hppa_link_hash_table *hppa_info;
 {
   asection *dlt;
@@ -1291,7 +1290,7 @@ get_dlt (abfd, info, hppa_info)
 static boolean
 get_stub (abfd, info, hppa_info)
      bfd *abfd;
-     struct bfd_link_info *info;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
      struct elf64_hppa_link_hash_table *hppa_info;
 {
   asection *stub;
@@ -1510,7 +1509,7 @@ allocate_dynrel_entries (dyn_h, data)
 
 static boolean
 elf64_hppa_adjust_dynamic_symbol (info, h)
-     struct bfd_link_info *info;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
      struct elf_link_hash_entry *h;
 {
   /* ??? Undefined symbols with PLT entries should be re-defined
@@ -1551,7 +1550,6 @@ elf64_hppa_size_dynamic_sections (output
   boolean plt;
   boolean relocs;
   boolean reltext;
-  boolean stubs;
   struct elf64_hppa_allocate_data data;
   struct elf64_hppa_link_hash_table *hppa_info;
 
@@ -1807,11 +1805,11 @@ elf64_hppa_size_dynamic_sections (output
 
 static boolean
 elf64_hppa_link_output_symbol_hook (abfd, info, name, sym, input_sec)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      struct bfd_link_info *info;
      const char *name;
      Elf_Internal_Sym *sym;
-     asection *input_sec;
+     asection *input_sec ATTRIBUTE_UNUSED;
 {
   struct elf64_hppa_link_hash_table *hppa_info;
   struct elf64_hppa_dyn_hash_entry *dyn_h;
@@ -2038,7 +2036,6 @@ elf64_hppa_finalize_opd (dyn_h, data)
   if (info->shared && dyn_h && dyn_h->want_opd)
     {
       Elf64_Internal_Rela rel;
-      bfd_vma value;
       int dynindx;
 
       /* We may need to do a relocation against a local symbol, in
@@ -2287,8 +2284,6 @@ elf64_hppa_finalize_dynreloc (dyn_h, dat
 	  if (info->shared && rent->type == R_PARISC_FPTR64)
 	    {
 	      bfd_vma value, value2;
-	      asymbol *sym;
-	      int elf_index;
 
 	      /* First compute the address of the opd entry for this symbol.  */
 	      value = (dyn_h->opd_offset
@@ -2366,7 +2361,6 @@ elf64_hppa_finish_dynamic_sections (outp
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       Elf64_External_Dyn *dyncon, *dynconend;
-      struct elf_link_hash_entry *h;
 
       BFD_ASSERT (sdyn != NULL);
 
@@ -2488,7 +2482,7 @@ static boolean
 elf64_hppa_modify_segment_map (abfd)
      bfd *abfd;
 {
-  struct elf_segment_map *m, **pm;
+  struct elf_segment_map *m;
   asection *s;
 
   s = bfd_get_section_by_name (abfd, ".interp");
Index: bfd/elf64-hppa.h
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.h,v
retrieving revision 1.1
diff -u -p -r1.1 elf64-hppa.h
--- elf64-hppa.h	2000/04/24 08:17:57	1.1
+++ elf64-hppa.h	2000/07/08 13:45:12
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suit
 #include "elf/hppa.h"
 
 extern elf_hppa_reloc_type ** _bfd_elf64_hppa_gen_reloc_type
-  PARAMS ((bfd *, elf_hppa_reloc_type, int, int, int, asymbol *));
+  PARAMS ((bfd *, elf_hppa_reloc_type, int, unsigned int, int, asymbol *));
 
 /* Define groups of basic relocations.  FIXME:  These should
    be the only basic relocations created by GAS.  The rest
Index: bfd/hppa_stubs.h
===================================================================
RCS file: hppa_stubs.h
diff -N hppa_stubs.h
--- /sourceware/cvs-tmp/cvsxnfFzf	Sat Jul  8 06:46:58 2000
+++ /dev/null	Tue May  5 13:32:27 1998
@@ -1,23 +0,0 @@
-/* HPPA linker stub instructions  */
-
-/* These are the instructions which the linker may insert into the
-   code stream when building final executables to handle out-of-range
-   calls and argument relocations.  */
-
-#define LDO_M4_R31_R31		0x37ff3ff9	/* ldo -4(%r31),%r31	  */
-#define LDIL_R1			0x20200000	/* ldil XXX,%r1		  */
-#define BE_SR4_R1		0xe0202000	/* be XXX(%sr4,%r1)	  */
-#define COPY_R31_R2          	0x081f0242	/* copy %r31,%r2	  */
-#define BLE_SR4_R0		0xe4002000	/* ble XXX(%sr4,%r0)	  */
-#define BLE_SR4_R1		0xe4202000	/* ble XXX(%sr4,%r1)	  */
-#define BV_N_0_R31		0xebe0c002	/* bv,n 0(%r31)		  */
-#define STW_R31_M8R30		0x6bdf3ff1	/* stw %r31,-8(%r30)	  */
-#define LDW_M8R30_R31		0x4bdf3ff1	/* ldw -8(%r30),%r31	  */
-#define STW_ARG_M16R30		0x6bc03fe1	/* stw %argX,-16(%r30)	  */
-#define LDW_M16R30_ARG		0x4bc03fe1	/* ldw -12(%r30),%argX	  */
-#define STW_ARG_M12R30		0x6bc03fe9	/* stw %argX,-16(%r30)	  */
-#define LDW_M12R30_ARG		0x4bc03fe9	/* ldw -12(%r30),%argX	  */
-#define FSTW_FARG_M16R30	0x27c11200	/* fstws %fargX,-16(%r30) */
-#define FLDW_M16R30_FARG	0x27c11000	/* fldws -16(%r30),%fargX */
-#define FSTD_FARG_M16R30	0x2fc11200	/* fstds %fargX,-16(%r30) */
-#define FLDD_M16R30_FARG	0x2fc11000	/* fldds -16(%r30),%fargX */
Index: bfd/libhppa.h
===================================================================
RCS file: /cvs/src/src/bfd/libhppa.h,v
retrieving revision 1.14
diff -u -p -r1.14 libhppa.h
--- libhppa.h	2000/05/19 00:20:31	1.14
+++ libhppa.h	2000/07/08 13:45:14
@@ -21,8 +21,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
-#ifndef _HPPA_H
-#define _HPPA_H
+#ifndef _LIBHPPA_H
+#define _LIBHPPA_H
 
 #define BYTES_IN_WORD 4
 #define PA_PAGESIZE 0x1000
@@ -159,224 +159,71 @@ enum hppa_reloc_expr_type_alt
   ((((bfd_signed_vma)(a)) << (BFD_ARCH_SIZE-22)) >> (BFD_ARCH_SIZE-22))
 #define HPPA_R_ADDEND(r, c)	\
   (((r) << 22) + ((c) & 0x3fffff))
-#define HPPA_WIDE	       (0) /* PSW W-bit, need to check! FIXME */
 
-/* These macros get bit fields using HP's numbering (MSB = 0),
- * but note that "MASK" assumes that the LSB bits are what's
- * wanted.
- */
-#ifndef GET_FIELD
-#define GET_FIELD(X, FROM, TO) \
-  ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
-#endif
-#define GET_BIT(X, WHICH) \
-  GET_FIELD (X, WHICH, WHICH)
 
-#define MASK(SIZE) \
-  (~((-1) << SIZE))
-
-#define CATENATE(X, XSIZE, Y, YSIZE) \
-  (((X & MASK (XSIZE)) << YSIZE) | (Y & MASK (YSIZE)))
-
-#define ELEVEN(X) \
-  CATENATE (GET_BIT (X, 10), 1, GET_FIELD (X, 0, 9), 10)
-
 /* Some functions to manipulate PA instructions.  */
 
-/* NOTE: these use the HP convention that f{0} is the _left_ most
- *       bit (MSB) of f; they sometimes have to impose an assumption
- *       about the size of a field; and as far as I can tell, most
- *       aren't used.
- */
-
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
 /* Declare the functions with the unused attribute to avoid warnings.  */
-static INLINE unsigned int sign_extend (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int low_sign_extend (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int assemble_3 (unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int assemble_6 (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int assemble_12 (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int assemble_16 (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int assemble_16a (unsigned int, unsigned int,
-					 unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int assemble_17 (unsigned int, unsigned int,
-					unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int assemble_21 (unsigned int)
-     __attribute ((__unused__));
-
-static INLINE unsigned int sign_unext (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int low_sign_unext (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int re_assemble_3 (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int re_assemble_12 (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int re_assemble_16 (unsigned int, unsigned int, int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int re_assemble_17 (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int re_assemble_22 (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE unsigned int re_assemble_21 (unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-static INLINE bfd_signed_vma hppa_field_adjust (bfd_signed_vma, bfd_signed_vma,
-						enum hppa_reloc_field_selector_type_alt)
-     __attribute__ ((__unused__));
-static INLINE int bfd_hppa_insn2fmt (unsigned int)
-     __attribute__ ((__unused__));
-static INLINE  unsigned int hppa_rebuild_insn (bfd *, unsigned int,
-					       unsigned int, unsigned int)
-     __attribute__ ((__unused__));
-#endif /* gcc 2.7 or higher */
-
-
-/* The *sign_extend and assemble_* functions are used to assemble
-   various bitfields taken from an instruction and return the
-   resulting immediate value.  They correspond to functions by the
-   same name in HP's PA-RISC 2.0 Architecture Reference Manual.  */
+static INLINE int sign_extend PARAMS ((int, int)) ATTRIBUTE_UNUSED;
+static INLINE int low_sign_extend PARAMS ((int, int)) ATTRIBUTE_UNUSED;
+static INLINE int sign_unext PARAMS ((int, int)) ATTRIBUTE_UNUSED;
+static INLINE int low_sign_unext PARAMS ((int, int)) ATTRIBUTE_UNUSED;
+static INLINE int re_assemble_3 PARAMS ((int)) ATTRIBUTE_UNUSED;
+static INLINE int re_assemble_12 PARAMS ((int)) ATTRIBUTE_UNUSED;
+static INLINE int re_assemble_14 PARAMS ((int)) ATTRIBUTE_UNUSED;
+static INLINE int re_assemble_16 PARAMS ((int)) ATTRIBUTE_UNUSED;
+static INLINE int re_assemble_17 PARAMS ((int)) ATTRIBUTE_UNUSED;
+static INLINE int re_assemble_21 PARAMS ((int)) ATTRIBUTE_UNUSED;
+static INLINE int re_assemble_22 PARAMS ((int)) ATTRIBUTE_UNUSED;
+static INLINE bfd_signed_vma hppa_field_adjust
+  PARAMS ((bfd_vma, bfd_signed_vma,
+	   enum hppa_reloc_field_selector_type_alt)) ATTRIBUTE_UNUSED;
+static INLINE int bfd_hppa_insn2fmt PARAMS ((bfd *, int)) ATTRIBUTE_UNUSED;
+static INLINE int hppa_rebuild_insn PARAMS ((int, int, int)) ATTRIBUTE_UNUSED;
+
+
+/* The *sign_extend functions are used to assemble various bitfields
+   taken from an instruction and return the resulting immediate
+   value.  */
 
-static INLINE unsigned int
+static INLINE int
 sign_extend (x, len)
-     unsigned int x, len;
+     int x, len;
 {
-  unsigned int signbit = (1 << (len - 1));
-  unsigned int mask = (signbit << 1) - 1;
+  int signbit = (1 << (len - 1));
+  int mask = (signbit << 1) - 1;
   return ((x & mask) ^ signbit) - signbit;
 }
 
-static INLINE unsigned int
+static INLINE int
 low_sign_extend (x, len)
-     unsigned int x, len;
+     int x, len;
 {
   return (x >> 1) - ((x & 1) << (len - 1));
 }
 
-static INLINE unsigned int
-assemble_3 (x)
-     unsigned int x;
-{
-  return CATENATE (GET_BIT (x, 2), 1, GET_FIELD (x, 0, 1), 2);
-}
-
-static INLINE unsigned int
-assemble_6 (x, y)
-     unsigned int x, y;
-{
-  return (((x & 1) << 5) + (32 - (y & 0x1f)));
-}
-
-static INLINE unsigned int
-assemble_12 (x, y)
-     unsigned int x, y;
-{
-  return CATENATE (CATENATE (y, 1, GET_BIT (x, 10), 1), 2,
- 		   GET_FIELD (x, 0, 9), 9);
-}
-
-static INLINE unsigned int
-assemble_16 (x, y)
-     unsigned int x, y;
-{
-  /* Depends on PSW W-bit !*/
-  unsigned int temp;
-
-  if (HPPA_WIDE)
-    temp = CATENATE (CATENATE (GET_BIT (y, 13), 1,
-			       (GET_BIT (y, 13) ^ GET_BIT (x, 0)), 1), 2,
-		     CATENATE ((GET_BIT (y, 13) ^ GET_BIT (x, 1)), 1,
-			       GET_FIELD (y, 0, 12), 13), 14);
-  else
-    temp = CATENATE (CATENATE (GET_BIT (y, 13), 1, GET_BIT (y, 13), 1), 2,
-		     CATENATE (GET_BIT (y, 13), 1, GET_FIELD (y, 0, 12), 13), 14);
-
-  return sign_extend (temp, 16);
-}
-
-static INLINE unsigned int
-assemble_16a (x, y, z)
-     unsigned int x, y, z;
-{
-  /* Depends on PSW W-bit !*/
-  unsigned int temp;
-
-  if (HPPA_WIDE)
-    temp = CATENATE (CATENATE (z, 1, (z ^ GET_BIT (x, 0)), 1), 2,
-		     CATENATE ((z ^ GET_BIT (x, 1)), 1, y, 11), 12);
-  else
-    temp = CATENATE (CATENATE (z, 1, z, 1), 2, CATENATE (z, 1, y, 11), 12);
-
-  return sign_extend ((temp << 2), 16);
-}
-
-static INLINE unsigned int
-assemble_17 (x, y, z)
-     unsigned int x, y, z;
-{
-  unsigned int temp;
-
-  temp = CATENATE (CATENATE (z, 1, x, 5), 6,
-		   CATENATE (GET_BIT (y, 10), 1, GET_FIELD (y, 0, 9), 10), 11);
-
-  return temp;
-}
-
-static INLINE unsigned int
-assemble_21 (x)
-     unsigned int x;
-{
-  unsigned int temp;
-
-  temp = ((  (x & 0x000001) << 20)
-	  | ((x & 0x000ffe) << 8)
-	  | ((x & 0x003000) >> 12)
-	  | ((x & 0x00c000) >> 7)
-	  | ((x & 0x1f0000) >> 14));
-  return temp;
-}
-
-static INLINE unsigned int
-assemble_22 (a,b,c,d)
-     unsigned int a,b,c,d;
-{
-  unsigned int temp;
-
-  temp = CATENATE (CATENATE (d, 1, a, 5), 6,
-		   CATENATE (b, 5, ELEVEN (c), 11), 16);
-
-  return sign_extend (temp, 22);
-}
 
+/* The re_assemble_* functions prepare an immediate value for
+   insertion into an opcode. pa-risc uses all sorts of weird bitfields
+   in the instruction to hold the value.  */
 
-/* The re_assemble_* functions splice together an opcode and an
-   immediate value.  pa-risc uses all sorts of weird bitfields in the
-   instruction to hold the value.  */
-
-static INLINE unsigned int
+static INLINE int
 sign_unext (x, len)
-     unsigned int x, len;
+     int x, len;
 {
-  unsigned int len_ones;
+  int len_ones;
 
-  len_ones = ((unsigned int) 1 << len) - 1;
+  len_ones = (1 << len) - 1;
 
   return x & len_ones;
 }
 
-static INLINE unsigned int
+static INLINE int
 low_sign_unext (x, len)
-     unsigned int x, len;
+     int x, len;
 {
-  unsigned int temp;
-  unsigned int sign;
+  int temp;
+  int sign;
 
   sign = (x >> (len-1)) & 1;
 
@@ -385,83 +232,69 @@ low_sign_unext (x, len)
   return (temp << 1) | sign;
 }
 
-static INLINE unsigned int
-re_assemble_3 (insn, as3)
-     unsigned int insn;
-     unsigned int as3;
+static INLINE int
+re_assemble_3 (as3)
+     int as3;
 {
-  return (insn
-	  | ((as3 & 4) << (13-2))
+  return ((  (as3 & 4) << (13-2))
 	  | ((as3 & 3) << (13+1)));
 }
 
-static INLINE unsigned int
-re_assemble_12 (insn, as12)
-     unsigned int insn;
-     unsigned int as12;
+static INLINE int
+re_assemble_12 (as12)
+     int as12;
 {
-  return (insn
-	  | ((as12 & 0x800) >> 11)
+  return ((  (as12 & 0x800) >> 11)
 	  | ((as12 & 0x400) >> (10 - 2))
 	  | ((as12 & 0x3ff) << (1 + 2)));
 }
 
-static INLINE unsigned int
-re_assemble_16 (insn, as16, wide)
-     unsigned int insn;
-     unsigned int as16;
-     int wide;
+static INLINE int
+re_assemble_14 (as14)
+     int as14;
 {
-  unsigned int s, t;
+  return ((  (as14 & 0x1fff) << 1)
+	  | ((as14 & 0x2000) >> 13));
+}
 
-  if (wide)
-    {
-      /* Unusual 16-bit encoding.  */
-      t = (as16 << 1) & 0xffff;
-      s = (as16 & 0x8000);
-      return insn | (t ^ s ^ (s >> 1)) | (s >> 15);
-    }
-  else
-    {
-      /* Standard 14-bit encoding.  */
-      t = (as16 << 1) & 0x3fff;
-      s = (as16 & 0x2000);
-      return insn | t | (s >> 13);
-    }
+static INLINE int
+re_assemble_16 (as16)
+     int as16;
+{
+  int s, t;
+
+  /* Unusual 16-bit encoding, for wide mode only.  */
+  t = (as16 << 1) & 0xffff;
+  s = (as16 & 0x8000);
+  return (t ^ s ^ (s >> 1)) | (s >> 15);
 }
 
-static INLINE unsigned int
-re_assemble_17 (insn, as17)
-     unsigned int insn;
-     unsigned int as17;
+static INLINE int
+re_assemble_17 (as17)
+     int as17;
 {
-  return (insn
-	  | ((as17 & 0x10000) >> 16)
+  return ((  (as17 & 0x10000) >> 16)
 	  | ((as17 & 0x0f800) << (16 - 11))
 	  | ((as17 & 0x00400) >> (10 - 2))
 	  | ((as17 & 0x003ff) << (1 + 2)));
 }
 
-static INLINE unsigned int
-re_assemble_21 (insn, as21)
-     unsigned int insn;
-     unsigned int as21;
+static INLINE int
+re_assemble_21 (as21)
+     int as21;
 {
-  return (insn
-	  | ((as21 & 0x100000) >> 20)
+  return ((  (as21 & 0x100000) >> 20)
 	  | ((as21 & 0x0ffe00) >> 8)
 	  | ((as21 & 0x000180) << 7)
 	  | ((as21 & 0x00007c) << 14)
 	  | ((as21 & 0x000003) << 12));
 }
 
-static INLINE unsigned int
-re_assemble_22 (insn, as22)
-     unsigned int insn;
-     unsigned int as22;
+static INLINE int
+re_assemble_22 (as22)
+     int as22;
 {
-  return (insn
-	  | ((as22 & 0x200000) >> 21)
+  return ((  (as22 & 0x200000) >> 21)
 	  | ((as22 & 0x1f0000) << (21 - 16))
 	  | ((as22 & 0x00f800) << (16 - 11))
 	  | ((as22 & 0x000400) >> (10 - 2))
@@ -481,7 +314,7 @@ re_assemble_22 (insn, as22)
 
 static INLINE bfd_signed_vma
 hppa_field_adjust (sym_val, addend, r_field)
-     bfd_signed_vma sym_val;
+     bfd_vma sym_val;
      bfd_signed_vma addend;
      enum hppa_reloc_field_selector_type_alt r_field;
 {
@@ -491,10 +324,18 @@ hppa_field_adjust (sym_val, addend, r_fi
   switch (r_field)
     {
     case e_fsel:
-    case e_nsel:
       /* F: No change.  */
       break;
 
+    case e_nsel:
+      /* N: null selector.  I don't really understand what this is all
+	 about, but HP's documentation says "this indicates that zero
+	 bits are to be used for the displacement on the instruction.
+	 This fixup is used to identify three-instruction sequences to
+	 access data (for importing shared library data)."  */
+      value = 0;
+      break;
+
     case e_lsel:
     case e_nlsel:
       /* L:  Select top 21 bits.  */
@@ -558,123 +399,158 @@ hppa_field_adjust (sym_val, addend, r_fi
 /* PA-RISC OPCODES */
 #define get_opcode(insn)	(((insn) >> 26) & 0x3f)
 
-/* FIXME: this list is incomplete.  It should also be an enumerated
-   type rather than #defines.  */
+enum hppa_opcode_type
+{
+  /* None of the opcodes in the first group generate relocs, so we
+     aren't too concerned about them.  */
+  OP_SYSOP   = 0x00,
+  OP_MEMMNG  = 0x01,
+  OP_ALU     = 0x02,
+  OP_NDXMEM  = 0x03,
+  OP_SPOP    = 0x04,
+  OP_DIAG    = 0x05,
+  OP_FMPYADD = 0x06,
+  OP_UNDEF07 = 0x07,
+  OP_COPRW   = 0x09,
+  OP_COPRDW  = 0x0b,
+  OP_COPR    = 0x0c,
+  OP_FLOAT   = 0x0e,
+  OP_PRDSPEC = 0x0f,
+  OP_UNDEF15 = 0x15,
+  OP_UNDEF1d = 0x1d,
+  OP_FMPYSUB = 0x26,
+  OP_FPFUSED = 0x2e,
+  OP_SHEXDP0 = 0x34,
+  OP_SHEXDP1 = 0x35,
+  OP_SHEXDP2 = 0x36,
+  OP_UNDEF37 = 0x37,
+  OP_SHEXDP3 = 0x3c,
+  OP_SHEXDP4 = 0x3d,
+  OP_MULTMED = 0x3e,
+  OP_UNDEF3f = 0x3f,
+
+  OP_LDIL    = 0x08,
+  OP_ADDIL   = 0x0a,
+
+  OP_LDO     = 0x0d,
+  OP_LDB     = 0x10,
+  OP_LDH     = 0x11,
+  OP_LDW     = 0x12,
+  OP_LDWM    = 0x13,
+  OP_STB     = 0x18,
+  OP_STH     = 0x19,
+  OP_STW     = 0x1a,
+  OP_STWM    = 0x1b,
+
+  OP_LDD     = 0x14,
+  OP_STD     = 0x1c,
+
+  OP_FLDW    = 0x16,
+  OP_LDWL    = 0x17,
+  OP_FSTW    = 0x1e,
+  OP_STWL    = 0x1f,
+
+  OP_COMBT   = 0x20,
+  OP_COMIBT  = 0x21,
+  OP_COMBF   = 0x22,
+  OP_COMIBF  = 0x23,
+  OP_CMPBDT  = 0x27,
+  OP_ADDBT   = 0x28,
+  OP_ADDIBT  = 0x29,
+  OP_ADDBF   = 0x2a,
+  OP_ADDIBF  = 0x2b,
+  OP_CMPBDF  = 0x2f,
+  OP_BVB     = 0x30,
+  OP_BB      = 0x31,
+  OP_MOVB    = 0x32,
+  OP_MOVIB   = 0x33,
+  OP_CMPIBD  = 0x3b,
+
+  OP_COMICLR = 0x24,
+  OP_SUBI    = 0x25,
+  OP_ADDIT   = 0x2c,
+  OP_ADDI    = 0x2d,
+
+  OP_BE      = 0x38,
+  OP_BLE     = 0x39,
+  OP_BL      = 0x3a
+};
 
-#define LDO	0x0d
-#define LDB	0x10
-#define LDH	0x11
-#define LDW	0x12
-#define LDWM	0x13
-#define STB	0x18
-#define STH	0x19
-#define STW	0x1a
-#define STWM	0x1b
-#define COMICLR	0x24
-#define SUBI	0x25
-#define SUBIO	0x25
-#define ADDIT	0x2c
-#define ADDITO	0x2c
-#define ADDI	0x2d
-#define ADDIO	0x2d
-#define LDIL	0x08
-#define ADDIL	0x0a
-
-#define MOVB	0x32
-#define MOVIB	0x33
-#define COMBT	0x20
-#define COMBF	0x22
-#define COMIBT	0x21
-#define COMIBF	0x23
-#define ADDBT	0x28
-#define ADDBF	0x2a
-#define ADDIBT	0x29
-#define ADDIBF	0x2b
-#define BVB	0x30
-#define BB	0x31
-
-#define BL	0x3a
-#define BLE	0x39
-#define BE	0x38
-
-#define CMPBDT	0x27
-#define CMPBDF	0x2f
-#define CMPIBD	0x3b
-#define LDD	0x14
-#define STD	0x1c
-#define LDWL	0x17
-#define STWL	0x1f
-#define FLDW    0x16
-#define FSTW    0x1e
-
-/* Given a machine instruction, return its format.
 
-   FIXME:  opcodes which do not map to a known format
-   should return an error of some sort.  */
+/* Given a machine instruction, return its format.  */
 
 static INLINE int
-bfd_hppa_insn2fmt (insn)
-     unsigned int insn;
+bfd_hppa_insn2fmt (abfd, insn)
+     bfd *abfd;
+     int insn;
 {
-  unsigned char op = get_opcode (insn);
+  enum hppa_opcode_type op = get_opcode (insn);
 
   switch (op)
     {
-    case ADDI:
-    case ADDIT:
-    case SUBI:
+    case OP_COMICLR:
+    case OP_SUBI:
+    case OP_ADDIT:
+    case OP_ADDI:
       return 11;
 
-    case MOVB:
-    case MOVIB:
-    case COMBT:
-    case COMBF:
-    case COMIBT:
-    case COMIBF:
-    case ADDBT:
-    case ADDBF:
-    case ADDIBT:
-    case ADDIBF:
-    case BVB:
-    case BB:
-    case CMPBDT:
-    case CMPBDF:
-    case CMPIBD:
+    case OP_COMBT:
+    case OP_COMIBT:
+    case OP_COMBF:
+    case OP_COMIBF:
+    case OP_CMPBDT:
+    case OP_ADDBT:
+    case OP_ADDIBT:
+    case OP_ADDBF:
+    case OP_ADDIBF:
+    case OP_CMPBDF:
+    case OP_BVB:
+    case OP_BB:
+    case OP_MOVB:
+    case OP_MOVIB:
+    case OP_CMPIBD:
       return 12;
 
-    case LDO:
-    case LDB:
-    case LDH:
-    case LDW:
-    case LDWM:
-    case STB:
-    case STH:
-    case STW:
-    case STWM:
+    case OP_LDO:
+    case OP_LDB:
+    case OP_LDH:
+    case OP_LDW:
+    case OP_LDWM:
+    case OP_STB:
+    case OP_STH:
+    case OP_STW:
+    case OP_STWM:
+      if (abfd->arch_info->mach >= 25)
+	return 16;	/* Wide mode, format 16.  */
       return 14;
 
-    case LDWL:
-    case STWL:
-    case FLDW:
-    case FSTW:
+    case OP_FLDW:
+    case OP_LDWL:
+    case OP_FSTW:
+    case OP_STWL:
       /* This is a hack.  Unfortunately, format 11 is already taken
 	 and we're using integers rather than an enum, so it's hard
 	 to describe the 11a format.  */
+      if (abfd->arch_info->mach >= 25)
+	return -16;	/* Wide mode, format 16a.  */
       return -11;
 
-    case LDD:
-    case STD:
+    case OP_LDD:
+    case OP_STD:
+      if (abfd->arch_info->mach >= 25)
+	return -10;	/* Wide mode, format 10a.  */
       return 10;
 
-    case BL:
-    case BE:
-    case BLE:
-      if ((insn & 0x00008000) != 0)
+    case OP_BL:
+      if ((insn & 0x8000) != 0)
 	return 22;
+      /* fall thru */
+    case OP_BE:
+    case OP_BLE:
       return 17;
 
-    case LDIL:
-    case ADDIL:
+    case OP_LDIL:
+    case OP_ADDIL:
       return 21;
 
     default:
@@ -687,21 +563,52 @@ bfd_hppa_insn2fmt (insn)
 /* Insert VALUE into INSN using R_FORMAT to determine exactly what
    bits to change.  */
 
-static INLINE unsigned int
-hppa_rebuild_insn (abfd, insn, value, r_format)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     unsigned int insn;
-     unsigned int value;
-     unsigned int r_format;
+static INLINE int
+hppa_rebuild_insn (insn, value, r_format)
+     int insn;
+     int value;
+     int r_format;
 {
   switch (r_format)
     {
-    case 11: return (insn & ~ 0x7ff) | low_sign_unext (value, 11);
-    case 12: return re_assemble_12 (insn & ~ 0x1ffd, value);
-    case 14: return (insn & ~ 0x3fff) | low_sign_unext (value, 14);
-    case 17: return re_assemble_17 (insn & ~ 0x1f1ffd, value);
-    case 21: return re_assemble_21 (insn & ~ 0x1fffff, value);
-    case 32: return value;
+    case 11:
+      return (insn & ~ 0x7ff) | low_sign_unext (value, 11);
+
+    case 12:
+      return (insn & ~ 0x1ffd) | re_assemble_12 (value);
+
+
+    case 10:
+      return (insn & ~ 0x3ff1) | re_assemble_14 (value & -8);
+
+    case -11:
+      return (insn & ~ 0x3ff9) | re_assemble_14 (value & -4);
+
+    case 14:
+      return (insn & ~ 0x3fff) | re_assemble_14 (value);
+
+
+    case -10:
+      return (insn & ~ 0xfff1) | re_assemble_16 (value & -8);
+
+    case -16:
+      return (insn & ~ 0xfff9) | re_assemble_16 (value & -4);
+
+    case 16:
+      return (insn & ~ 0xffff) | re_assemble_16 (value);
+
+
+    case 17:
+      return (insn & ~ 0x1f1ffd) | re_assemble_17 (value);
+
+    case 21:
+      return (insn & ~ 0x1fffff) | re_assemble_21 (value);
+
+    case 22:
+      return (insn & ~ 0x3ff1ffd) | re_assemble_22 (value);
+
+    case 32:
+      return value;
 
     default:
       abort ();
@@ -709,4 +616,4 @@ hppa_rebuild_insn (abfd, insn, value, r_
   return insn;
 }
 
-#endif /* _HPPA_H */
+#endif /* _LIBHPPA_H */


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