Tue Jun 18 14:42:58 1996 Klaus Kaempf <kkaempf@progis.de>

Added support for Alpha OpenVMS:
	* evax.h, evax-alpha.c, evax-egsd.c, evax-emh.c: New files.
	* evax-etir.c, evax-misc.c, hosts/alphavms.h: New files.
	* config.h-vms, makefile.vms: New files.
	* config.bfd (alpha-*-*vms*): New target.
	* configure.in (evax_alpha_vec): New target vector.
	* configure: Rebuild.
	* reloc.c (BFD_RELOC_SWREL32, BFD_RELOC_SWREL64): Define.
	(BFD_RELOC_ALPHA_LINKAGE, BFD_RELOC_ALPHA_BASEREG): Define.
	* targets.c (bfd_target_evax_flavour): Define.
	(evax_alpha_vec): Declare.
	(bfd_target_vector): Add ecoffalpha_little_vec and evax_alpha_vec
	if BFD64 is defined.
	* bfd-in2.h, libbfd.h: Rebuild.
	* Makefile.in: Rebuild dependencies.
	(BFD64_BACKENDS): Add evax-alpha.o, evax-egsd.o, evax-etir.o,
	evax-emh.o, and evax-misc.o.
	(BFD64_BACKENDS_CFILES): Add evax-alpha.c, evax-egsd.c,
	evax-etir.c, evax-emh.c, and evax-misc.c.
	(HFILES): Add evax.h.
This commit is contained in:
Ian Lance Taylor 1996-06-18 19:07:51 +00:00
parent bc70a91892
commit c3d8e071bf
13 changed files with 5953 additions and 5 deletions

View File

@ -92,6 +92,7 @@ coffgen.c
cofflink.c
coffswap.h
config.bfd
config.h-vms
config.in
configure
configure.bat
@ -147,6 +148,12 @@ elfcode.h
elfcore.h
elflink.c
elflink.h
evax.h
evax-alpha.c
evax-egsd.c
evax-emh.c
evax-etir.c
evax-misc.c
filemode.c
format.c
freebsd.h
@ -193,6 +200,7 @@ m68klynx.c
m68knetbsd.c
m88kmach3.c
makefile.dos
makefile.vms
mipsbsd.c
mpw-config.in
mpw-make.sed

View File

@ -1,3 +1,26 @@
Tue Jun 18 14:42:58 1996 Klaus Kaempf <kkaempf@progis.de>
Added support for Alpha OpenVMS:
* evax.h, evax-alpha.c, evax-egsd.c, evax-emh.c: New files.
* evax-etir.c, evax-misc.c, hosts/alphavms.h: New files.
* config.h-vms, makefile.vms: New files.
* config.bfd (alpha-*-*vms*): New target.
* configure.in (evax_alpha_vec): New target vector.
* configure: Rebuild.
* reloc.c (BFD_RELOC_SWREL32, BFD_RELOC_SWREL64): Define.
(BFD_RELOC_ALPHA_LINKAGE, BFD_RELOC_ALPHA_BASEREG): Define.
* targets.c (bfd_target_evax_flavour): Define.
(evax_alpha_vec): Declare.
(bfd_target_vector): Add ecoffalpha_little_vec and evax_alpha_vec
if BFD64 is defined.
* bfd-in2.h, libbfd.h: Rebuild.
* Makefile.in: Rebuild dependencies.
(BFD64_BACKENDS): Add evax-alpha.o, evax-egsd.o, evax-etir.o,
evax-emh.o, and evax-misc.o.
(BFD64_BACKENDS_CFILES): Add evax-alpha.c, evax-egsd.c,
evax-etir.c, evax-emh.c, and evax-misc.c.
(HFILES): Add evax.h.
Tue Jun 18 13:54:18 1996 Ian Lance Taylor <ian@cygnus.com>
* coff-h8300.c (h8300_reloc16_extra_cases): Make name a const

View File

@ -125,7 +125,9 @@ typedef long int file_ptr;
#else
#ifdef __GNUC__
#define BFD_HOST_64_BIT long long
#endif /* defined (__GNUC__) */
#else /* ! defined (__GNUC__) */
#error No 64 bit integer type available
#endif /* ! defined (__GNUC__) */
#endif /* ! BFD_HOST_64BIT_LONG */
#endif /* ! defined (BFD_HOST_64_BIT) */
@ -665,6 +667,18 @@ extern boolean bfd_xcoff_size_dynamic_sections
unsigned long, unsigned long, unsigned long, boolean,
int, boolean, boolean, struct sec **));
/* Externally visible COFF routines. */
#if defined(__STDC__) || defined(ALMOST_STDC)
struct internal_syment;
union internal_auxent;
#endif
extern boolean bfd_coff_get_syment
PARAMS ((bfd *, struct symbol_cache_entry *, struct internal_syment *));
extern boolean bfd_coff_get_auxent
PARAMS ((bfd *, struct symbol_cache_entry *, int, union internal_auxent *));
/* And more from the source. */
void
bfd_init PARAMS ((void));
@ -1190,9 +1204,6 @@ enum bfd_architecture
bfd_arch_arm, /* Advanced Risc Machines ARM */
bfd_arch_ns32k, /* National Semiconductors ns32000 */
bfd_arch_w65, /* WDC 65816 */
/* start-sanitize-rce */
bfd_arch_rce, /* Motorola RCE */
/* end-sanitize-rce */
/* start-sanitize-arc */
bfd_arch_arc, /* Argonaut RISC Core */
#define bfd_mach_arc_base 0
@ -1533,6 +1544,11 @@ decided relatively late. */
BFD_RELOC_GPREL16,
BFD_RELOC_GPREL32,
/* For openVMS/Alpha systems, these are displacements for switch
tables. */
BFD_RELOC_SWREL32,
BFD_RELOC_SWREL64,
/* Reloc types used for i960/b.out. */
BFD_RELOC_I960_CALLJ,
@ -1617,6 +1633,13 @@ The GNU linker currently doesn't do any of this optimizing. */
prediction logic which may be provided on some processors. */
BFD_RELOC_ALPHA_HINT,
/* The LINKAGE relocation outputs a special code in the object file,
the rest is handled by the linker. */
BFD_RELOC_ALPHA_LINKAGE,
/* The BASEREG relocation calculates differences to basereg. */
BFD_RELOC_ALPHA_BASEREG,
/* Bits 27..2 of the relocation address shifted right 2 bits;
simple reloc otherwise. */
BFD_RELOC_MIPS_JMP,
@ -2270,7 +2293,8 @@ enum bfd_flavour {
bfd_target_som_flavour,
bfd_target_os9k_flavour,
bfd_target_versados_flavour,
bfd_target_msdos_flavour
bfd_target_msdos_flavour,
bfd_target_evax_flavour
};
enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };

59
bfd/config.h-vms Normal file
View File

@ -0,0 +1,59 @@
/* config.h-vms. Generated by hand by Klaus Kämpf, kkaempf@didymus.rmi.de. */
/* config.in. Generated automatically from configure.in by autoheader. */
/* Whether malloc must be declared even if <stdlib.h> is included. */
/* #undef NEED_DECLARATION_MALLOC */
/* Whether free must be declared even if <stdlib.h> is included. */
/* #undef NEED_DECLARATION_FREE */
/* Define if you have a working `mmap' system call. */
/* #define HAVE_MMAP 1 */
/* Do we need to use the b modifier when opening binary files? */
/* #undef USE_BINARY_FOPEN */
/* Name of host specific header file to include in trad-core.c. */
/* #undef TRAD_HEADER */
/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t. */
/* #undef HAVE_SYS_PROCFS_H */
/* Do we really want to use mmap if it's available? */
/* #undef USE_MMAP */
/* Define if you have the fcntl function. */
#define HAVE_FCNTL 1
/* Define if you have the getpagesize function. */
#define HAVE_GETPAGESIZE 1
/* Define if you have the madvise function. */
#define HAVE_MADVISE 1
/* Define if you have the mprotect function. */
#define HAVE_MPROTECT 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define if you have the <sys/file.h> header file. */
#define HAVE_SYS_FILE_H 1
/* Define if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

1857
bfd/evax-alpha.c Normal file

File diff suppressed because it is too large Load Diff

583
bfd/evax-egsd.c Normal file
View File

@ -0,0 +1,583 @@
/* evax-egsd.c -- BFD back-end for ALPHA EVAX (openVMS/AXP) files.
Copyright 1996 Free Software Foundation Inc.
go and read the openVMS linker manual (esp. appendix B)
if you don't know what's going on here :-)
Written by Klaus Kämpf (kkaempf@progis.de)
of proGIS Softwareentwicklung, Aachen, Germany
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include <ctype.h>
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"
#include "libbfd.h"
#include "evax.h"
/*-----------------------------------------------------------------------------*/
/* sections every evax object file has */
#define EVAX_ABS_NAME "$ABS$"
#define EVAX_CODE_NAME "$CODE$"
#define EVAX_LINK_NAME "$LINK$"
#define EVAX_DATA_NAME "$DATA$"
#define EVAX_BSS_NAME "$BSS$"
#define EVAX_READONLY_NAME "$READONLY$"
#define EVAX_LITERAL_NAME "$LITERAL$"
struct sec_flags_struct {
char *name; /* name of section */
int eflags_always;
flagword flags_always; /* flags we set always */
int eflags_hassize;
flagword flags_hassize; /* flags we set if the section has a size > 0 */
};
/* just a dummy flag array since i don't understand it yet */
static struct sec_flags_struct evax_section_flags[] = {
{ EVAX_ABS_NAME,
(EGPS_S_V_SHR),
(SEC_DATA),
(EGPS_S_V_SHR),
(SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
{ EVAX_CODE_NAME,
(EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_EXE),
(SEC_CODE),
(EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_EXE),
(SEC_IN_MEMORY|SEC_CODE|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
{ EVAX_LINK_NAME,
(EGPS_S_V_REL|EGPS_S_V_RD),
(SEC_DATA|SEC_READONLY),
(EGPS_S_V_REL|EGPS_S_V_RD),
(SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
{ EVAX_DATA_NAME,
(EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
(SEC_DATA),
(EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
(SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
{ EVAX_BSS_NAME,
(EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD),
(SEC_NO_FLAGS),
(EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT|EGPS_S_V_NOMOD),
(SEC_IN_MEMORY|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) },
{ EVAX_READONLY_NAME,
(EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD),
(SEC_DATA|SEC_READONLY),
(EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD),
(SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
{ EVAX_LITERAL_NAME,
(EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD),
(SEC_DATA|SEC_READONLY),
(EGPS_S_V_PIC|EGPS_S_V_REL|EGPS_S_V_SHR|EGPS_S_V_RD),
(SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_READONLY|SEC_LOAD) },
{ NULL,
(EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
(SEC_DATA),
(EGPS_S_V_REL|EGPS_S_V_RD|EGPS_S_V_WRT),
(SEC_IN_MEMORY|SEC_DATA|SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD) }
};
/* Retrieve bfd section flags by name and size */
static flagword
evax_secflag_by_name(name, size)
char *name;
int size;
{
int i = 0;
while (evax_section_flags[i].name != NULL)
{
if (strcmp (name, evax_section_flags[i].name) == 0)
{
if (size > 0)
return evax_section_flags[i].flags_hassize;
else
return evax_section_flags[i].flags_always;
}
i++;
}
if (size > 0)
return evax_section_flags[i].flags_hassize;
return evax_section_flags[i].flags_always;
}
/* Retrieve evax section flags by name and size */
static flagword
evax_esecflag_by_name(name, size)
char *name;
int size;
{
int i = 0;
while (evax_section_flags[i].name != NULL)
{
if (strcmp (name, evax_section_flags[i].name) == 0)
{
if (size > 0)
return evax_section_flags[i].eflags_hassize;
else
return evax_section_flags[i].eflags_always;
}
i++;
}
if (size > 0)
return evax_section_flags[i].eflags_hassize;
return evax_section_flags[i].eflags_always;
}
/*-----------------------------------------------------------------------------*/
#if EVAX_DEBUG
/* debug */
struct flagdescstruct { char *name; flagword value; };
/* Convert flag to printable string */
static char *
flag2str(flagdesc, flags)
struct flagdescstruct *flagdesc;
flagword flags;
{
static char res[64];
int next = 0;
res[0] = 0;
while (flagdesc->name != NULL)
{
if ((flags & flagdesc->value) != 0)
{
if (next)
strcat(res, ",");
else
next = 1;
strcat (res, flagdesc->name);
}
flagdesc++;
}
return res;
}
#endif
/*-----------------------------------------------------------------------------*/
/* input routines */
/* Process EGSD record
return 0 on success, -1 on error */
int
_bfd_evax_slurp_egsd (abfd)
bfd *abfd;
{
#if EVAX_DEBUG
static struct flagdescstruct gpsflagdesc[] =
{
{ "PIC", 0x0001 },
{ "LIB", 0x0002 },
{ "OVR", 0x0004 },
{ "REL", 0x0008 },
{ "GBL", 0x0010 },
{ "SHR", 0x0020 },
{ "EXE", 0x0040 },
{ "RD", 0x0080 },
{ "WRT", 0x0100 },
{ "VEC", 0x0200 },
{ "NOMOD", 0x0400 },
{ "COM", 0x0800 },
{ NULL, 0 }
};
static struct flagdescstruct gsyflagdesc[] =
{
{ "WEAK", 0x0001 },
{ "DEF", 0x0002 },
{ "UNI", 0x0004 },
{ "REL", 0x0008 },
{ "COMM", 0x0010 },
{ "VECEP", 0x0020 },
{ "NORM", 0x0040 },
{ NULL, 0 }
};
#endif
int gsd_type, gsd_size;
asection *section;
unsigned char *evax_rec;
flagword new_flags, old_flags;
char *name;
asymbol *symbol;
evax_symbol_entry *entry;
unsigned long base_addr;
unsigned long align_addr;
#if EVAX_DEBUG
evax_debug (2, "EGSD\n");
#endif
PRIV(evax_rec) += 8; /* skip type, size, l_temp */
PRIV(rec_size) -= 8;
/* calculate base address for each section */
base_addr = 0L;
abfd->symcount = 0;
while (PRIV(rec_size) > 0)
{
evax_rec = PRIV(evax_rec);
_bfd_evax_get_header_values (abfd, evax_rec, &gsd_type, &gsd_size);
switch (gsd_type)
{
case EGSD_S_C_PSC:
{
/* program section definition */
name = _bfd_evax_save_counted_string ((char *)evax_rec+12);
section = bfd_make_section (abfd, name);
if (!section)
return -1;
old_flags = bfd_getl16 (evax_rec + 6);
section->_raw_size = bfd_getl32 (evax_rec + 8); /* allocation */
new_flags = evax_secflag_by_name (name, section->_raw_size);
if (old_flags & EGPS_S_V_REL)
new_flags |= SEC_RELOC;
if (!bfd_set_section_flags (abfd, section, new_flags))
return -1;
section->alignment_power = evax_rec[4];
align_addr = (1 << section->alignment_power);
if ((base_addr % align_addr) != 0)
base_addr += (align_addr - (base_addr % align_addr));
section->vma = (bfd_vma)base_addr;
base_addr += section->_raw_size; /* FIXME: should be cooked size */
section->contents = (unsigned char *) malloc (section->_raw_size);
if (section->contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
return -1;
}
memset (section->contents, 0, section->_raw_size);
#if EVAX_DEBUG
evax_debug(3, "egsd psc %d (%s, flags %04x=%s) ",
section->index, name, old_flags, flag2str(gpsflagdesc, old_flags));
evax_debug(3, "%d bytes at 0x%08lx (mem %p)\n",
section->_raw_size, section->vma, section->contents);
#endif
}
break;
case EGSD_S_C_SYM:
{
/* symbol specification (definition or reference) */
symbol = _bfd_evax_make_empty_symbol (abfd);
if (symbol == 0)
return -1;
old_flags = bfd_getl16 (evax_rec + 6);
new_flags = BSF_NO_FLAGS;
if (old_flags & EGSY_S_V_WEAK)
new_flags |= BSF_WEAK;
if (evax_rec[6] & EGSY_S_V_DEF) /* symbol definition */
{
symbol->name =
_bfd_evax_save_counted_string ((char *)evax_rec+32);
if (old_flags & EGSY_S_V_NORM)
{ /* proc def */
new_flags |= BSF_FUNCTION;
}
symbol->value = bfd_getl64 (evax_rec+8);
symbol->section = (asection *)((unsigned long) bfd_getl32 (evax_rec+28));
#if EVAX_DEBUG
evax_debug(3, "egsd sym def #%d (%s, %d, %04x=%s)\n", abfd->symcount,
symbol->name, (int)symbol->section, old_flags, flag2str(gsyflagdesc, old_flags));
#endif
}
else /* symbol reference */
{
#if EVAX_DEBUG
evax_debug(3, "egsd sym ref #%d (%s, %04x=%s)\n", abfd->symcount, evax_rec+9, old_flags, flag2str(gsyflagdesc, old_flags));
#endif
symbol->name =
_bfd_evax_save_counted_string ((char *)evax_rec+8);
symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
}
symbol->flags = new_flags;
/* save symbol in evax_symbol_table */
entry = (evax_symbol_entry *) bfd_hash_lookup (PRIV(evax_symbol_table), symbol->name, true, false);
if (entry == (evax_symbol_entry *)NULL)
{
bfd_set_error (bfd_error_no_memory);
return -1;
}
if (entry->symbol != (asymbol *)NULL)
{ /* FIXME ?, DEC C generates this */
#if EVAX_DEBUG
evax_debug(3, "EGSD_S_C_SYM: duplicate \"%s\"\n", symbol->name);
#endif
}
else
{
entry->symbol = symbol;
PRIV(egsd_sym_count)++;
abfd->symcount++;
}
}
break;
case EGSD_S_C_IDC:
break;
default:
(*_bfd_error_handler) ("unknown egsd subtype %d", gsd_type);
bfd_set_error (bfd_error_bad_value);
return -1;
} /* switch */
PRIV(rec_size) -= gsd_size;
PRIV(evax_rec) += gsd_size;
} /* while (recsize > 0) */
if (abfd->symcount > 0)
abfd->flags |= HAS_SYMS;
return 0;
}
/*-----------------------------------------------------------------------------*/
/* output routines */
/* Write section and symbol directory of bfd abfd */
int
_bfd_evax_write_egsd (abfd)
bfd *abfd;
{
asection *section;
asymbol *symbol;
int symnum;
int last_index = -1;
char dummy_name[10];
char *sname;
flagword new_flags, old_flags;
char uname[200];
char *nptr, *uptr;
#if EVAX_DEBUG
evax_debug (2, "evax_write_egsd(%p)\n", abfd);
#endif
/* output sections */
section = abfd->sections;
#if EVAX_DEBUG
evax_debug (3, "%d sections found\n", abfd->section_count);
#endif
/* egsd is quadword aligned */
_bfd_evax_output_alignment (abfd, 8);
_bfd_evax_output_begin (abfd, EOBJ_S_C_EGSD, -1);
_bfd_evax_output_long (abfd, 0);
_bfd_evax_output_push (abfd); /* prepare output for subrecords */
while (section != 0)
{
#if EVAX_DEBUG
evax_debug (3, "Section #%d %s, %d bytes\n", section->index, section->name, (int)section->_raw_size);
#endif
/* 13 bytes egsd, max 31 chars name -> should be 44 bytes */
if (_bfd_evax_output_check (abfd, 64) < 0)
{
_bfd_evax_output_pop (abfd);
_bfd_evax_output_end (abfd);
_bfd_evax_output_begin (abfd, EOBJ_S_C_EGSD, -1);
_bfd_evax_output_long (abfd, 0);
_bfd_evax_output_push (abfd); /* prepare output for subrecords */
}
/* Create dummy sections to keep consecutive indices */
while (section->index - last_index > 1)
{
#if EVAX_DEBUG
evax_debug (3, "index %d, last %d\n", section->index, last_index);
#endif
_bfd_evax_output_begin (abfd, EGSD_S_C_PSC, -1);
_bfd_evax_output_short (abfd, 0);
_bfd_evax_output_short (abfd, 0);
_bfd_evax_output_long (abfd, 0);
sprintf (dummy_name, ".DUMMY%02d", last_index);
_bfd_evax_output_counted (abfd, dummy_name);
_bfd_evax_output_flush (abfd);
last_index++;
}
/* Don't know if this is neccesary for the linker but for now it keeps
evax_slurp_egsd happy */
sname = (char *)section->name;
if (*sname == '.')
{
sname++;
if ((*sname == 't') && (strcmp (sname, "text") == 0))
sname = EVAX_CODE_NAME;
else if ((*sname == 'd') && (strcmp (sname, "data") == 0))
sname = EVAX_DATA_NAME;
else if ((*sname == 'b') && (strcmp (sname, "bss") == 0))
sname = EVAX_BSS_NAME;
else if ((*sname == 'l') && (strcmp (sname, "link") == 0))
sname = EVAX_LINK_NAME;
else if ((*sname == 'r') && (strcmp (sname, "rdata") == 0))
sname = EVAX_READONLY_NAME;
else if ((*sname == 'l') && (strcmp (sname, "literal") == 0))
sname = EVAX_LITERAL_NAME;
}
_bfd_evax_output_begin (abfd, EGSD_S_C_PSC, -1);
_bfd_evax_output_short (abfd, section->alignment_power & 0xff);
_bfd_evax_output_short (abfd,
evax_esecflag_by_name (sname,
section->_raw_size));
_bfd_evax_output_long (abfd, section->_raw_size);
_bfd_evax_output_counted (abfd, sname);
_bfd_evax_output_flush (abfd);
last_index = section->index;
section = section->next;
}
/* output symbols */
#if EVAX_DEBUG
evax_debug (3, "%d symbols found\n", abfd->symcount);
#endif
bfd_set_start_address (abfd, (bfd_vma)-1);
for (symnum = 0; symnum < abfd->symcount; symnum++)
{
symbol = abfd->outsymbols[symnum];
if (*(symbol->name) == '_')
{
if (strcmp (symbol->name, "__main") == 0)
bfd_set_start_address (abfd, (bfd_vma)symbol->value);
}
old_flags = symbol->flags;
if (((old_flags & BSF_GLOBAL) == 0) /* not xdef */
&& (!bfd_is_und_section (symbol->section))) /* and not xref */
continue; /* dont output */
/* 13 bytes egsd, max 64 chars name -> should be 77 bytes */
if (_bfd_evax_output_check (abfd, 80) < 0)
{
_bfd_evax_output_pop (abfd);
_bfd_evax_output_end (abfd);
_bfd_evax_output_begin (abfd, EOBJ_S_C_EGSD, -1);
_bfd_evax_output_long (abfd, 0);
_bfd_evax_output_push (abfd); /* prepare output for subrecords */
}
_bfd_evax_output_begin (abfd, EGSD_S_C_SYM, -1);
_bfd_evax_output_short (abfd, 0); /* data type, alignment */
new_flags = 0;
if (old_flags & BSF_WEAK)
new_flags |= EGSY_S_V_WEAK;
if (old_flags & BSF_FUNCTION)
{
new_flags |= EGSY_S_V_NORM;
new_flags |= EGSY_S_V_REL;
}
if (old_flags & BSF_GLOBAL)
{
new_flags |= EGSY_S_V_DEF;
if (!bfd_is_abs_section (symbol->section))
new_flags |= EGSY_S_V_REL;
}
_bfd_evax_output_short (abfd, new_flags);
if (old_flags & BSF_GLOBAL) /* symbol definition */
{
if (old_flags & BSF_FUNCTION)
{
_bfd_evax_output_quad (abfd, symbol->value);
_bfd_evax_output_quad (abfd,
((asymbol *)(symbol->udata.p))->value);
_bfd_evax_output_long (abfd,
(((asymbol *)(symbol->udata.p))
->section->index));
_bfd_evax_output_long (abfd, symbol->section->index);
}
else
{
_bfd_evax_output_quad (abfd, symbol->value); /* L_VALUE */
_bfd_evax_output_quad (abfd, 0); /* L_CODE_ADDRESS */
_bfd_evax_output_long (abfd, 0); /* L_CA_PSINDX */
_bfd_evax_output_long (abfd, symbol->section->index);/* L_PSINDX, FIXME */
}
}
if (strlen ((char *)symbol->name) > 198)
{
(*_bfd_error_handler) ("Name '%s' too long\n", symbol->name);
abort ();
}
nptr = (char *)symbol->name;
uptr = uname;
while (*nptr)
{
if (islower (*nptr))
*uptr = toupper (*nptr);
else
*uptr = *nptr;
uptr++;
nptr++;
}
*uptr = 0;
_bfd_evax_output_counted (abfd, uname);
_bfd_evax_output_flush (abfd);
}
_bfd_evax_output_alignment (abfd, 8);
_bfd_evax_output_pop (abfd);
_bfd_evax_output_end (abfd);
return 0;
}

288
bfd/evax-emh.c Normal file
View File

@ -0,0 +1,288 @@
/* evax-emh.c -- BFD back-end for ALPHA EVAX (openVMS/AXP) files.
Copyright 1996 Free Software Foundation, Inc.
EMH record handling functions
and
EEOM record handling functions
Written by Klaus Kämpf (kkaempf@progis.de)
of proGIS Softwareentwicklung, Aachen, Germany
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"
#include "libbfd.h"
#include "evax.h"
/*---------------------------------------------------------------------------*/
/* Read & process emh record
return 0 on success, -1 on error */
int
_bfd_evax_slurp_emh (abfd)
bfd *abfd;
{
unsigned char *ptr;
unsigned char *evax_rec;
evax_rec = PRIV(evax_rec);
#if EVAX_DEBUG
evax_debug(2, "EMH\n");
#endif
switch (bfd_getl16 (evax_rec + 4))
{
case EMH_S_C_MHD:
/*
* module header
*/
PRIV(emh_data).emh_b_strlvl = evax_rec[6];
PRIV(emh_data).emh_l_arch1 = bfd_getl32 (evax_rec + 8);
PRIV(emh_data).emh_l_arch2 = bfd_getl32 (evax_rec + 12);
PRIV(emh_data).emh_l_recsiz = bfd_getl32 (evax_rec + 16);
PRIV(emh_data).emh_t_name =
_bfd_evax_save_counted_string ((char *)evax_rec + 20);
ptr = evax_rec + 20 + evax_rec[20] + 1;
PRIV(emh_data).emh_t_version =
_bfd_evax_save_counted_string ((char *)ptr);
ptr += *ptr + 1;
PRIV(emh_data).emh_t_date =
_bfd_evax_save_sized_string ((char *)ptr, 17);
break;
case EMH_S_C_LNM:
/*
*
*/
PRIV(emh_data).emh_c_lnm =
_bfd_evax_save_sized_string ((char *)evax_rec, PRIV(rec_length-6));
break;
case EMH_S_C_SRC:
/*
*
*/
PRIV(emh_data).emh_c_src =
_bfd_evax_save_sized_string ((char *)evax_rec, PRIV(rec_length-6));
break;
case EMH_S_C_TTL:
/*
*
*/
PRIV(emh_data).emh_c_ttl =
_bfd_evax_save_sized_string ((char *)evax_rec, PRIV(rec_length-6));
break;
case EMH_S_C_CPR:
/*
*
*/
break;
case EMH_S_C_MTC:
/*
*
*/
break;
case EMH_S_C_GTX:
/*
*
*/
break;
default:
bfd_set_error (bfd_error_wrong_format);
return -1;
} /* switch */
return 0;
}
#if 0
/* register a file name */
int
_bfd_evax_register_filename (abfd, name)
bfd *abfd;
char *name;
{
if (PRIV(filename) != NULL)
{
#if EVAX_DEBUG
evax_debug(3, "Second filename %s, first was %s\n", name, PRIV(filename));
#endif
return -1;
}
PRIV(filename) = strdup (name);
return 0;
}
#endif /* 0 */
/* write object header for bfd abfd */
int
_bfd_evax_write_emh (abfd)
bfd *abfd;
{
char *name;
#if EVAX_DEBUG
evax_debug (2, "evax_write_emh(%p)\n", abfd);
#endif
_bfd_evax_output_alignment (abfd, 2);
/* MHD */
_bfd_evax_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_MHD);
_bfd_evax_output_short (abfd, EOBJ_S_C_STRLVL);
_bfd_evax_output_long (abfd, 0);
_bfd_evax_output_long (abfd, 0);
_bfd_evax_output_long (abfd, MAX_OUTREC_SIZE);
if (bfd_get_filename (abfd) != NULL)
{
name = strdup (bfd_get_filename (abfd));
_bfd_evax_output_counted (abfd, _bfd_evax_basename (name));
}
else
_bfd_evax_output_counted (abfd, "NONAME");
_bfd_evax_output_counted (abfd, BFD_VERSION);
_bfd_evax_output_dump (abfd, (unsigned char *)_bfd_get_vms_time_string (),
17);
_bfd_evax_output_fill (abfd, 0, 17);
_bfd_evax_output_flush (abfd);
/* LMN */
_bfd_evax_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_LNM);
_bfd_evax_output_dump (abfd, (unsigned char *)"GAS proGIS", 10);
_bfd_evax_output_flush (abfd);
/* SRC */
_bfd_evax_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_SRC);
if (PRIV(filename) != 0)
_bfd_evax_output_dump (abfd, (unsigned char *)PRIV(filename), strlen (PRIV(filename)));
else
_bfd_evax_output_dump (abfd, (unsigned char *)"noname", 6);
_bfd_evax_output_flush (abfd);
/* TTL */
_bfd_evax_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_TTL);
_bfd_evax_output_dump (abfd, (unsigned char *)"TTL", 3);
_bfd_evax_output_flush (abfd);
/* CPR */
_bfd_evax_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_CPR);
_bfd_evax_output_dump (abfd,
(unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
39);
_bfd_evax_output_flush (abfd);
return 0;
}
/*-----------------------------------------------------------------------------*/
/* Process EEOM record
return 0 on success, -1 on error */
int
_bfd_evax_slurp_eeom (abfd)
bfd *abfd;
{
unsigned char *evax_rec;
#if EVAX_DEBUG
evax_debug(2, "EEOM\n");
#endif
evax_rec = PRIV(evax_rec);
PRIV(eeom_data).eeom_l_total_lps = bfd_getl32 (evax_rec + 4);
PRIV(eeom_data).eeom_b_comcod = *(evax_rec + 8);
if (PRIV(eeom_data).eeom_b_comcod > 1)
{
(*_bfd_error_handler) ("Object module NOT error-free !\n");
bfd_set_error (bfd_error_bad_value);
return -1;
}
PRIV(eeom_data).eeom_has_transfer = false;
if (PRIV(rec_size) > 10)
{
PRIV(eeom_data).eeom_has_transfer = true;
PRIV(eeom_data).eeom_b_tfrflg = *(evax_rec + 9);
PRIV(eeom_data).eeom_l_psindx = bfd_getl32 (evax_rec + 12);
PRIV(eeom_data).eeom_l_tfradr = bfd_getl32 (evax_rec + 16);
abfd->start_address = PRIV(eeom_data).eeom_l_tfradr;
}
return 0;
}
/* Write eom record for bfd abfd */
int
_bfd_evax_write_eeom (abfd)
bfd *abfd;
{
#if EVAX_DEBUG
evax_debug (2, "evax_write_eeom(%p)\n", abfd);
#endif
_bfd_evax_output_begin (abfd,EOBJ_S_C_EEOM, -1);
_bfd_evax_output_long (abfd, (unsigned long)(PRIV(evax_linkage_index) >> 1));
_bfd_evax_output_byte (abfd, 0); /* completion code */
_bfd_evax_output_byte (abfd, 0); /* fill byte */
if (bfd_get_start_address (abfd) != (bfd_vma)-1)
{
asection *section;
section = bfd_get_section_by_name (abfd, ".link");
if (section == 0)
{
bfd_set_error (bfd_error_nonrepresentable_section);
return -1;
}
_bfd_evax_output_short (abfd, 0);
_bfd_evax_output_long (abfd, (unsigned long)(section->index));
_bfd_evax_output_long (abfd,
(unsigned long) bfd_get_start_address (abfd));
_bfd_evax_output_long (abfd, 0);
}
_bfd_evax_output_end (abfd);
return 0;
}

1553
bfd/evax-etir.c Normal file

File diff suppressed because it is too large Load Diff

1065
bfd/evax-misc.c Normal file

File diff suppressed because it is too large Load Diff

382
bfd/evax.h Normal file
View File

@ -0,0 +1,382 @@
/* evax.h -- Header file for ALPHA EVAX (openVMS/AXP) support.
Copyright 1996 Free Software Foundation, Inc.
Written by Klaus Kämpf (kkaempf@progis.de)
of proGIS Softwareentwicklung, Aachen, Germany
This file is part of BFD, the Binary File Descriptor library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef EVAX_H
#define EVAX_H
/* EVAX Text, information and relocation record (ETIR) definitions. */
#define ETIR_S_C_MINSTACOD 0 /* Minimum store code */
#define ETIR_S_C_STA_GBL 0 /* Stack global symbol value */
#define ETIR_S_C_STA_LW 1 /* Stack longword */
#define ETIR_S_C_STA_QW 2 /* Stack quadword */
#define ETIR_S_C_STA_PQ 3 /* Stack psect base plus quadword offset */
#define ETIR_S_C_STA_LI 4 /* Stack literal */
#define ETIR_S_C_STA_MOD 5 /* Stack module */
#define ETIR_S_C_STA_CKARG 6 /* Check Arguments */
#define ETIR_S_C_MAXSTACOD 6 /* Maximum stack code */
#define ETIR_S_C_MINSTOCOD 50 /* Minimum store code */
#define ETIR_S_C_STO_B 50 /* Store byte */
#define ETIR_S_C_STO_W 51 /* Store word */
#define ETIR_S_C_STO_LW 52 /* Store longword */
#define ETIR_S_C_STO_QW 53 /* Store quadword */
#define ETIR_S_C_STO_IMMR 54 /* Store immediate Repeated */
#define ETIR_S_C_STO_GBL 55 /* Store global */
#define ETIR_S_C_STO_CA 56 /* Store code address */
#define ETIR_S_C_STO_RB 57 /* Store relative branch */
#define ETIR_S_C_STO_AB 58 /* Store absolute branch */
#define ETIR_S_C_STO_OFF 59 /* Store offset within psect */
#define ETIR_S_C_STO_IMM 61 /* Store immediate */
#define ETIR_S_C_STO_GBL_LW 62 /* Store global Longword */
#define ETIR_S_C_STO_LP_PSB 63 /* STO_LP_PSB not valid in level 2 use STC_LP_PSB */
#define ETIR_S_C_STO_HINT_GBL 64 /* Store 14 bit HINT at global address */
#define ETIR_S_C_STO_HINT_PS 65 /* Store 14 bit HINT at psect + offset */
#define ETIR_S_C_MAXSTOCOD 65 /* Maximum store code */
#define ETIR_S_C_MINOPRCOD 100 /* Minimum operate code */
#define ETIR_S_C_OPR_NOP 100 /* No-op */
#define ETIR_S_C_OPR_ADD 101 /* Add */
#define ETIR_S_C_OPR_SUB 102 /* Subtract */
#define ETIR_S_C_OPR_MUL 103 /* Multiply */
#define ETIR_S_C_OPR_DIV 104 /* Divide */
#define ETIR_S_C_OPR_AND 105 /* Logical AND */
#define ETIR_S_C_OPR_IOR 106 /* Logical inclusive OR */
#define ETIR_S_C_OPR_EOR 107 /* Logical exclusive OR */
#define ETIR_S_C_OPR_NEG 108 /* Negate */
#define ETIR_S_C_OPR_COM 109 /* Complement */
#define ETIR_S_C_OPR_INSV 110 /* Insert bit field */
#define ETIR_S_C_OPR_ASH 111 /* Arithmetic shift */
#define ETIR_S_C_OPR_USH 112 /* Unsigned shift */
#define ETIR_S_C_OPR_ROT 113 /* Rotate */
#define ETIR_S_C_OPR_SEL 114 /* Select one of three longwords on top of stack */
#define ETIR_S_C_OPR_REDEF 115 /* Redefine this symbol after pass 2 */
#define ETIR_S_C_OPR_DFLIT 116 /* Define a literal */
#define ETIR_S_C_MAXOPRCOD 116 /* Maximum operate code */
#define ETIR_S_C_MINCTLCOD 150 /* Minimum control code */
#define ETIR_S_C_CTL_SETRB 150 /* Set relocation base */
#define ETIR_S_C_CTL_AUGRB 151 /* Augment relocation base */
#define ETIR_S_C_CTL_DFLOC 152 /* Define debug location */
#define ETIR_S_C_CTL_STLOC 153 /* Set debug location */
#define ETIR_S_C_CTL_STKDL 154 /* Stack debug location */
#define ETIR_S_C_MAXCTLCOD 154 /* Maximum control code */
#define ETIR_S_C_MINSTCCOD 200 /* Minimum store-conditional code */
#define ETIR_S_C_STC_LP 200 /* Store-conditional Linkage Pair */
#define ETIR_S_C_STC_LP_PSB 201 /* Store-conditional Linkage Pair with Procedure Signature */
#define ETIR_S_C_STC_GBL 202 /* Store-conditional Address at global address */
#define ETIR_S_C_STC_GCA 203 /* Store-conditional Code Address at global address */
#define ETIR_S_C_STC_PS 204 /* Store-conditional Address at psect + offset */
#define ETIR_S_C_STC_NOP_GBL 205 /* Store-conditional NOP at address of global */
#define ETIR_S_C_STC_NOP_PS 206 /* Store-conditional NOP at pect + offset */
#define ETIR_S_C_STC_BSR_GBL 207 /* Store-conditional BSR at global address */
#define ETIR_S_C_STC_BSR_PS 208 /* Store-conditional BSR at pect + offset */
#define ETIR_S_C_STC_LDA_GBL 209 /* Store-conditional LDA at global address */
#define ETIR_S_C_STC_LDA_PS 210 /* Store-conditional LDA at psect + offset */
#define ETIR_S_C_STC_BOH_GBL 211 /* Store-conditional BSR or Hint at global address */
#define ETIR_S_C_STC_BOH_PS 212 /* Store-conditional BSR or Hint at pect + offset */
#define ETIR_S_C_STC_NBH_GBL 213 /* Store-conditional NOP,BSR or HINT at global address */
#define ETIR_S_C_STC_NBH_PS 214 /* Store-conditional NOP,BSR or HINT at psect + offset */
#define ETIR_S_C_MAXSTCCOD 214 /* Maximum store-conditional code */
/* EVAX Global symbol definition record (EGSD). */
#define EGSD_S_K_ENTRIES 2 /* Offset to first entry in record */
#define EGSD_S_C_ENTRIES 2 /* Offset to first entry in record */
#define EGSD_S_C_PSC 0 /* Psect definition */
#define EGSD_S_C_SYM 1 /* Symbol specification */
#define EGSD_S_C_IDC 2 /* Random entity check */
#define EGSD_S_C_SPSC 5 /* Shareable image psect definition */
#define EGSD_S_C_SYMV 6 /* Vectored (dual-valued) versions of SYM, */
#define EGSD_S_C_SYMM 7 /* Masked versions of SYM, */
#define EGSD_S_C_SYMG 8 /* EGST - gst version of SYM */
#define EGSD_S_C_MAXRECTYP 8 /* Maximum entry type defined */
#define EGPS_S_V_PIC 0x0001
#define EGPS_S_V_LIB 0x0002
#define EGPS_S_V_OVR 0x0004
#define EGPS_S_V_REL 0x0008
#define EGPS_S_V_GBL 0x0010
#define EGPS_S_V_SHR 0x0020
#define EGPS_S_V_EXE 0x0040
#define EGPS_S_V_RD 0x0080
#define EGPS_S_V_WRT 0x0100
#define EGPS_S_V_VEC 0x0200
#define EGPS_S_V_NOMOD 0x0400
#define EGPS_S_V_COM 0x0800
#define EGSY_S_V_WEAK 0x0001
#define EGSY_S_V_DEF 0x0002
#define EGSY_S_V_UNI 0x0004
#define EGSY_S_V_REL 0x0008
#define EGSY_S_V_COMM 0x0010
#define EGSY_S_V_VECEP 0x0020
#define EGSY_S_V_NORM 0x0040
/* EVAX Module header record (EMH) definitions. */
#define EMH_S_C_MHD 0 /* Main header record */
#define EMH_S_C_LNM 1 /* Language name and version */
#define EMH_S_C_SRC 2 /* Source file specification */
#define EMH_S_C_TTL 3 /* Title text of module */
#define EMH_S_C_CPR 4 /* Copyright notice */
#define EMH_S_C_MTC 5 /* Maintenance status */
#define EMH_S_C_GTX 6 /* General text */
#define EMH_S_C_MAXHDRTYP 6 /* Maximum allowable type */
/* evax-alpha.c. */
extern asymbol *_bfd_evax_make_empty_symbol PARAMS ((bfd *abfd));
/* evax-egsd.c. */
extern int _bfd_evax_slurp_egsd PARAMS ((bfd *abfd));
extern int _bfd_evax_write_egsd PARAMS ((bfd *abfd));
/* evax-emh.c. */
extern int _bfd_evax_slurp_emh PARAMS ((bfd *abfd));
extern int _bfd_evax_write_emh PARAMS ((bfd *abfd));
extern int _bfd_evax_slurp_eeom PARAMS ((bfd *abfd));
extern int _bfd_evax_write_eeom PARAMS ((bfd *abfd));
/* evax-etir.c. */
extern int _bfd_evax_slurp_etir PARAMS ((bfd *abfd));
extern int _bfd_evax_slurp_edbg PARAMS ((bfd *abfd));
extern int _bfd_evax_slurp_etbt PARAMS ((bfd *abfd));
extern int _bfd_evax_write_etir PARAMS ((bfd *abfd));
extern int _bfd_evax_write_etbt PARAMS ((bfd *abfd));
extern int _bfd_evax_write_edbg PARAMS ((bfd *abfd));
/* The r_type field in a reloc is one of the following values. */
#define ALPHA_R_IGNORE 0
#define ALPHA_R_REFQUAD 1
#define ALPHA_R_BRADDR 2
#define ALPHA_R_HINT 3
#define ALPHA_R_SREL16 4
#define ALPHA_R_SREL32 5
#define ALPHA_R_SREL64 6
#define ALPHA_R_OP_PUSH 7
#define ALPHA_R_OP_STORE 8
#define ALPHA_R_OP_PSUB 9
#define ALPHA_R_OP_PRSHIFT 10
#define ALPHA_R_LINKAGE 11
#define ALPHA_R_SWREL32 12
#define ALPHA_R_SWREL64 13
#define ALPHA_R_REFLONG 14
/* Object language definitions. */
#define EOBJ_S_C_EMH 8 /*EVAX module header record */
#define EOBJ_S_C_EEOM 9 /*EVAX end of module record */
#define EOBJ_S_C_EGSD 10 /*EVAX global symbol definition record */
#define EOBJ_S_C_ETIR 11 /*EVAX text information record */
#define EOBJ_S_C_EDBG 12 /*EVAX Debugger information record */
#define EOBJ_S_C_ETBT 13 /*EVAX Traceback information record */
#define EOBJ_S_C_MAXRECTYP 13 /*Last assigned record type */
#define EOBJ_S_K_SUBTYP 4
#define EOBJ_S_C_SUBTYP 4
#define EOBJ_S_C_MAXRECSIZ 8192 /*Maximum legal record size */
#define EOBJ_S_C_STRLVL 2 /*Structure level */
#define EOBJ_S_C_SYMSIZ 64 /*Maxymum symbol length */
#define EOBJ_S_C_STOREPLIM -1 /*Maximum repeat count on store commands */
#define EOBJ_S_C_PSCALILIM 16 /*Maximum p-sect alignment */
/* Miscellaneous definitions. */
#if __GNUC__
typedef unsigned long long uquad;
#else
typedef unsigned long uquad;
#endif
#define MAX_OUTREC_SIZE 4096
#define MIN_OUTREC_LUFT 64
typedef struct _evax_section {
unsigned char *contents;
bfd_vma offset;
bfd_size_type size;
struct _evax_section *next;
} evax_section;
extern boolean _bfd_save_evax_section
PARAMS ((bfd *abfd, asection *section, PTR data, file_ptr offset,
bfd_size_type count));
extern evax_section *_bfd_get_evax_section PARAMS ((bfd *abfd, int index));
typedef struct _evax_reloc {
struct _evax_reloc *next;
arelent *reloc;
asection *section;
} evax_reloc;
/* evax module header */
struct emh_struc {
int emh_b_strlvl;
long emh_l_arch1;
long emh_l_arch2;
long emh_l_recsiz;
char *emh_t_name;
char *emh_t_version;
char *emh_t_date;
char *emh_c_lnm;
char *emh_c_src;
char *emh_c_ttl;
};
/* evax end of module */
struct eeom_struc {
long eeom_l_total_lps;
unsigned char eeom_b_comcod;
boolean eeom_has_transfer;
unsigned char eeom_b_tfrflg;
long eeom_l_psindx;
long eeom_l_tfradr;
};
enum file_format_enum { FF_UNKNOWN, FF_FOREIGN, FF_NATIVE };
typedef struct evax_symbol_struct {
struct bfd_hash_entry bfd_hash;
asymbol *symbol;
} evax_symbol_entry;
/* stack value for push/pop commands */
struct stack_struct {
uquad value;
int psect;
};
#define STACKSIZE 50
/* location stack definitions for CTL_DFLOC, CTL_STLOC, and CTL_STKDL */
struct location_struct {
unsigned long value;
int psect;
};
#define LOCATION_SAVE_SIZE 32
#define EVAX_SECTION_COUNT 32
struct evax_private_data_struct {
char *filename; /* Filename of object file */
boolean fixup_done; /* Flag to indicate if all
section pointers and PRIV(sections)
are set up correctly */
unsigned char *evax_buf; /* buffer to record */
int buf_size; /* max size of buffer */
unsigned char *evax_rec; /* actual record ptr */
int rec_length; /* remaining record length */
int rec_size; /* actual record size */
int rec_type; /* actual record type */
enum file_format_enum file_format;
struct emh_struc emh_data; /* data from EMH record */
struct eeom_struc eeom_data; /* data from EEOM record */
int egsd_sec_count; /* # of EGSD sections */
asection **sections; /* vector of EGSD sections */
int egsd_sym_count; /* # of EGSD symbols */
asymbol **symbols; /* vector of EGSD symbols */
struct proc_value *procedure;
struct stack_struct *stack;
int stackptr;
evax_section *evax_section_table[EVAX_SECTION_COUNT];
evax_reloc *evax_reloc_table[EVAX_SECTION_COUNT];
struct bfd_hash_table *evax_symbol_table;
struct symbol_cache_entry **symcache;
int symnum;
struct location_struct *location_stack;
unsigned char *image_ptr; /* a pointer to section->contents */
unsigned char pdsc[8]; /* procedure descriptor */
/* Output routine storage */
unsigned char *output_buf; /* output data */
int push_level;
int pushed_size;
int length_pos;
int output_size;
int output_alignment;
/* linkage index counter
used by conditional store commands (ETIR_S_C_STC_) */
int evax_linkage_index;
};
#define PRIV(name) ((struct evax_private_data_struct *)abfd->tdata.any)->name
#if EVAX_DEBUG
extern void _bfd_evax_debug PARAMS((int level, char *format, ...));
extern void _bfd_hexdump
PARAMS ((int level, unsigned char *ptr, int size, int offset));
#define evax_debug _bfd_evax_debug
#endif
extern struct bfd_hash_entry *_bfd_evax_hash_newfunc
PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
const char *string));
extern void _bfd_evax_get_header_values
PARAMS ((bfd *abfd, unsigned char *buf, int *type, int *length));
extern int _bfd_evax_get_record PARAMS ((bfd *abfd));
extern int _bfd_evax_next_record PARAMS ((bfd *abfd));
extern char *_bfd_evax_save_sized_string PARAMS ((char *str, int size));
extern char *_bfd_evax_save_counted_string PARAMS ((char *ptr));
extern void _bfd_evax_push PARAMS ((bfd *abfd, uquad val, int psect));
extern uquad _bfd_evax_pop PARAMS ((bfd *abfd, int *psect));
extern boolean _bfd_save_evax_section
PARAMS ((bfd *abfd, asection *section, PTR data, file_ptr offset,
bfd_size_type count));
extern void _bfd_evax_output_begin
PARAMS ((bfd *abfd, int rectype, int rechead));
extern void _bfd_evax_output_alignment PARAMS ((bfd *abfd, int alignto));
extern void _bfd_evax_output_push PARAMS ((bfd *abfd));
extern void _bfd_evax_output_pop PARAMS ((bfd *abfd));
extern void _bfd_evax_output_flush PARAMS ((bfd *abfd));
extern void _bfd_evax_output_end PARAMS ((bfd *abfd));
extern int _bfd_evax_output_check PARAMS ((bfd *abfd, int size));
extern void _bfd_evax_output_byte PARAMS ((bfd *abfd, unsigned int value));
extern void _bfd_evax_output_short PARAMS ((bfd *abfd, unsigned int value));
extern void _bfd_evax_output_long PARAMS ((bfd *abfd, unsigned long value));
extern void _bfd_evax_output_quad PARAMS ((bfd *abfd, uquad value));
extern void _bfd_evax_output_counted PARAMS ((bfd *abfd, char *value));
extern void _bfd_evax_output_dump PARAMS ((bfd *abfd, unsigned char *data,
int length));
extern void _bfd_evax_output_fill PARAMS ((bfd *abfd, int value, int length));
extern char *_bfd_get_vms_time_string PARAMS ((void));
extern char *_bfd_evax_basename PARAMS ((char *name));
#endif /* EVAX_H */

View File

@ -25,6 +25,7 @@ Do-first:
Things-to-keep:
alphalinux.h
alphavms.h
decstation.h
delta68.h
dpx2.h

65
bfd/hosts/alphavms.h Normal file
View File

@ -0,0 +1,65 @@
/* alphavms.h -- BFD definitions for an openVMS host
Copyright 1996 Free Software Foundation, Inc.
Written by Klaus Kämpf (kkaempf@progis.de)
of proGIS Softwareentwicklung, Aachen, Germany
This file is part of BFD, the Binary File Descriptor library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stddef.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <string.h>
#include <sys/file.h>
#include <stdlib.h>
#include <unixlib.h>
#include <unixio.h>
#include <time.h>
#include "bfd.h"
#ifndef BFD_HOST_64_BIT
/* Make the basic types 64-bit quantities on the host.
Also provide the support macros BFD needs. */
# ifdef __GNUC__
# define BFD_HOST_64_BIT long long
# else
# define BFD_HOST_64_BIT long
# endif
typedef unsigned BFD_HOST_64_BIT uint64_type;
typedef BFD_HOST_64_BIT int64_type;
# define sprintf_vma(s,x) sprintf (s, "%016lx", x) /* BFD_HOST_64_BIT */
# define fprintf_vma(f,x) fprintf (f, "%016lx", x) /* BFD_HOST_64_BIT */
# define BYTES_IN_PRINTF_INT 4
/* These must have type unsigned long because they are used as
arguments in printf functions. */
# define uint64_typeLOW(x) ((unsigned long) (((x) & 0xffffffff))) /* BFD_HOST_64_BIT */
# define uint64_typeHIGH(x) ((unsigned long) (((x) >> 32) & 0xffffffff)) /* BFD_HOST_64_BIT */
#endif /* BFD_HOST_64_BIT */
#include "fopen-vms.h"
#define NO_FCNTL 1
extern int getpagesize PARAMS ((void));

40
bfd/makefile.vms Normal file
View File

@ -0,0 +1,40 @@
#
# Makefile for bfd library under openVMS/AXP
#
# For use with gnu-make for vms
#
# Created by Klaus Kaempf, kkaempf@progis.de
#
#
CC=gcc
OBJS=archive.obj,archures.obj,bfd.obj,cache.obj,coffgen.obj,corefile.obj,format.obj,\
init.obj,libbfd.obj,opncls.obj,reloc.obj,section.obj,syms.obj,targets.obj,\
hash.obj,linker.obj,elf.obj,srec.obj,binary.obj,tekhex.obj,ihex.obj,stab-syms.obj,\
evax-alpha.obj,evax-emh.obj,evax-egsd.obj,evax-etir.obj,evax-misc.obj,\
cpu-alpha.obj
ifeq ($(CC),gcc)
DEFS=/define=(SELECT_VECS="&evax_alpha_vec",SELECT_ARCHITECTURES="&bfd_alpha_arch","unlink=remove")
CFLAGS=/include=([],[-.include])$(DEFS)
else
DEFS=/define=(DEFAULT_VECTOR="evax_alpha_vec",SELECT_VECS="&evax_alpha_vec",\
SELECT_ARCHITECTURES="&bfd_alpha_arch","unlink=remove",\
"_bfd_generic_get_section_contents_in_window"="_bfd_generic_get_win_section_cont",\
"_bfd_elf_section_from_bfd_section"="_bfd_elf_sec_from_bfd_sec")
CFLAGS=/machine/list=cc.s/noopt/debug/include=([],[-.include])$(DEFS)
endif
libbfd.olb: sysdep.h bfd.h $(OBJS)
purge
lib/create libbfd $(OBJS)
sysdep.h: [.hosts]alphavms.h config.h
$(CP) $< $@
bfd.h: bfd.h-vms
$(CP) $< $@
config.h: config.h-vms
$(CP) $< $@