Restore hppa-elf32 to working order.

This commit is contained in:
Alan Modra
2000-07-09 07:23:07 +00:00
parent 63ac3005ce
commit edd21acadc
13 changed files with 1410 additions and 1315 deletions

View File

@ -1,3 +1,183 @@
2000-07-09 Alan Modra <alan@linuxcare.com.au>
* 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.
2000-07-08 Alan Modra <alan@linuxcare.com.au> 2000-07-08 Alan Modra <alan@linuxcare.com.au>
* section.c (struct sec): Add id field. Tidy comment formatting. * section.c (struct sec): Add id field. Tidy comment formatting.

View File

@ -470,7 +470,7 @@ SOURCE_HFILES = \
aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h ecoffswap.h \ 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 \ 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 \ 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 \ 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 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)/filenames.h elf-bfd.h \
elf32-hppa.lo: elf32-hppa.c $(INCDIR)/filenames.h elf-bfd.h \ 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)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
$(INCDIR)/bfdlink.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.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 \ elf32-i370.lo: elf32-i370.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/i370.h elf32-target.h $(INCDIR)/elf/external.h $(INCDIR)/elf/i370.h elf32-target.h

View File

@ -593,7 +593,7 @@ SOURCE_HFILES = \
aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h ecoffswap.h \ 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 \ 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 \ 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 \ 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 nlmcode.h nlmswap.h ns32k.h peicode.h som.h vms.h xcoff-target.h
@ -671,7 +671,7 @@ configure.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP_ENV = --best GZIP_ENV = --best
SOURCES = $(libbfd_a_SOURCES) $(libbfd_la_SOURCES) SOURCES = $(libbfd_a_SOURCES) $(libbfd_la_SOURCES)
OBJECTS = $(libbfd_a_OBJECTS) $(libbfd_la_OBJECTS) OBJECTS = $(libbfd_a_OBJECTS) $(libbfd_la_OBJECTS)
@ -1459,7 +1459,7 @@ elf32-gen.lo: elf32-gen.c $(INCDIR)/filenames.h elf-bfd.h \
elf32-hppa.lo: elf32-hppa.c $(INCDIR)/filenames.h elf-bfd.h \ 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)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
$(INCDIR)/bfdlink.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.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 \ elf32-i370.lo: elf32-i370.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/i370.h elf32-target.h $(INCDIR)/elf/external.h $(INCDIR)/elf/i370.h elf32-target.h

View File

@ -230,15 +230,20 @@ case "${targ}" in
targ_underscore=yes targ_underscore=yes
;; ;;
hppa*-*-*elf* | hppa*-*-linux-gnu* | hppa*-*-lites* | hppa*-*-sysv4* | hppa*-*-rtems*)
targ_defvec=bfd_elf32_hppa_vec
;;
#ifdef BFD64 #ifdef BFD64
hppa*64*-*-linux-gnu*)
targ_defvec=bfd_elf64_hppa_vec
;;
hppa*64*-*-hpux11*) hppa*64*-*-hpux11*)
targ_defvec=bfd_elf64_hppa_vec targ_defvec=bfd_elf64_hppa_vec
targ_cflags=-DHPUX_LARGE_AR_IDS targ_cflags=-DHPUX_LARGE_AR_IDS
;; ;;
#endif #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) #if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) || defined (HOST_HPPAMPEIX)
hppa*-*-bsd*) hppa*-*-bsd*)
targ_defvec=som_vec targ_defvec=som_vec

View File

@ -1,3 +1,7 @@
2000-07-09 Alan Modra <alan@linuxcare.com.au>
* Makefile.in: Regenerate.
2000-07-08 Alan Modra <alan@linuxcare.com.au> 2000-07-08 Alan Modra <alan@linuxcare.com.au>
* chew.c (outputdots): Don't add a space before `/*'. * chew.c (outputdots): Don't add a space before `/*'.

View File

@ -188,7 +188,7 @@ DIST_COMMON = ChangeLog Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar TAR = tar
GZIP_ENV = --best GZIP_ENV = --best
all: all-redirect all: all-redirect
.SUFFIXES: .SUFFIXES:

View File

@ -45,7 +45,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#endif #endif
elf_hppa_reloc_type ** _bfd_elf_hppa_gen_reloc_type 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 static void elf_hppa_info_to_howto
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
@ -604,7 +604,7 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
bfd *abfd; bfd *abfd;
elf_hppa_reloc_type base_type; elf_hppa_reloc_type base_type;
int format; int format;
int field; unsigned int field;
int ignore ATTRIBUTE_UNUSED; int ignore ATTRIBUTE_UNUSED;
asymbol *sym ATTRIBUTE_UNUSED; asymbol *sym ATTRIBUTE_UNUSED;
{ {
@ -688,6 +688,8 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
{ {
case e_lsel: case e_lsel:
case e_lrsel: case e_lrsel:
case e_nlsel:
case e_nlrsel:
final_type = R_PARISC_DIR21L; final_type = R_PARISC_DIR21L;
break; break;
case e_ltsel: case e_ltsel:
@ -751,9 +753,11 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
{ {
case e_rsel: case e_rsel:
case e_rrsel: case e_rrsel:
/* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32 */
final_type = base_type + OFFSET_14R_FROM_21L; final_type = base_type + OFFSET_14R_FROM_21L;
break; break;
case e_fsel: case e_fsel:
/* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32 */
final_type = base_type + OFFSET_14F_FROM_21L; final_type = base_type + OFFSET_14F_FROM_21L;
break; break;
default: default:
@ -764,8 +768,11 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
case 21: case 21:
switch (field) switch (field)
{ {
case e_lrsel:
case e_lsel: 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; final_type = base_type;
break; break;
default: default:
@ -812,23 +819,25 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
} }
break; break;
case 22: case 21:
switch (field) switch (field)
{ {
case e_fsel: case e_lsel:
final_type = R_PARISC_PCREL22F; case e_lrsel:
case e_nlsel:
case e_nlrsel:
final_type = R_PARISC_PCREL21L;
break; break;
default: default:
return NULL; return NULL;
} }
break; break;
case 21: case 22:
switch (field) switch (field)
{ {
case e_lsel: case e_fsel:
case e_lrsel: final_type = R_PARISC_PCREL22F;
final_type = R_PARISC_PCREL21L;
break; break;
default: default:
return NULL; return NULL;
@ -920,7 +929,7 @@ elf_hppa_fake_sections (abfd, hdr, sec)
if (strcmp (name, ".PARISC.unwind") == 0) if (strcmp (name, ".PARISC.unwind") == 0)
{ {
int indx; int indx;
asection *sec; asection *asec;
#if ARCH_SIZE == 64 #if ARCH_SIZE == 64
hdr->sh_type = SHT_LOPROC + 1; hdr->sh_type = SHT_LOPROC + 1;
#else #else
@ -935,9 +944,9 @@ elf_hppa_fake_sections (abfd, hdr, sec)
So we (gasp) recompute it here. Hopefully nobody ever changes the So we (gasp) recompute it here. Hopefully nobody ever changes the
way sections are numbered in elf.c! */ 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; hdr->sh_info = indx;
break; break;
@ -954,7 +963,7 @@ elf_hppa_fake_sections (abfd, hdr, sec)
static void static void
elf_hppa_final_write_processing (abfd, linker) elf_hppa_final_write_processing (abfd, linker)
bfd *abfd; bfd *abfd;
boolean linker; boolean linker ATTRIBUTE_UNUSED;
{ {
int mach = bfd_get_mach (abfd); int mach = bfd_get_mach (abfd);
@ -1095,13 +1104,13 @@ elf_hppa_record_segment_addrs (abfd, section, data)
value = section->vma - section->filepos; 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)) == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
&& value < hppa_info->text_segment_base) && value < hppa_info->text_segment_base)
hppa_info->text_segment_base = value; hppa_info->text_segment_base = value;
else if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY) else if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
== (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
&& value < hppa_info->data_segment_base) && value < hppa_info->data_segment_base)
hppa_info->data_segment_base = value; hppa_info->data_segment_base = value;
} }
@ -1117,14 +1126,12 @@ elf_hppa_final_link (abfd, info)
struct bfd_link_info *info; struct bfd_link_info *info;
{ {
boolean retval; boolean retval;
struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
if (! info->relocateable) if (! info->relocateable)
{ {
struct elf_link_hash_entry *gp; struct elf_link_hash_entry *gp;
bfd_vma gp_val; 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 /* 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 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 /* 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 .plt section so that the stubs can access PLT entries without
using an addil sequence. */ 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_val = (gp->root.u.def.section->output_section->vma
+ gp->root.u.def.section->output_offset + 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 /* 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. */ when we encounter the first SEGREL relocation. */
elf64_hppa_hash_table (info)->text_segment_base = (bfd_vma)-1; hppa_info->text_segment_base = (bfd_vma)-1;
elf64_hppa_hash_table (info)->data_segment_base = (bfd_vma)-1; hppa_info->data_segment_base = (bfd_vma)-1;
/* HP's shared libraries have references to symbols that are not /* HP's shared libraries have references to symbols that are not
defined anywhere. The generic ELF BFD linker code will complaim defined anywhere. The generic ELF BFD linker code will complaim
@ -1243,7 +1250,7 @@ elf_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
bfd_vma relocation; bfd_vma relocation;
bfd_reloc_status_type r; bfd_reloc_status_type r;
const char *sym_name; const char *sym_name;
char *dyn_name; const char *dyn_name;
char *dynh_buf = NULL; char *dynh_buf = NULL;
size_t dynh_buflen = 0; size_t dynh_buflen = 0;
struct elf64_hppa_dyn_hash_entry *dyn_h = NULL; struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
@ -1442,7 +1449,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
bfd_vma value; bfd_vma value;
struct bfd_link_info *info; struct bfd_link_info *info;
asection *sym_sec; 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; struct elf64_hppa_dyn_hash_entry *dyn_h;
{ {
unsigned int insn; unsigned int insn;
@ -1560,7 +1567,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
case R_PARISC_LTOFF16DF: case R_PARISC_LTOFF16DF:
{ {
/* If this relocation was against a local symbol, then we still /* 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 in the "finalize_dlt" routine because it is difficult to get
to the local symbol's value). to the local symbol's value).
@ -1822,7 +1829,6 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
/* Subtract out the global pointer value to make value a DLT /* Subtract out the global pointer value to make value a DLT
relative address. */ relative address. */
value -= _bfd_get_gp_value (output_bfd); value -= _bfd_get_gp_value (output_bfd);
value += addend;
bfd_put_64 (input_bfd, value + addend, hit_data); bfd_put_64 (input_bfd, value + addend, hit_data);
return bfd_reloc_ok; return bfd_reloc_ok;
@ -1855,7 +1861,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
value += addend; value += addend;
value -= 8; value -= 8;
bfd_put_64 (input_bfd, value, hit_data); bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok; return bfd_reloc_ok;
} }
@ -1913,8 +1919,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
case R_PARISC_SECREL32: case R_PARISC_SECREL32:
bfd_put_32 (input_bfd, bfd_put_32 (input_bfd,
(value + addend value + addend - sym_sec->output_section->vma,
- sym_sec->output_section->vma),
hit_data); hit_data);
return bfd_reloc_ok; return bfd_reloc_ok;
@ -1925,7 +1930,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
the segment base values. */ the segment base values. */
if (hppa_info->text_segment_base == (bfd_vma) -1) if (hppa_info->text_segment_base == (bfd_vma) -1)
bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs, 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 /* VALUE holds the absolute address. We want to include the
addend, then turn it into a segment relative address. addend, then turn it into a segment relative address.
@ -1955,7 +1960,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
/* Update the instruction word. */ /* Update the instruction word. */
bfd_put_32 (input_bfd, insn, hit_data); 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 /* Relocate the given INSN. VALUE should be the actual value we want
@ -1976,7 +1981,7 @@ elf_hppa_relocate_insn (insn, sym_value, r_type)
the "B" instruction. */ the "B" instruction. */
case R_PARISC_PCREL22F: case R_PARISC_PCREL22F:
case R_PARISC_PCREL22C: 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 /* This is any 17bit branch. In PA2.0 syntax it also corresponds to
the "B" instruction as well as BE. */ the "B" instruction as well as BE. */
@ -1985,7 +1990,7 @@ elf_hppa_relocate_insn (insn, sym_value, r_type)
case R_PARISC_DIR17R: case R_PARISC_DIR17R:
case R_PARISC_PCREL17C: case R_PARISC_PCREL17C:
case R_PARISC_PCREL17R: case R_PARISC_PCREL17R:
return re_assemble_17 (insn & ~ 0x1f1ffd, sym_value); return (insn & ~ 0x1f1ffd) | re_assemble_17 (sym_value);
/* ADDIL or LDIL instructions. */ /* ADDIL or LDIL instructions. */
case R_PARISC_DLTREL21L: case R_PARISC_DLTREL21L:
@ -1996,7 +2001,7 @@ elf_hppa_relocate_insn (insn, sym_value, r_type)
case R_PARISC_DPREL21L: case R_PARISC_DPREL21L:
case R_PARISC_PLTOFF21L: case R_PARISC_PLTOFF21L:
case R_PARISC_DIR21L: 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. */ /* LDO and integer loads/stores with 14bit displacements. */
case R_PARISC_DLTREL14R: case R_PARISC_DLTREL14R:

File diff suppressed because it is too large Load Diff

View File

@ -37,13 +37,15 @@
#include "elf/hppa.h" #include "elf/hppa.h"
boolean elf32_hppa_size_stubs boolean elf32_hppa_size_stubs
PARAMS ((bfd *, bfd *, struct bfd_link_info *)); PARAMS ((bfd *, struct bfd_link_info *,
asection * (*) PARAMS ((const char *, asection *)),
void (*) PARAMS ((void))));
boolean elf32_hppa_build_stubs boolean elf32_hppa_build_stubs
PARAMS ((bfd *, struct bfd_link_info *)); PARAMS ((bfd *, struct bfd_link_info *));
extern elf_hppa_reloc_type ** _bfd_elf32_hppa_gen_reloc_type extern elf_hppa_reloc_type ** _bfd_elf32_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 /* Define groups of basic relocations. FIXME: These should
be the only basic relocations created by GAS. The rest be the only basic relocations created by GAS. The rest

View File

@ -55,7 +55,7 @@ struct elf64_hppa_dyn_hash_entry
bfd_vma opd_offset; bfd_vma opd_offset;
bfd_vma stub_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; struct elf_link_hash_entry *h;
/* The index of the (possibly local) symbol in the input bfd and its /* The index of the (possibly local) symbol in the input bfd and its
@ -262,7 +262,7 @@ static boolean get_stub
static boolean static boolean
elf64_hppa_dyn_hash_table_init (ht, abfd, new) elf64_hppa_dyn_hash_table_init (ht, abfd, new)
struct elf64_hppa_dyn_hash_table *ht; struct elf64_hppa_dyn_hash_table *ht;
bfd *abfd; bfd *abfd ATTRIBUTE_UNUSED;
new_hash_entry_func new; new_hash_entry_func new;
{ {
memset (ht, 0, sizeof(*ht)); memset (ht, 0, sizeof(*ht));
@ -575,7 +575,6 @@ elf64_hppa_check_relocs (abfd, info, sec, relocs)
if (info->shared && hppa_info->section_syms_bfd != abfd) if (info->shared && hppa_info->section_syms_bfd != abfd)
{ {
int i, highest_shndx; int i, highest_shndx;
asection *section;
Elf_Internal_Sym *local_syms, *isym; Elf_Internal_Sym *local_syms, *isym;
Elf64_External_Sym *ext_syms, *esym; Elf64_External_Sym *ext_syms, *esym;
@ -1177,7 +1176,7 @@ elf64_hppa_post_process_headers (abfd, link_info)
static boolean static boolean
get_opd (abfd, info, hppa_info) get_opd (abfd, info, hppa_info)
bfd *abfd; bfd *abfd;
struct bfd_link_info *info; struct bfd_link_info *info ATTRIBUTE_UNUSED;
struct elf64_hppa_link_hash_table *hppa_info; struct elf64_hppa_link_hash_table *hppa_info;
{ {
asection *opd; asection *opd;
@ -1215,7 +1214,7 @@ get_opd (abfd, info, hppa_info)
static boolean static boolean
get_plt (abfd, info, hppa_info) get_plt (abfd, info, hppa_info)
bfd *abfd; bfd *abfd;
struct bfd_link_info *info; struct bfd_link_info *info ATTRIBUTE_UNUSED;
struct elf64_hppa_link_hash_table *hppa_info; struct elf64_hppa_link_hash_table *hppa_info;
{ {
asection *plt; asection *plt;
@ -1253,7 +1252,7 @@ get_plt (abfd, info, hppa_info)
static boolean static boolean
get_dlt (abfd, info, hppa_info) get_dlt (abfd, info, hppa_info)
bfd *abfd; bfd *abfd;
struct bfd_link_info *info; struct bfd_link_info *info ATTRIBUTE_UNUSED;
struct elf64_hppa_link_hash_table *hppa_info; struct elf64_hppa_link_hash_table *hppa_info;
{ {
asection *dlt; asection *dlt;
@ -1291,7 +1290,7 @@ get_dlt (abfd, info, hppa_info)
static boolean static boolean
get_stub (abfd, info, hppa_info) get_stub (abfd, info, hppa_info)
bfd *abfd; bfd *abfd;
struct bfd_link_info *info; struct bfd_link_info *info ATTRIBUTE_UNUSED;
struct elf64_hppa_link_hash_table *hppa_info; struct elf64_hppa_link_hash_table *hppa_info;
{ {
asection *stub; asection *stub;
@ -1510,7 +1509,7 @@ allocate_dynrel_entries (dyn_h, data)
static boolean static boolean
elf64_hppa_adjust_dynamic_symbol (info, h) 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; struct elf_link_hash_entry *h;
{ {
/* ??? Undefined symbols with PLT entries should be re-defined /* ??? Undefined symbols with PLT entries should be re-defined
@ -1551,7 +1550,6 @@ elf64_hppa_size_dynamic_sections (output_bfd, info)
boolean plt; boolean plt;
boolean relocs; boolean relocs;
boolean reltext; boolean reltext;
boolean stubs;
struct elf64_hppa_allocate_data data; struct elf64_hppa_allocate_data data;
struct elf64_hppa_link_hash_table *hppa_info; struct elf64_hppa_link_hash_table *hppa_info;
@ -1807,11 +1805,11 @@ elf64_hppa_size_dynamic_sections (output_bfd, info)
static boolean static boolean
elf64_hppa_link_output_symbol_hook (abfd, info, name, sym, input_sec) elf64_hppa_link_output_symbol_hook (abfd, info, name, sym, input_sec)
bfd *abfd; bfd *abfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info; struct bfd_link_info *info;
const char *name; const char *name;
Elf_Internal_Sym *sym; Elf_Internal_Sym *sym;
asection *input_sec; asection *input_sec ATTRIBUTE_UNUSED;
{ {
struct elf64_hppa_link_hash_table *hppa_info; struct elf64_hppa_link_hash_table *hppa_info;
struct elf64_hppa_dyn_hash_entry *dyn_h; 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) if (info->shared && dyn_h && dyn_h->want_opd)
{ {
Elf64_Internal_Rela rel; Elf64_Internal_Rela rel;
bfd_vma value;
int dynindx; int dynindx;
/* We may need to do a relocation against a local symbol, in /* We may need to do a relocation against a local symbol, in
@ -2287,8 +2284,6 @@ elf64_hppa_finalize_dynreloc (dyn_h, data)
if (info->shared && rent->type == R_PARISC_FPTR64) if (info->shared && rent->type == R_PARISC_FPTR64)
{ {
bfd_vma value, value2; bfd_vma value, value2;
asymbol *sym;
int elf_index;
/* First compute the address of the opd entry for this symbol. */ /* First compute the address of the opd entry for this symbol. */
value = (dyn_h->opd_offset value = (dyn_h->opd_offset
@ -2366,7 +2361,6 @@ elf64_hppa_finish_dynamic_sections (output_bfd, info)
if (elf_hash_table (info)->dynamic_sections_created) if (elf_hash_table (info)->dynamic_sections_created)
{ {
Elf64_External_Dyn *dyncon, *dynconend; Elf64_External_Dyn *dyncon, *dynconend;
struct elf_link_hash_entry *h;
BFD_ASSERT (sdyn != NULL); BFD_ASSERT (sdyn != NULL);
@ -2488,7 +2482,7 @@ static boolean
elf64_hppa_modify_segment_map (abfd) elf64_hppa_modify_segment_map (abfd)
bfd *abfd; bfd *abfd;
{ {
struct elf_segment_map *m, **pm; struct elf_segment_map *m;
asection *s; asection *s;
s = bfd_get_section_by_name (abfd, ".interp"); s = bfd_get_section_by_name (abfd, ".interp");

View File

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "elf/hppa.h" #include "elf/hppa.h"
extern elf_hppa_reloc_type ** _bfd_elf64_hppa_gen_reloc_type 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 /* Define groups of basic relocations. FIXME: These should
be the only basic relocations created by GAS. The rest be the only basic relocations created by GAS. The rest

View File

@ -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 */

View File

@ -21,8 +21,8 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _HPPA_H #ifndef _LIBHPPA_H
#define _HPPA_H #define _LIBHPPA_H
#define BYTES_IN_WORD 4 #define BYTES_IN_WORD 4
#define PA_PAGESIZE 0x1000 #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)) ((((bfd_signed_vma)(a)) << (BFD_ARCH_SIZE-22)) >> (BFD_ARCH_SIZE-22))
#define HPPA_R_ADDEND(r, c) \ #define HPPA_R_ADDEND(r, c) \
(((r) << 22) + ((c) & 0x3fffff)) (((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. */ /* 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. */ /* Declare the functions with the unused attribute to avoid warnings. */
static INLINE unsigned int sign_extend (unsigned int, unsigned int) static INLINE int sign_extend PARAMS ((int, int)) ATTRIBUTE_UNUSED;
__attribute__ ((__unused__)); static INLINE int low_sign_extend PARAMS ((int, int)) ATTRIBUTE_UNUSED;
static INLINE unsigned int low_sign_extend (unsigned int, unsigned int) static INLINE int sign_unext PARAMS ((int, int)) ATTRIBUTE_UNUSED;
__attribute__ ((__unused__)); static INLINE int low_sign_unext PARAMS ((int, int)) ATTRIBUTE_UNUSED;
static INLINE unsigned int assemble_3 (unsigned int) static INLINE int re_assemble_3 PARAMS ((int)) ATTRIBUTE_UNUSED;
__attribute__ ((__unused__)); static INLINE int re_assemble_12 PARAMS ((int)) ATTRIBUTE_UNUSED;
static INLINE unsigned int assemble_6 (unsigned int, unsigned int) static INLINE int re_assemble_14 PARAMS ((int)) ATTRIBUTE_UNUSED;
__attribute__ ((__unused__)); static INLINE int re_assemble_16 PARAMS ((int)) ATTRIBUTE_UNUSED;
static INLINE unsigned int assemble_12 (unsigned int, unsigned int) static INLINE int re_assemble_17 PARAMS ((int)) ATTRIBUTE_UNUSED;
__attribute__ ((__unused__)); static INLINE int re_assemble_21 PARAMS ((int)) ATTRIBUTE_UNUSED;
static INLINE unsigned int assemble_16 (unsigned int, unsigned int) static INLINE int re_assemble_22 PARAMS ((int)) ATTRIBUTE_UNUSED;
__attribute__ ((__unused__)); static INLINE bfd_signed_vma hppa_field_adjust
static INLINE unsigned int assemble_16a (unsigned int, unsigned int, PARAMS ((bfd_vma, bfd_signed_vma,
unsigned int) enum hppa_reloc_field_selector_type_alt)) ATTRIBUTE_UNUSED;
__attribute__ ((__unused__)); static INLINE int bfd_hppa_insn2fmt PARAMS ((bfd *, int)) ATTRIBUTE_UNUSED;
static INLINE unsigned int assemble_17 (unsigned int, unsigned int, static INLINE int hppa_rebuild_insn PARAMS ((int, int, int)) ATTRIBUTE_UNUSED;
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 /* The *sign_extend functions are used to assemble various bitfields
various bitfields taken from an instruction and return the taken from an instruction and return the resulting immediate
resulting immediate value. They correspond to functions by the value. */
same name in HP's PA-RISC 2.0 Architecture Reference Manual. */
static INLINE unsigned int static INLINE int
sign_extend (x, len) sign_extend (x, len)
unsigned int x, len; int x, len;
{ {
unsigned int signbit = (1 << (len - 1)); int signbit = (1 << (len - 1));
unsigned int mask = (signbit << 1) - 1; int mask = (signbit << 1) - 1;
return ((x & mask) ^ signbit) - signbit; return ((x & mask) ^ signbit) - signbit;
} }
static INLINE unsigned int static INLINE int
low_sign_extend (x, len) low_sign_extend (x, len)
unsigned int x, len; int x, len;
{ {
return (x >> 1) - ((x & 1) << (len - 1)); 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 /* The re_assemble_* functions prepare an immediate value for
assemble_6 (x, y) insertion into an opcode. pa-risc uses all sorts of weird bitfields
unsigned int x, y; in the instruction to hold the value. */
{
return (((x & 1) << 5) + (32 - (y & 0x1f)));
}
static INLINE unsigned int static INLINE 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 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
sign_unext (x, len) 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; return x & len_ones;
} }
static INLINE unsigned int static INLINE int
low_sign_unext (x, len) low_sign_unext (x, len)
unsigned int x, len; int x, len;
{ {
unsigned int temp; int temp;
unsigned int sign; int sign;
sign = (x >> (len-1)) & 1; sign = (x >> (len-1)) & 1;
@ -385,83 +232,69 @@ low_sign_unext (x, len)
return (temp << 1) | sign; return (temp << 1) | sign;
} }
static INLINE unsigned int static INLINE int
re_assemble_3 (insn, as3) re_assemble_3 (as3)
unsigned int insn; int as3;
unsigned int as3;
{ {
return (insn return (( (as3 & 4) << (13-2))
| ((as3 & 4) << (13-2))
| ((as3 & 3) << (13+1))); | ((as3 & 3) << (13+1)));
} }
static INLINE unsigned int static INLINE int
re_assemble_12 (insn, as12) re_assemble_12 (as12)
unsigned int insn; int as12;
unsigned int as12;
{ {
return (insn return (( (as12 & 0x800) >> 11)
| ((as12 & 0x800) >> 11)
| ((as12 & 0x400) >> (10 - 2)) | ((as12 & 0x400) >> (10 - 2))
| ((as12 & 0x3ff) << (1 + 2))); | ((as12 & 0x3ff) << (1 + 2)));
} }
static INLINE unsigned int static INLINE int
re_assemble_16 (insn, as16, wide) re_assemble_14 (as14)
unsigned int insn; int as14;
unsigned int as16;
int wide;
{ {
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 unsigned int static INLINE int
re_assemble_17 (insn, as17) re_assemble_16 (as16)
unsigned int insn; int as16;
unsigned int as17;
{ {
return (insn int s, t;
| ((as17 & 0x10000) >> 16)
/* Unusual 16-bit encoding, for wide mode only. */
t = (as16 << 1) & 0xffff;
s = (as16 & 0x8000);
return (t ^ s ^ (s >> 1)) | (s >> 15);
}
static INLINE int
re_assemble_17 (as17)
int as17;
{
return (( (as17 & 0x10000) >> 16)
| ((as17 & 0x0f800) << (16 - 11)) | ((as17 & 0x0f800) << (16 - 11))
| ((as17 & 0x00400) >> (10 - 2)) | ((as17 & 0x00400) >> (10 - 2))
| ((as17 & 0x003ff) << (1 + 2))); | ((as17 & 0x003ff) << (1 + 2)));
} }
static INLINE unsigned int static INLINE int
re_assemble_21 (insn, as21) re_assemble_21 (as21)
unsigned int insn; int as21;
unsigned int as21;
{ {
return (insn return (( (as21 & 0x100000) >> 20)
| ((as21 & 0x100000) >> 20)
| ((as21 & 0x0ffe00) >> 8) | ((as21 & 0x0ffe00) >> 8)
| ((as21 & 0x000180) << 7) | ((as21 & 0x000180) << 7)
| ((as21 & 0x00007c) << 14) | ((as21 & 0x00007c) << 14)
| ((as21 & 0x000003) << 12)); | ((as21 & 0x000003) << 12));
} }
static INLINE unsigned int static INLINE int
re_assemble_22 (insn, as22) re_assemble_22 (as22)
unsigned int insn; int as22;
unsigned int as22;
{ {
return (insn return (( (as22 & 0x200000) >> 21)
| ((as22 & 0x200000) >> 21)
| ((as22 & 0x1f0000) << (21 - 16)) | ((as22 & 0x1f0000) << (21 - 16))
| ((as22 & 0x00f800) << (16 - 11)) | ((as22 & 0x00f800) << (16 - 11))
| ((as22 & 0x000400) >> (10 - 2)) | ((as22 & 0x000400) >> (10 - 2))
@ -481,7 +314,7 @@ re_assemble_22 (insn, as22)
static INLINE bfd_signed_vma static INLINE bfd_signed_vma
hppa_field_adjust (sym_val, addend, r_field) hppa_field_adjust (sym_val, addend, r_field)
bfd_signed_vma sym_val; bfd_vma sym_val;
bfd_signed_vma addend; bfd_signed_vma addend;
enum hppa_reloc_field_selector_type_alt r_field; enum hppa_reloc_field_selector_type_alt r_field;
{ {
@ -491,10 +324,18 @@ hppa_field_adjust (sym_val, addend, r_field)
switch (r_field) switch (r_field)
{ {
case e_fsel: case e_fsel:
case e_nsel:
/* F: No change. */ /* F: No change. */
break; 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_lsel:
case e_nlsel: case e_nlsel:
/* L: Select top 21 bits. */ /* L: Select top 21 bits. */
@ -558,123 +399,158 @@ hppa_field_adjust (sym_val, addend, r_field)
/* PA-RISC OPCODES */ /* PA-RISC OPCODES */
#define get_opcode(insn) (((insn) >> 26) & 0x3f) #define get_opcode(insn) (((insn) >> 26) & 0x3f)
/* FIXME: this list is incomplete. It should also be an enumerated enum hppa_opcode_type
type rather than #defines. */ {
/* 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,
#define LDO 0x0d OP_LDIL = 0x08,
#define LDB 0x10 OP_ADDIL = 0x0a,
#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 OP_LDO = 0x0d,
#define MOVIB 0x33 OP_LDB = 0x10,
#define COMBT 0x20 OP_LDH = 0x11,
#define COMBF 0x22 OP_LDW = 0x12,
#define COMIBT 0x21 OP_LDWM = 0x13,
#define COMIBF 0x23 OP_STB = 0x18,
#define ADDBT 0x28 OP_STH = 0x19,
#define ADDBF 0x2a OP_STW = 0x1a,
#define ADDIBT 0x29 OP_STWM = 0x1b,
#define ADDIBF 0x2b
#define BVB 0x30
#define BB 0x31
#define BL 0x3a OP_LDD = 0x14,
#define BLE 0x39 OP_STD = 0x1c,
#define BE 0x38
#define CMPBDT 0x27 OP_FLDW = 0x16,
#define CMPBDF 0x2f OP_LDWL = 0x17,
#define CMPIBD 0x3b OP_FSTW = 0x1e,
#define LDD 0x14 OP_STWL = 0x1f,
#define STD 0x1c
#define LDWL 0x17
#define STWL 0x1f
#define FLDW 0x16
#define FSTW 0x1e
/* Given a machine instruction, return its format. 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,
FIXME: opcodes which do not map to a known format OP_COMICLR = 0x24,
should return an error of some sort. */ OP_SUBI = 0x25,
OP_ADDIT = 0x2c,
OP_ADDI = 0x2d,
OP_BE = 0x38,
OP_BLE = 0x39,
OP_BL = 0x3a
};
/* Given a machine instruction, return its format. */
static INLINE int static INLINE int
bfd_hppa_insn2fmt (insn) bfd_hppa_insn2fmt (abfd, insn)
unsigned int insn; bfd *abfd;
int insn;
{ {
unsigned char op = get_opcode (insn); enum hppa_opcode_type op = get_opcode (insn);
switch (op) switch (op)
{ {
case ADDI: case OP_COMICLR:
case ADDIT: case OP_SUBI:
case SUBI: case OP_ADDIT:
case OP_ADDI:
return 11; return 11;
case MOVB: case OP_COMBT:
case MOVIB: case OP_COMIBT:
case COMBT: case OP_COMBF:
case COMBF: case OP_COMIBF:
case COMIBT: case OP_CMPBDT:
case COMIBF: case OP_ADDBT:
case ADDBT: case OP_ADDIBT:
case ADDBF: case OP_ADDBF:
case ADDIBT: case OP_ADDIBF:
case ADDIBF: case OP_CMPBDF:
case BVB: case OP_BVB:
case BB: case OP_BB:
case CMPBDT: case OP_MOVB:
case CMPBDF: case OP_MOVIB:
case CMPIBD: case OP_CMPIBD:
return 12; return 12;
case LDO: case OP_LDO:
case LDB: case OP_LDB:
case LDH: case OP_LDH:
case LDW: case OP_LDW:
case LDWM: case OP_LDWM:
case STB: case OP_STB:
case STH: case OP_STH:
case STW: case OP_STW:
case STWM: case OP_STWM:
if (abfd->arch_info->mach >= 25)
return 16; /* Wide mode, format 16. */
return 14; return 14;
case LDWL: case OP_FLDW:
case STWL: case OP_LDWL:
case FLDW: case OP_FSTW:
case FSTW: case OP_STWL:
/* This is a hack. Unfortunately, format 11 is already taken /* This is a hack. Unfortunately, format 11 is already taken
and we're using integers rather than an enum, so it's hard and we're using integers rather than an enum, so it's hard
to describe the 11a format. */ to describe the 11a format. */
if (abfd->arch_info->mach >= 25)
return -16; /* Wide mode, format 16a. */
return -11; return -11;
case LDD: case OP_LDD:
case STD: case OP_STD:
if (abfd->arch_info->mach >= 25)
return -10; /* Wide mode, format 10a. */
return 10; return 10;
case BL: case OP_BL:
case BE: if ((insn & 0x8000) != 0)
case BLE:
if ((insn & 0x00008000) != 0)
return 22; return 22;
/* fall thru */
case OP_BE:
case OP_BLE:
return 17; return 17;
case LDIL: case OP_LDIL:
case ADDIL: case OP_ADDIL:
return 21; return 21;
default: default:
@ -687,21 +563,52 @@ bfd_hppa_insn2fmt (insn)
/* Insert VALUE into INSN using R_FORMAT to determine exactly what /* Insert VALUE into INSN using R_FORMAT to determine exactly what
bits to change. */ bits to change. */
static INLINE unsigned int static INLINE int
hppa_rebuild_insn (abfd, insn, value, r_format) hppa_rebuild_insn (insn, value, r_format)
bfd *abfd ATTRIBUTE_UNUSED; int insn;
unsigned int insn; int value;
unsigned int value; int r_format;
unsigned int r_format;
{ {
switch (r_format) switch (r_format)
{ {
case 11: return (insn & ~ 0x7ff) | low_sign_unext (value, 11); case 11:
case 12: return re_assemble_12 (insn & ~ 0x1ffd, value); return (insn & ~ 0x7ff) | low_sign_unext (value, 11);
case 14: return (insn & ~ 0x3fff) | low_sign_unext (value, 14);
case 17: return re_assemble_17 (insn & ~ 0x1f1ffd, value); case 12:
case 21: return re_assemble_21 (insn & ~ 0x1fffff, value); return (insn & ~ 0x1ffd) | re_assemble_12 (value);
case 32: return 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: default:
abort (); abort ();
@ -709,4 +616,4 @@ hppa_rebuild_insn (abfd, insn, value, r_format)
return insn; return insn;
} }
#endif /* _HPPA_H */ #endif /* _LIBHPPA_H */