From 9921a571984b5697e69ad39bb7714e8694832e8e Mon Sep 17 00:00:00 2001 From: Niklas Hallqvist Date: Thu, 31 Oct 1996 00:31:23 +0000 Subject: Alpha support based on Chris Demetriou's work --- gnu/usr.bin/binutils/bfd/bfd-in2.h | 1 + gnu/usr.bin/binutils/bfd/coff-alpha.c | 28 ++++++++++ gnu/usr.bin/binutils/bfd/config.bfd | 8 +++ gnu/usr.bin/binutils/bfd/ecoff.c | 1 + gnu/usr.bin/binutils/bfd/reloc.c | 2 + gnu/usr.bin/binutils/include/coff/alpha.h | 1 + gnu/usr.bin/binutils/ld/Makefile.in | 4 ++ gnu/usr.bin/binutils/ld/configure.host | 9 ++++ gnu/usr.bin/binutils/ld/configure.tgt | 3 +- gnu/usr.bin/binutils/ld/emulparams/alphabsd.sh | 3 ++ gnu/usr.bin/binutils/ld/scripttempl/alphabsd.sc | 68 +++++++++++++++++++++++++ 11 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 gnu/usr.bin/binutils/ld/emulparams/alphabsd.sh create mode 100644 gnu/usr.bin/binutils/ld/scripttempl/alphabsd.sc diff --git a/gnu/usr.bin/binutils/bfd/bfd-in2.h b/gnu/usr.bin/binutils/bfd/bfd-in2.h index edaf2b4e18c..443c539553e 100644 --- a/gnu/usr.bin/binutils/bfd/bfd-in2.h +++ b/gnu/usr.bin/binutils/bfd/bfd-in2.h @@ -1628,6 +1628,7 @@ of instruction using the register: The GNU linker currently doesn't do any of this optimizing. */ BFD_RELOC_ALPHA_LITERAL, + BFD_RELOC_ALPHA_LITERALSLEAZY, BFD_RELOC_ALPHA_LITUSE, /* The HINT relocation indicates a value that should be filled into the diff --git a/gnu/usr.bin/binutils/bfd/coff-alpha.c b/gnu/usr.bin/binutils/bfd/coff-alpha.c index b7a41b572c4..ea77db21ab6 100644 --- a/gnu/usr.bin/binutils/bfd/coff-alpha.c +++ b/gnu/usr.bin/binutils/bfd/coff-alpha.c @@ -424,6 +424,23 @@ static reloc_howto_type alpha_howto_table[] = false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ + false), /* pcrel_offset */ + + /* Used for an instruction that refers to memory off the GP + register. The offset is 16 bits of the 32 bit instruction. This + reloc always seems to be against the .lita section. */ + HOWTO (ALPHA_R_LITERALSLEAZY, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + 0, /* special_function */ + "LITERALSLEAZY", /* name */ + true, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ false) /* pcrel_offset */ }; @@ -645,6 +662,7 @@ alpha_adjust_reloc_in (abfd, intern, rptr) case ALPHA_R_GPREL32: case ALPHA_R_LITERAL: + case ALPHA_R_LITERALSLEAZY: /* Copy the gp value for this object file into the addend, to ensure that we are not confused by the linker. */ if (! intern->r_extern) @@ -880,6 +898,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, break; case ALPHA_R_LITERAL: + case ALPHA_R_LITERALSLEAZY: /* This is a reference to a literal value, generally (always?) in the .lita section. This is a 16 bit GP relative relocation. Sometimes the subsequent reloc is a @@ -1193,6 +1212,9 @@ alpha_bfd_reloc_type_lookup (abfd, code) case BFD_RELOC_ALPHA_LITERAL: alpha_type = ALPHA_R_LITERAL; break; + case BFD_RELOC_ALPHA_LITERALSLEAZY: + alpha_type = ALPHA_R_LITERALSLEAZY; + break; case BFD_RELOC_ALPHA_LITUSE: alpha_type = ALPHA_R_LITUSE; break; @@ -1581,6 +1603,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, break; case ALPHA_R_LITERAL: + case ALPHA_R_LITERALSLEAZY: /* This is a reference to a literal value, generally (always?) in the .lita section. This is a 16 bit GP relative relocation. Sometimes the subsequent reloc is a @@ -1597,6 +1620,10 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, use. This would not be particularly difficult, but it is not currently implemented. */ +#if 0 + /* Apparently the belief mentioned just below is in error on + BSD systems. */ + /* I believe that the LITERAL reloc will only apply to a ldq or ldl instruction, so check my assumption. */ { @@ -1607,6 +1634,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29 || ((insn >> 26) & 0x3f) == 0x28); } +#endif relocatep = true; addend = ecoff_data (input_bfd)->gp - gp; diff --git a/gnu/usr.bin/binutils/bfd/config.bfd b/gnu/usr.bin/binutils/bfd/config.bfd index 0ba80caf4d4..f540c87f2f3 100644 --- a/gnu/usr.bin/binutils/bfd/config.bfd +++ b/gnu/usr.bin/binutils/bfd/config.bfd @@ -63,6 +63,14 @@ case "${targ}" in targ_defvec=bfd_elf64_alpha_vec targ_selvecs=ecoffalpha_little_vec ;; + alpha-*-netbsd*) + targ_defvec=bsd_ecoffalpha_little_vec + targ_selvecs="ecoffalpha_little_vec bfd_elf64_alpha_vec" + ;; + alpha-*-openbsd*) + targ_defvec=bsd_ecoffalpha_little_vec + targ_selvecs="ecoffalpha_little_vec bfd_elf64_alpha_vec" + ;; alpha-*-*vms*) targ_defvec=evax_alpha_vec ;; diff --git a/gnu/usr.bin/binutils/bfd/ecoff.c b/gnu/usr.bin/binutils/bfd/ecoff.c index 90928c7b463..0da5e6484ca 100644 --- a/gnu/usr.bin/binutils/bfd/ecoff.c +++ b/gnu/usr.bin/binutils/bfd/ecoff.c @@ -230,6 +230,7 @@ static int ecoff_get_magic (abfd) bfd *abfd; { + extern const bfd_target bsd_ecoffalpha_little_vec; int big, little; switch (bfd_get_arch (abfd)) diff --git a/gnu/usr.bin/binutils/bfd/reloc.c b/gnu/usr.bin/binutils/bfd/reloc.c index 84e2a5670cb..b71218c9d89 100644 --- a/gnu/usr.bin/binutils/bfd/reloc.c +++ b/gnu/usr.bin/binutils/bfd/reloc.c @@ -1909,6 +1909,8 @@ ENUMDOC ENUM BFD_RELOC_ALPHA_LITERAL +ENUMX + BFD_RELOC_ALPHA_LITERALSLEAZY ENUMX BFD_RELOC_ALPHA_LITUSE ENUMDOC diff --git a/gnu/usr.bin/binutils/include/coff/alpha.h b/gnu/usr.bin/binutils/include/coff/alpha.h index 438a8fca81d..742bdf916fd 100644 --- a/gnu/usr.bin/binutils/include/coff/alpha.h +++ b/gnu/usr.bin/binutils/include/coff/alpha.h @@ -122,6 +122,7 @@ struct external_reloc { #define ALPHA_R_OP_PRSHIFT 15 #define ALPHA_R_GPVALUE 16 #define ALPHA_R_GPRELHIGH 17 +#define ALPHA_R_LITERALSLEAZY 17 /* The *BSD ELF uses this */ #define ALPHA_R_GPRELLOW 18 #define ALPHA_R_IMMED 19 diff --git a/gnu/usr.bin/binutils/ld/Makefile.in b/gnu/usr.bin/binutils/ld/Makefile.in index 42e66f2a2bb..85ec9358f27 100644 --- a/gnu/usr.bin/binutils/ld/Makefile.in +++ b/gnu/usr.bin/binutils/ld/Makefile.in @@ -204,6 +204,7 @@ ALL_EMULATIONS = \ eaixppc.o \ eaixrs6.o \ ealpha.o \ + ealphabsd.o \ earmaoutb.o \ earmaoutl.o \ earmcoff.o \ @@ -367,6 +368,9 @@ eaixrs6.c: $(srcdir)/emulparams/aixrs6.sh \ ealpha.c: $(srcdir)/emulparams/alpha.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/alpha.sc ${GEN_DEPENDS} ${GENSCRIPTS} alpha "$(tdir_alpha)" +ealphabsd.c: $(srcdir)/emulparams/alphabsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/alphabsd.sc ${GEN_DEPENDS} + ${GENSCRIPTS} alphabsd "$(tdir_alpha)" earmaoutb.c: $(srcdir)/emulparams/armaoutb.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/armaout.sc ${GEN_DEPENDS} ${GENSCRIPTS} armaoutb "$(tdir_armaoutb)" diff --git a/gnu/usr.bin/binutils/ld/configure.host b/gnu/usr.bin/binutils/ld/configure.host index 01292b64b41..9d5e527c863 100644 --- a/gnu/usr.bin/binutils/ld/configure.host +++ b/gnu/usr.bin/binutils/ld/configure.host @@ -23,6 +23,15 @@ alpha-*-linux*) HOSTING_CRT0=/usr/lib/crt0.o ;; +alpha-*-netbsd*) + # The new BSD `make' has a bug: it doesn't pass empty arguments in + # shell commands. So we need to make this value non-empty in order + # for the genscripts.sh call to work. There's nothing magic about + # the value `/lib'; it's just a dummy. + NATIVE_LIB_DIRS=/lib + HOSTING_CRT0=/usr/lib/crt0.o + ;; + alpha-*-openbsd*) # The new BSD `make' has a bug: it doesn't pass empty arguments in # shell commands. So we need to make this value non-empty in order diff --git a/gnu/usr.bin/binutils/ld/configure.tgt b/gnu/usr.bin/binutils/ld/configure.tgt index 6eb5db0e64f..244f2d515d4 100644 --- a/gnu/usr.bin/binutils/ld/configure.tgt +++ b/gnu/usr.bin/binutils/ld/configure.tgt @@ -142,7 +142,8 @@ alpha-*-linuxecoff*) targ_emul=alpha targ_extra_emuls=elf64alpha alpha-*-linux*) targ_emul=elf64alpha targ_extra_emuls=alpha tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'` ;; -alpha-*-openbsd*) targ_emul=alpha ;; +alpha-*-netbsd*) targ_emul=alphabsd targ_extra_emuls="alpha elf64alpha";; +alpha-*-openbsd*) targ_emul=alphabsd targ_extra_emuls="alpha elf64alpha";; alpha-*-osf*) targ_emul=alpha ;; alpha-*-netware*) targ_emul=alpha ;; z8k-*-coff) targ_emul=z8002; targ_extra_emuls=z8001 ;; diff --git a/gnu/usr.bin/binutils/ld/emulparams/alphabsd.sh b/gnu/usr.bin/binutils/ld/emulparams/alphabsd.sh new file mode 100644 index 00000000000..dac53137e58 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/emulparams/alphabsd.sh @@ -0,0 +1,3 @@ +SCRIPT_NAME=alphabsd +OUTPUT_FORMAT="bsd-ecoff-littlealpha" +ARCH=alpha diff --git a/gnu/usr.bin/binutils/ld/scripttempl/alphabsd.sc b/gnu/usr.bin/binutils/ld/scripttempl/alphabsd.sc new file mode 100644 index 00000000000..66feee12e73 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/scripttempl/alphabsd.sc @@ -0,0 +1,68 @@ +# Linker script for {Net,Open}BSD/Alpha systems. +# Ian Lance Taylor . +# These variables may be overridden by the emulation file. The +# defaults are appropriate for an Alpha running NetBSD. +test -z "$ENTRY" && ENTRY=__start +test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x120000000 + SIZEOF_HEADERS" +if test "x$LD_FLAG" = "xn" -o "x$LD_FLAG" = "xN"; then + DATA_ADDR=. +else + test -z "$DATA_ADDR" && DATA_ADDR=0x140000000 +fi +cat <