Lint (saber actually).
This commit is contained in:
parent
ac0167e878
commit
fb3be09b66
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Sep 26 15:27:29 1991 John Gilmore (gnu at cygnus.com)
|
||||||
|
|
||||||
|
* aoutf1.h, aoutx.h, bout.c, coffcode.h, host-aout.c, oasys.c,
|
||||||
|
opncls.c: Lint (saber actually).
|
||||||
|
|
||||||
Thu Sep 26 11:24:24 1991 Per Bothner (bothner at cygnus.com)
|
Thu Sep 26 11:24:24 1991 Per Bothner (bothner at cygnus.com)
|
||||||
|
|
||||||
* libaout.h (WRITE_HEADERS): Set header's a_text field always.
|
* libaout.h (WRITE_HEADERS): Set header's a_text field always.
|
||||||
|
|
15
bfd/aoutf1.h
15
bfd/aoutf1.h
|
@ -20,7 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
#include <ansidecl.h>
|
#include <ansidecl.h>
|
||||||
#include <sysdep.h>
|
#include <sysdep.h>
|
||||||
struct external_exec;
|
|
||||||
#include <a.out.sun4.h>
|
#include <a.out.sun4.h>
|
||||||
#include "bfd.h"
|
#include "bfd.h"
|
||||||
#include "libaout.h"
|
#include "libaout.h"
|
||||||
|
@ -308,7 +307,6 @@ DEFUN(swapcore_sun3,(abfd, ext, intcore),
|
||||||
char *ext AND
|
char *ext AND
|
||||||
struct internal_sunos_core *intcore)
|
struct internal_sunos_core *intcore)
|
||||||
{
|
{
|
||||||
struct external_exec exec_bytes;
|
|
||||||
struct external_sun3_core *extcore = (struct external_sun3_core *)ext;
|
struct external_sun3_core *extcore = (struct external_sun3_core *)ext;
|
||||||
|
|
||||||
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic);
|
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic);
|
||||||
|
@ -332,7 +330,7 @@ DEFUN(swapcore_sun3,(abfd, ext, intcore),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* byte-swap in the Sun-3 core structure */
|
/* byte-swap in the Sparc core structure */
|
||||||
static void
|
static void
|
||||||
DEFUN(swapcore_sparc,(abfd, ext, intcore),
|
DEFUN(swapcore_sparc,(abfd, ext, intcore),
|
||||||
bfd *abfd AND
|
bfd *abfd AND
|
||||||
|
@ -360,9 +358,8 @@ DEFUN(swapcore_sparc,(abfd, ext, intcore),
|
||||||
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *)extcore);
|
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *)extcore);
|
||||||
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||||
Presuming that this remains true, this definition will work. */
|
Presuming that this remains true, this definition will work. */
|
||||||
#define USRSTACK (-(128*1024*1024))
|
#define SPARC_USRSTACK (-(128*1024*1024))
|
||||||
intcore->c_stacktop = USRSTACK; /* By experimentation */
|
intcore->c_stacktop = SPARC_USRSTACK; /* By experimentation */
|
||||||
#undef USRSTACK
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* need this cast because ptr is really void * */
|
/* need this cast because ptr is really void * */
|
||||||
|
@ -390,7 +387,6 @@ DEFUN(sunos4_core_file_p,(abfd),
|
||||||
int core_mag;
|
int core_mag;
|
||||||
struct internal_sunos_core *core;
|
struct internal_sunos_core *core;
|
||||||
char *extcore;
|
char *extcore;
|
||||||
char *rawptr;
|
|
||||||
struct mergem {
|
struct mergem {
|
||||||
struct suncoredata suncoredata;
|
struct suncoredata suncoredata;
|
||||||
struct internal_sunos_core internal_sunos_core;
|
struct internal_sunos_core internal_sunos_core;
|
||||||
|
@ -457,7 +453,7 @@ DEFUN(sunos4_core_file_p,(abfd),
|
||||||
if (core_stacksec (abfd) == NULL) {
|
if (core_stacksec (abfd) == NULL) {
|
||||||
loser:
|
loser:
|
||||||
bfd_error = no_memory;
|
bfd_error = no_memory;
|
||||||
bfd_release (abfd, rawptr);
|
bfd_release (abfd, (char *)mergem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||||
|
@ -543,7 +539,8 @@ DEFUN(sunos4_core_file_matches_executable_p, (core_bfd, exec_bfd),
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bcmp ((char *)&core_hdr (core_bfd), (char*) &exec_hdr (exec_bfd),
|
return (bcmp ((char *)&core_hdr (core_bfd)->c_aouthdr,
|
||||||
|
(char *) exec_hdr (exec_bfd),
|
||||||
sizeof (struct internal_exec)) == 0) ? true : false;
|
sizeof (struct internal_exec)) == 0) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
bfd/aoutx.h
37
bfd/aoutx.h
|
@ -112,7 +112,6 @@ selected.
|
||||||
#include <sysdep.h>
|
#include <sysdep.h>
|
||||||
#include <ansidecl.h>
|
#include <ansidecl.h>
|
||||||
|
|
||||||
struct external_exec;
|
|
||||||
#include "libaout.h"
|
#include "libaout.h"
|
||||||
#include "libbfd.h"
|
#include "libbfd.h"
|
||||||
#include "aout64.h"
|
#include "aout64.h"
|
||||||
|
@ -194,6 +193,10 @@ DEFUN(disp64,(abfd, reloc_entry, symbol_in, data, input_section),
|
||||||
return bfd_reloc_ok;
|
return bfd_reloc_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* High 22 bits of high half of a 64-bit value, in the low bits of the
|
||||||
|
target address. If we only have 32-bit values, this is always zeroes. */
|
||||||
|
|
||||||
static bfd_reloc_status_enum_type
|
static bfd_reloc_status_enum_type
|
||||||
DEFUN(hhi22,(abfd, reloc_entry, symbol_in, data, input_section),
|
DEFUN(hhi22,(abfd, reloc_entry, symbol_in, data, input_section),
|
||||||
bfd *abfd AND
|
bfd *abfd AND
|
||||||
|
@ -204,14 +207,21 @@ DEFUN(hhi22,(abfd, reloc_entry, symbol_in, data, input_section),
|
||||||
{
|
{
|
||||||
bfd_vma sym_value = get_symbol_value(symbol_in, input_section);
|
bfd_vma sym_value = get_symbol_value(symbol_in, input_section);
|
||||||
|
|
||||||
bfd_vma value = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
|
bfd_vma value = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
|
||||||
|
|
||||||
value = (value & ~0x3fffff) | ( ((sym_value + reloc_entry->addend) >> 32+10) & 0x3fffff);
|
value &= ~0x3fffff;
|
||||||
|
value |= 0x3fffff & (((sym_value + reloc_entry->addend) >> 31) >> 11);
|
||||||
|
/* C does not define what happens if we shift it by >32 bits on a 32-bit
|
||||||
|
machine, but a shift of 31 and then 11 is well defined to give zero. */
|
||||||
|
|
||||||
bfd_put_32(abfd, value, (bfd_byte *)data+reloc_entry->address);
|
bfd_put_32(abfd, value, (bfd_byte *)data+reloc_entry->address);
|
||||||
return bfd_reloc_ok;
|
return bfd_reloc_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Low 10 bits of high half of a 64-bit value, in the low bits of the
|
||||||
|
target address. If we only have 32-bit values, this is always zeroes. */
|
||||||
|
|
||||||
static bfd_reloc_status_enum_type
|
static bfd_reloc_status_enum_type
|
||||||
DEFUN(hlo10,(abfd, reloc_entry, symbol_in, data, input_section),
|
DEFUN(hlo10,(abfd, reloc_entry, symbol_in, data, input_section),
|
||||||
bfd *abfd AND
|
bfd *abfd AND
|
||||||
|
@ -222,9 +232,12 @@ DEFUN(hlo10,(abfd, reloc_entry, symbol_in, data, input_section),
|
||||||
{
|
{
|
||||||
bfd_vma sym_value = get_symbol_value(symbol_in, input_section);
|
bfd_vma sym_value = get_symbol_value(symbol_in, input_section);
|
||||||
|
|
||||||
bfd_vma value = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
|
bfd_vma value = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
|
||||||
|
|
||||||
value = (value & ~0x3ff) | (((sym_value + reloc_entry->addend) >> 32) & 0x3ff);
|
value &= ~0x3ff;
|
||||||
|
value |= 0x3ff & (((sym_value + reloc_entry->addend) >> 31) >> 1);
|
||||||
|
/* C does not define what happens if we shift it by >32 bits on a 32-bit
|
||||||
|
machine, but a shift of 31 and then 1 is well defined to give zero. */
|
||||||
|
|
||||||
bfd_put_32(abfd, value, (bfd_byte *)data+reloc_entry->address);
|
bfd_put_32(abfd, value, (bfd_byte *)data+reloc_entry->address);
|
||||||
return bfd_reloc_ok;
|
return bfd_reloc_ok;
|
||||||
|
@ -234,6 +247,7 @@ static bfd_reloc_status_enum_type
|
||||||
r64()
|
r64()
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
|
return bfd_reloc_notsupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end-sanitize-v9 */
|
/* end-sanitize-v9 */
|
||||||
|
@ -1244,6 +1258,7 @@ DEFUN(NAME(aout,swap_std_reloc_out),(abfd, g, natptr),
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BFD_ASSERT(0);
|
BFD_ASSERT(0);
|
||||||
|
r_index = N_ABS | N_EXT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1328,6 +1343,7 @@ DEFUN(NAME(aout,swap_ext_reloc_out),(abfd, g, natptr),
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BFD_ASSERT(0);
|
BFD_ASSERT(0);
|
||||||
|
r_index = N_ABS | N_EXT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1698,7 +1714,8 @@ DEFUN(NAME(aout,print_symbol),(ignore_abfd, afile, symbol, how),
|
||||||
|
|
||||||
switch (how) {
|
switch (how) {
|
||||||
case bfd_print_symbol_name_enum:
|
case bfd_print_symbol_name_enum:
|
||||||
fprintf(file,"%s", symbol->name);
|
if (symbol->name)
|
||||||
|
fprintf(file,"%s", symbol->name);
|
||||||
break;
|
break;
|
||||||
case bfd_print_symbol_type_enum:
|
case bfd_print_symbol_type_enum:
|
||||||
fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff),
|
fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff),
|
||||||
|
@ -1712,12 +1729,14 @@ DEFUN(NAME(aout,print_symbol),(ignore_abfd, afile, symbol, how),
|
||||||
|
|
||||||
bfd_print_symbol_vandf((PTR)file,symbol);
|
bfd_print_symbol_vandf((PTR)file,symbol);
|
||||||
|
|
||||||
fprintf(file," %-5s %04x %02x %02x %s",
|
fprintf(file," %-5s %04x %02x %02x",
|
||||||
section_name,
|
section_name,
|
||||||
(unsigned)(aout_symbol(symbol)->desc & 0xffff),
|
(unsigned)(aout_symbol(symbol)->desc & 0xffff),
|
||||||
(unsigned)(aout_symbol(symbol)->other & 0xff),
|
(unsigned)(aout_symbol(symbol)->other & 0xff),
|
||||||
(unsigned)(aout_symbol(symbol)->type & 0xff),
|
(unsigned)(aout_symbol(symbol)->type & 0xff),
|
||||||
symbol->name);
|
symbol->name);
|
||||||
|
if (symbol->name)
|
||||||
|
fprintf(file," %s", symbol->name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1806,9 +1825,9 @@ DEFUN(NAME(aout,find_nearest_line),(abfd,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
DEFUN(NAME(aout,sizeof_headers),(ignore_abfd, execable),
|
DEFUN(NAME(aout,sizeof_headers),(ignore_abfd, ignore),
|
||||||
bfd *ignore_abfd AND
|
bfd *ignore_abfd AND
|
||||||
boolean execable)
|
boolean ignore)
|
||||||
{
|
{
|
||||||
return EXEC_BYTES_SIZE;
|
return EXEC_BYTES_SIZE;
|
||||||
}
|
}
|
||||||
|
|
40
bfd/bout.c
40
bfd/bout.c
|
@ -1,22 +1,22 @@
|
||||||
/* BFD back-end for i960 b.out binaries */
|
/* BFD back-end for Intel 960 b.out binaries.
|
||||||
|
Copyright (C) 1990-1991 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support.
|
||||||
|
|
||||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
This file is part of BFD, the Binary File Diddler.
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
|
||||||
BFD is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 1, or (at your option)
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
BFD is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with BFD; see the file COPYING. If not, write to
|
along with this program; if not, write to the Free Software
|
||||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
@ -24,13 +24,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
#include "bfd.h"
|
#include "bfd.h"
|
||||||
#include "libbfd.h"
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
|
||||||
#include "bout.h"
|
#include "bout.h"
|
||||||
|
|
||||||
|
|
||||||
#include "stab.gnu.h"
|
#include "stab.gnu.h"
|
||||||
#include "libaout.h" /* BFD a.out internal data structures */
|
#include "libaout.h" /* BFD a.out internal data structures */
|
||||||
#include "archures.h"
|
|
||||||
|
|
||||||
/* Align an address by rounding it up to a power of two. It leaves the
|
/* Align an address by rounding it up to a power of two. It leaves the
|
||||||
address unchanged if align == 0 (2^0 = alignment of 1 byte) */
|
address unchanged if align == 0 (2^0 = alignment of 1 byte) */
|
||||||
|
@ -526,21 +523,18 @@ b_out_squirt_out_relocs (abfd, section)
|
||||||
else if(g->section->output_section == obj_textsec(abfd)) {
|
else if(g->section->output_section == obj_textsec(abfd)) {
|
||||||
symnum = N_TEXT;
|
symnum = N_TEXT;
|
||||||
BFD_ASSERT(g->addend + obj_textsec(abfd)->vma == 0);
|
BFD_ASSERT(g->addend + obj_textsec(abfd)->vma == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (g->section->output_section == obj_datasec(abfd)) {
|
else if (g->section->output_section == obj_datasec(abfd)) {
|
||||||
symnum = N_DATA;
|
symnum = N_DATA;
|
||||||
BFD_ASSERT(g->addend + obj_datasec(abfd)->vma == 0);
|
BFD_ASSERT(g->addend + obj_datasec(abfd)->vma == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (g->section->output_section == obj_bsssec(abfd)) {
|
else if (g->section->output_section == obj_bsssec(abfd)) {
|
||||||
symnum = N_BSS;
|
symnum = N_BSS;
|
||||||
BFD_ASSERT(g->addend + obj_bsssec(abfd)->vma == 0);
|
BFD_ASSERT(g->addend + obj_bsssec(abfd)->vma == 0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BFD_ASSERT(0);
|
BFD_ASSERT(0);
|
||||||
|
symnum = N_ABS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (abfd->xvec->header_byteorder_big_p) {
|
if (abfd->xvec->header_byteorder_big_p) {
|
||||||
|
@ -554,7 +548,7 @@ b_out_squirt_out_relocs (abfd, section)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
|
if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
|
||||||
free((PTR)native);
|
free((PTR)native);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -667,14 +661,12 @@ b_out_set_arch_mach (abfd, arch, machine)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
DEFUN(b_out_sizeof_headers,(abfd, exec),
|
DEFUN(b_out_sizeof_headers,(ignore_abfd, ignore),
|
||||||
bfd *abfd AND
|
bfd *ignore_abfd AND
|
||||||
boolean exec)
|
boolean ignore)
|
||||||
{
|
{
|
||||||
return sizeof(struct internal_exec);
|
return sizeof(struct internal_exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -697,7 +689,7 @@ DEFUN(b_out_sizeof_headers,(abfd, exec),
|
||||||
#define aout_32_truncate_arname bfd_bsd_truncate_arname
|
#define aout_32_truncate_arname bfd_bsd_truncate_arname
|
||||||
|
|
||||||
/* We override these routines from the usual a.out file routines. */
|
/* We override these routines from the usual a.out file routines. */
|
||||||
#define aout_32_canonicalize_reloc b_out_canonicalize_reloc
|
#define aout_32_canonicalize_reloc b_out_canonicalize_reloc
|
||||||
#define aout_32_get_reloc_upper_bound b_out_get_reloc_upper_bound
|
#define aout_32_get_reloc_upper_bound b_out_get_reloc_upper_bound
|
||||||
#define aout_32_set_section_contents b_out_set_section_contents
|
#define aout_32_set_section_contents b_out_set_section_contents
|
||||||
#define aout_32_set_arch_mach b_out_set_arch_mach
|
#define aout_32_set_arch_mach b_out_set_arch_mach
|
||||||
|
|
155
bfd/coffcode.h
155
bfd/coffcode.h
|
@ -363,21 +363,8 @@ DEFUN(styp_to_sec_flags, (styp_flags),
|
||||||
return(sec_flags);
|
return(sec_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
#define get_index(symbol) ((int) (symbol)->value)
|
||||||
DEFUN(get_index,(symbol),
|
#define set_index(symbol, idx) ((symbol)->value = (idx))
|
||||||
asymbol *symbol)
|
|
||||||
{
|
|
||||||
return (int) symbol->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
DEFUN(set_index,(symbol, idx),
|
|
||||||
asymbol *symbol AND
|
|
||||||
unsigned int idx)
|
|
||||||
{
|
|
||||||
symbol->value = idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* **********************************************************************
|
/* **********************************************************************
|
||||||
Here are all the routines for swapping the structures seen in the
|
Here are all the routines for swapping the structures seen in the
|
||||||
|
@ -462,7 +449,11 @@ DEFUN(coff_swap_sym_in,(abfd, ext1, in1),
|
||||||
in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
|
in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#if SYMNMLEN != E_SYMNMLEN
|
||||||
|
-> Error, we need to cope with truncating or extending SYMNMLEN!;
|
||||||
|
#else
|
||||||
memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
|
memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
|
in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
|
||||||
in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
|
in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
|
||||||
|
@ -487,7 +478,11 @@ DEFUN(coff_swap_sym_out,(abfd,in, ext),
|
||||||
bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
|
bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#if SYMNMLEN != E_SYMNMLEN
|
||||||
|
-> Error, we need to cope with truncating or extending SYMNMLEN!;
|
||||||
|
#else
|
||||||
memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
|
memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
|
bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
|
||||||
bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
|
bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
|
||||||
|
@ -506,10 +501,10 @@ DEFUN(coff_swap_sym_out,(abfd,in, ext),
|
||||||
static void
|
static void
|
||||||
DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
|
DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
|
||||||
bfd *abfd AND
|
bfd *abfd AND
|
||||||
PTR ext1 AND
|
PTR ext1 AND
|
||||||
int type AND
|
int type AND
|
||||||
int class AND
|
int class AND
|
||||||
PTR in1)
|
PTR in1)
|
||||||
{
|
{
|
||||||
AUXENT *ext = (AUXENT *)ext1;
|
AUXENT *ext = (AUXENT *)ext1;
|
||||||
union internal_auxent *in = (union internal_auxent *)in1;
|
union internal_auxent *in = (union internal_auxent *)in1;
|
||||||
|
@ -519,8 +514,11 @@ DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
|
||||||
in->x_file.x_n.x_zeroes = 0;
|
in->x_file.x_n.x_zeroes = 0;
|
||||||
in->x_file.x_n.x_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
|
in->x_file.x_n.x_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
|
||||||
} else {
|
} else {
|
||||||
memcpy (in->x_file.x_fname, ext->x_file.x_fname,
|
#if FILNMLEN != E_FILNMLEN
|
||||||
sizeof (in->x_file.x_fname));
|
-> Error, we need to cope with truncating or extending FILNMLEN!;
|
||||||
|
#else
|
||||||
|
memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -542,10 +540,14 @@ DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ISARY(type) || class == C_BLOCK) {
|
if (ISARY(type) || class == C_BLOCK) {
|
||||||
|
#if DIMNUM != E_DIMNUM
|
||||||
|
-> Error, we need to cope with truncating or extending DIMNUM!;
|
||||||
|
#else
|
||||||
in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
||||||
in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
||||||
in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
||||||
in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR(abfd, ext);
|
in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR(abfd, ext);
|
||||||
in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX(abfd, ext);
|
in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX(abfd, ext);
|
||||||
|
@ -575,8 +577,11 @@ DEFUN(coff_swap_aux_out,(abfd, in, type, class, ext),
|
||||||
PUTWORD(abfd, in->x_file.x_n.x_offset, (bfd_byte *) ext->x_file.x_n.x_offset);
|
PUTWORD(abfd, in->x_file.x_n.x_offset, (bfd_byte *) ext->x_file.x_n.x_offset);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memcpy ( ext->x_file.x_fname,in->x_file.x_fname,
|
#if FILNMLEN != E_FILNMLEN
|
||||||
sizeof (in->x_file.x_fname));
|
-> Error, we need to cope with truncating or extending FILNMLEN!;
|
||||||
|
#else
|
||||||
|
memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case C_STAT:
|
case C_STAT:
|
||||||
|
@ -605,11 +610,14 @@ DEFUN(coff_swap_aux_out,(abfd, in, type, class, ext),
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if (ISARY(type) || class == C_BLOCK) {
|
if (ISARY(type) || class == C_BLOCK) {
|
||||||
|
#if DIMNUM != E_DIMNUM
|
||||||
|
-> Error, we need to cope with truncating or extending DIMNUM!;
|
||||||
|
#else
|
||||||
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
|
||||||
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
|
||||||
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
|
||||||
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
PUT_LNSZ_LNNO(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
|
PUT_LNSZ_LNNO(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
|
||||||
PUT_LNSZ_SIZE(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
|
PUT_LNSZ_SIZE(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
|
||||||
|
@ -755,35 +763,6 @@ DEFUN(swap_scnhdr_out,(abfd, scnhdr_int, scnhdr_ext),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* **********************************************************************/
|
|
||||||
/* Return a pointer to a malloc'd copy of 'name'. 'name' may not be
|
|
||||||
\0-terminated, but will not exceed 'maxlen' characters. The copy *will*
|
|
||||||
be \0-terminated.
|
|
||||||
*/
|
|
||||||
static char *
|
|
||||||
DEFUN(copy_name,(abfd, name, maxlen),
|
|
||||||
bfd *abfd AND
|
|
||||||
char *name AND
|
|
||||||
int maxlen)
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
char *newname;
|
|
||||||
|
|
||||||
for (len = 0; len < maxlen; ++len) {
|
|
||||||
if (name[len] == '\0') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((newname = (PTR) bfd_alloc(abfd, len+1)) == NULL) {
|
|
||||||
bfd_error = no_memory;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
strncpy(newname, name, len);
|
|
||||||
newname[len] = '\0';
|
|
||||||
return newname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
initialize a section structure with information peculiar to this
|
initialize a section structure with information peculiar to this
|
||||||
particular implementation of coff
|
particular implementation of coff
|
||||||
|
@ -1011,7 +990,18 @@ DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a),
|
||||||
|
|
||||||
coff->sym_filepos = internal_f->f_symptr;
|
coff->sym_filepos = internal_f->f_symptr;
|
||||||
|
|
||||||
|
/* These members communicate important constants about the symbol table
|
||||||
|
to GDB's symbol-reading code. These `constants' unfortunately vary
|
||||||
|
from coff implementation to implementation... */
|
||||||
|
#ifndef NO_COFF_SYMBOLS
|
||||||
|
coff->local_n_btmask = N_BTMASK;
|
||||||
|
coff->local_n_btshft = N_BTSHFT;
|
||||||
|
coff->local_n_tmask = N_TMASK;
|
||||||
|
coff->local_n_tshift = N_TSHIFT;
|
||||||
|
coff->local_symesz = SYMESZ;
|
||||||
|
coff->local_auxesz = AUXESZ;
|
||||||
|
coff->local_linesz = LINESZ;
|
||||||
|
#endif
|
||||||
|
|
||||||
coff->symbols = (coff_symbol_type *) NULL;
|
coff->symbols = (coff_symbol_type *) NULL;
|
||||||
bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0;
|
bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0;
|
||||||
|
@ -1123,8 +1113,8 @@ Takes a bfd and a symbol, returns a pointer to the coff specific area
|
||||||
of the symbol if there is one.
|
of the symbol if there is one.
|
||||||
*/
|
*/
|
||||||
static coff_symbol_type *
|
static coff_symbol_type *
|
||||||
DEFUN(coff_symbol_from,(abfd, symbol),
|
DEFUN(coff_symbol_from,(ignore_abfd, symbol),
|
||||||
bfd *abfd AND
|
bfd *ignore_abfd AND
|
||||||
asymbol *symbol)
|
asymbol *symbol)
|
||||||
{
|
{
|
||||||
if (symbol->the_bfd->xvec->flavour != bfd_target_coff_flavour_enum)
|
if (symbol->the_bfd->xvec->flavour != bfd_target_coff_flavour_enum)
|
||||||
|
@ -1433,8 +1423,8 @@ DEFUN(coff_mangle_symbols,(bfd_ptr),
|
||||||
#endif
|
#endif
|
||||||
static int string_size;
|
static int string_size;
|
||||||
static void
|
static void
|
||||||
DEFUN(coff_fix_symbol_name,(abfd, symbol, native),
|
DEFUN(coff_fix_symbol_name,(ignore_abfd, symbol, native),
|
||||||
bfd *abfd AND
|
bfd *ignore_abfd AND
|
||||||
asymbol *symbol AND
|
asymbol *symbol AND
|
||||||
combined_entry_type *native)
|
combined_entry_type *native)
|
||||||
{
|
{
|
||||||
|
@ -1443,10 +1433,8 @@ DEFUN(coff_fix_symbol_name,(abfd, symbol, native),
|
||||||
char * name = ( char *)(symbol->name);
|
char * name = ( char *)(symbol->name);
|
||||||
|
|
||||||
if (name == (char *) NULL) {
|
if (name == (char *) NULL) {
|
||||||
/*
|
/* coff symbols always have names, so we'll make one up */
|
||||||
coff symbols always have names, so we'll make one up
|
symbol->name = "strange";
|
||||||
*/
|
|
||||||
symbol->name = "strange";
|
|
||||||
name = (char *)symbol->name;
|
name = (char *)symbol->name;
|
||||||
}
|
}
|
||||||
name_length = strlen(name);
|
name_length = strlen(name);
|
||||||
|
@ -1668,7 +1656,8 @@ DEFUN(coff_write_symbols,(abfd),
|
||||||
if (string_size != 0)
|
if (string_size != 0)
|
||||||
{
|
{
|
||||||
unsigned int size = string_size + 4;
|
unsigned int size = string_size + 4;
|
||||||
char buffer[4];
|
bfd_byte buffer[4];
|
||||||
|
|
||||||
bfd_h_put_32(abfd, size, buffer);
|
bfd_h_put_32(abfd, size, buffer);
|
||||||
bfd_write((PTR) buffer, 1, sizeof(buffer), abfd);
|
bfd_write((PTR) buffer, 1, sizeof(buffer), abfd);
|
||||||
for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
|
for (p = abfd->outsymbols, i = 0; i < limit; i++, p++)
|
||||||
|
@ -1698,7 +1687,6 @@ DEFUN(coff_write_symbols,(abfd),
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* NO_COFF_SYMBOLS */
|
|
||||||
|
|
||||||
/*doc*
|
/*doc*
|
||||||
@subsubsection Writing Relocations
|
@subsubsection Writing Relocations
|
||||||
|
@ -1743,6 +1731,7 @@ DEFUN(coff_write_relocs,(abfd),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* NO_COFF_SYMBOLS */
|
||||||
|
|
||||||
#ifndef NO_COFF_LINENOS
|
#ifndef NO_COFF_LINENOS
|
||||||
|
|
||||||
|
@ -2298,8 +2287,8 @@ pointers to syments.
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DEFUN(coff_pointerize_aux,(abfd, table_base, type, class, auxent),
|
DEFUN(coff_pointerize_aux,(ignore_abfd, table_base, type, class, auxent),
|
||||||
bfd *abfd AND
|
bfd *ignore_abfd AND
|
||||||
combined_entry_type *table_base AND
|
combined_entry_type *table_base AND
|
||||||
int type AND
|
int type AND
|
||||||
int class AND
|
int class AND
|
||||||
|
@ -2422,6 +2411,34 @@ bfd *abfd)
|
||||||
return string_table;
|
return string_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return a pointer to a malloc'd copy of 'name'. 'name' may not be
|
||||||
|
\0-terminated, but will not exceed 'maxlen' characters. The copy *will*
|
||||||
|
be \0-terminated. */
|
||||||
|
static char *
|
||||||
|
DEFUN(copy_name,(abfd, name, maxlen),
|
||||||
|
bfd *abfd AND
|
||||||
|
char *name AND
|
||||||
|
int maxlen)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *newname;
|
||||||
|
|
||||||
|
for (len = 0; len < maxlen; ++len) {
|
||||||
|
if (name[len] == '\0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((newname = (PTR) bfd_alloc(abfd, len+1)) == NULL) {
|
||||||
|
bfd_error = no_memory;
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
strncpy(newname, name, len);
|
||||||
|
newname[len] = '\0';
|
||||||
|
return newname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
read a symbol table into freshly mallocated memory, swap it, and knit the
|
read a symbol table into freshly mallocated memory, swap it, and knit the
|
||||||
symbol names into a normalized form. By normalized here I mean that all
|
symbol names into a normalized form. By normalized here I mean that all
|
||||||
|
@ -2483,7 +2500,7 @@ bfd *abfd)
|
||||||
(internal_ptr+1)->fix_tag = 0;
|
(internal_ptr+1)->fix_tag = 0;
|
||||||
(internal_ptr+1)->fix_end = 0;
|
(internal_ptr+1)->fix_end = 0;
|
||||||
|
|
||||||
coff_swap_aux_in(abfd, (AUXENT *)(raw_src +1), internal_ptr->u.syment.n_type,
|
coff_swap_aux_in(abfd, (char *)(raw_src +1), internal_ptr->u.syment.n_type,
|
||||||
internal_ptr->u.syment.n_sclass, & (internal_ptr+1)->u.auxent);
|
internal_ptr->u.syment.n_sclass, & (internal_ptr+1)->u.auxent);
|
||||||
|
|
||||||
coff_pointerize_aux(abfd,
|
coff_pointerize_aux(abfd,
|
||||||
|
@ -3087,14 +3104,14 @@ location.
|
||||||
static boolean
|
static boolean
|
||||||
DEFUN(coff_find_nearest_line,(abfd,
|
DEFUN(coff_find_nearest_line,(abfd,
|
||||||
section,
|
section,
|
||||||
symbols,
|
ignore_symbols,
|
||||||
offset,
|
offset,
|
||||||
filename_ptr,
|
filename_ptr,
|
||||||
functionname_ptr,
|
functionname_ptr,
|
||||||
line_ptr),
|
line_ptr),
|
||||||
bfd *abfd AND
|
bfd *abfd AND
|
||||||
asection *section AND
|
asection *section AND
|
||||||
asymbol **symbols AND
|
asymbol **ignore_symbols AND
|
||||||
bfd_vma offset AND
|
bfd_vma offset AND
|
||||||
CONST char **filename_ptr AND
|
CONST char **filename_ptr AND
|
||||||
CONST char **functionname_ptr AND
|
CONST char **functionname_ptr AND
|
||||||
|
@ -3107,7 +3124,7 @@ DEFUN(coff_find_nearest_line,(abfd,
|
||||||
static alent *cache_l;
|
static alent *cache_l;
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
struct icofdata *cof = obj_icof(abfd);
|
coff_data_type *cof = coff_data(abfd);
|
||||||
/* Run through the raw syments if available */
|
/* Run through the raw syments if available */
|
||||||
combined_entry_type *p;
|
combined_entry_type *p;
|
||||||
alent *l;
|
alent *l;
|
||||||
|
@ -3122,7 +3139,7 @@ DEFUN(coff_find_nearest_line,(abfd,
|
||||||
if (abfd->xvec->flavour != bfd_target_coff_flavour_enum)
|
if (abfd->xvec->flavour != bfd_target_coff_flavour_enum)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (cof == (struct icofdata *)NULL)
|
if (cof == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
p = cof->raw_syments;
|
p = cof->raw_syments;
|
||||||
|
|
356
bfd/host-aout.c
356
bfd/host-aout.c
|
@ -1,22 +1,22 @@
|
||||||
/* BFD backend for local host's a.out binaries */
|
/* BFD backend for local host's a.out binaries
|
||||||
|
Copyright (C) 1990-1991 Free Software Foundation, Inc.
|
||||||
|
Written by Cygnus Support. Probably John Gilmore's fault.
|
||||||
|
|
||||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
This file is part of BFD, the Binary File Diddler.
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
|
||||||
BFD is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 1, or (at your option)
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
BFD is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with BFD; see the file COPYING. If not, write to
|
along with this program; if not, write to the Free Software
|
||||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
#include <ansidecl.h>
|
#include <ansidecl.h>
|
||||||
#include <sysdep.h>
|
#include <sysdep.h>
|
||||||
|
@ -24,20 +24,109 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
#include "libbfd.h"
|
#include "libbfd.h"
|
||||||
|
|
||||||
#include <a.out.h>
|
#include <a.out.h>
|
||||||
#include "liba.out.h" /* BFD a.out internal data structures */
|
#include "libaout.h" /* BFD a.out internal data structures */
|
||||||
|
|
||||||
#include "trad-core.h" /* Traditional Unix core files */
|
#include "trad-core.h" /* Traditional Unix core files */
|
||||||
|
|
||||||
void (*bfd_error_trap)();
|
/*======== This next section is stolen from ../include/a.out.gnu.h
|
||||||
|
======== for all the losing Unix systems that don't provide these
|
||||||
|
======== macros.
|
||||||
|
|
||||||
static bfd_target *host_aout_callback ();
|
When porting to a new system, you must supply:
|
||||||
|
|
||||||
|
HOST_PAGE_SIZE
|
||||||
|
HOST_SEGMENT_SIZE
|
||||||
|
HOST_MACHINE_ARCH (optional)
|
||||||
|
HOST_MACHINE_MACHINE (optional)
|
||||||
|
HOST_TEXT_START_ADDR
|
||||||
|
HOST_STACK_END_ADDR
|
||||||
|
|
||||||
|
in the ../include/h-systemname.h file. */
|
||||||
|
|
||||||
|
#define PAGE_SIZE HOST_PAGE_SIZE
|
||||||
|
#define SEGMENT_SIZE HOST_SEGMENT_SIZE
|
||||||
|
#define TEXT_START_ADDR HOST_TEXT_START_ADDR
|
||||||
|
#define STACK_END_ADDR HOST_STACK_END_ADDR
|
||||||
|
|
||||||
|
/*======== Stolen section begins below. =================================*/
|
||||||
|
|
||||||
|
#define a_info a_magic /* Old traditional Unix */
|
||||||
|
|
||||||
|
#define N_MAGIC(exec) ((exec).a_info & 0xffff)
|
||||||
|
#define N_SET_MAGIC(exec, magic) \
|
||||||
|
((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
|
||||||
|
|
||||||
|
/* Virtual Address of text segment from the a.out file. For OMAGIC,
|
||||||
|
(almost always "unlinked .o's" these days), should be zero.
|
||||||
|
For linked files, should reflect reality if we know it. */
|
||||||
|
|
||||||
|
#ifndef N_TXTADDR
|
||||||
|
#define N_TXTADDR(x) (N_MAGIC(x)==OMAGIC? 0 : TEXT_START_ADDR)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef N_BADMAG
|
||||||
|
#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
|
||||||
|
&& N_MAGIC(x) != NMAGIC \
|
||||||
|
&& N_MAGIC(x) != ZMAGIC)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This complexity is for encapsulated COFF support */
|
||||||
|
#ifndef _N_HDROFF
|
||||||
|
#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef N_TXTOFF
|
||||||
|
#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \
|
||||||
|
_N_HDROFF((x)) + sizeof (struct exec) : \
|
||||||
|
sizeof (struct exec))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef N_DATOFF
|
||||||
|
#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef N_TRELOFF
|
||||||
|
#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef N_DRELOFF
|
||||||
|
#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef N_SYMOFF
|
||||||
|
#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef N_STROFF
|
||||||
|
#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Address of text segment in memory after it is loaded. */
|
||||||
|
#ifndef N_TXTADDR
|
||||||
|
#define N_TXTADDR(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef N_DATADDR
|
||||||
|
#define N_DATADDR(x) \
|
||||||
|
(N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
|
||||||
|
: (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Address of bss segment in memory after it is loaded. */
|
||||||
|
#ifndef N_BSSADDR
|
||||||
|
#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static bfd_target *NAME(host_aout,callback) ();
|
||||||
|
|
||||||
/*SUPPRESS558*/
|
/*SUPPRESS558*/
|
||||||
/*SUPPRESS529*/
|
/*SUPPRESS529*/
|
||||||
|
|
||||||
bfd_target *
|
bfd_target *
|
||||||
host_aout_object_p (abfd)
|
DEFUN(NAME(host_aout,object_p), (abfd),
|
||||||
bfd *abfd;
|
bfd *abfd)
|
||||||
{
|
{
|
||||||
unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
|
unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
|
||||||
unsigned long magic; /* Swapped magic number */
|
unsigned long magic; /* Swapped magic number */
|
||||||
|
@ -47,21 +136,28 @@ host_aout_object_p (abfd)
|
||||||
if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
|
if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
|
||||||
sizeof (magicbuf))
|
sizeof (magicbuf))
|
||||||
return 0;
|
return 0;
|
||||||
magic = bfd_h_getlong (abfd, magicbuf);
|
magic = bfd_h_get_32 (abfd, magicbuf);
|
||||||
|
|
||||||
if (N_BADMAG (*((struct exec *) &magic))) return 0;
|
if (N_BADMAG (*((struct exec *) &magic))) return 0;
|
||||||
|
|
||||||
return some_aout_object_p (abfd, host_aout_callback);
|
return NAME(aout,some_aout_object_p) (abfd, NAME(host_aout,callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set parameters about this a.out file that are machine-dependent.
|
/* Set parameters about this a.out file that are machine-dependent.
|
||||||
This routine is called from some_aout_object_p just before it returns. */
|
This routine is called from NAME(some_aout_object_p) just before it returns.
|
||||||
|
*/
|
||||||
|
|
||||||
static bfd_target *
|
static bfd_target *
|
||||||
host_aout_callback (abfd)
|
DEFUN(NAME(host_aout,callback), (abfd),
|
||||||
bfd *abfd;
|
bfd *abfd)
|
||||||
{
|
{
|
||||||
struct exec *execp = exec_hdr (abfd);
|
/* exec_hdr (abfd), a "struct internal_exec *", is just an abstraction,
|
||||||
|
as far as the BFD a.out layer cares. We use it as a "struct exec *".
|
||||||
|
This routine moves any data from the exec header,
|
||||||
|
which is needed by the BFD code, out to places known to BFD. This
|
||||||
|
allows the rest of the BFD code to not know or care about the structure
|
||||||
|
of exec_hdr (abfd). */
|
||||||
|
struct exec *execp = (struct exec *)exec_hdr (abfd);
|
||||||
|
|
||||||
/* The virtual memory addresses of the sections */
|
/* The virtual memory addresses of the sections */
|
||||||
obj_datasec (abfd)->vma = N_DATADDR(*execp);
|
obj_datasec (abfd)->vma = N_DATADDR(*execp);
|
||||||
|
@ -87,28 +183,36 @@ host_aout_callback (abfd)
|
||||||
abfd->obj_machine = HOST_MACHINE_MACHINE;
|
abfd->obj_machine = HOST_MACHINE_MACHINE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
obj_reloc_entry_size (abfd) = sizeof (struct relocation_info);
|
||||||
return abfd->xvec;
|
return abfd->xvec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
host_aout_mkobject (abfd)
|
DEFUN(NAME(host_aout,mkobject), (abfd),
|
||||||
bfd *abfd;
|
bfd *abfd)
|
||||||
{
|
{
|
||||||
char *rawptr;
|
/* This struct is just for allocating two things with one zalloc, so
|
||||||
|
they will be freed together, without violating alignment constraints. */
|
||||||
|
struct aout_exec {
|
||||||
|
struct aoutdata aoutdata;
|
||||||
|
struct exec exec;
|
||||||
|
} *rawptr;
|
||||||
|
|
||||||
bfd_error = system_call_error;
|
bfd_error = system_call_error;
|
||||||
|
|
||||||
/* Use an intermediate variable for clarity */
|
/* Use an intermediate variable for clarity */
|
||||||
rawptr = bfd_zalloc (abfd, sizeof (struct aoutdata) + sizeof (struct exec));
|
rawptr = (struct aout_exec *)bfd_zalloc (abfd, sizeof (struct aout_exec));
|
||||||
|
|
||||||
if (rawptr == NULL) {
|
if (rawptr == NULL) {
|
||||||
bfd_error = no_memory;
|
bfd_error = no_memory;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_tdata (abfd, (struct aoutdata *) rawptr);
|
set_tdata (abfd, &rawptr->aoutdata);
|
||||||
exec_hdr (abfd) = (struct exec *) (rawptr + sizeof (struct aoutdata));
|
/* exec_hdr (abfd), a "struct internal_exec *", is just an abstraction,
|
||||||
|
as far as the BFD a.out layer cares. We use it as a "struct exec *". */
|
||||||
|
exec_hdr (abfd) = (struct internal_exec *) &rawptr->exec;
|
||||||
|
|
||||||
/* For simplicity's sake we just make all the sections right here. */
|
/* For simplicity's sake we just make all the sections right here. */
|
||||||
|
|
||||||
|
@ -127,144 +231,110 @@ host_aout_mkobject (abfd)
|
||||||
file header, symbols, and relocation. */
|
file header, symbols, and relocation. */
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
host_aout_write_object_contents (abfd)
|
DEFUN(NAME(host_aout,write_object_contents), (abfd),
|
||||||
bfd *abfd;
|
bfd *abfd)
|
||||||
{
|
{
|
||||||
/* This works because we are on the host system */
|
/* This works because we are on the host system */
|
||||||
#define EXEC_BYTES_SIZE sizeof (struct exec)
|
#define EXEC_BYTES_SIZE (sizeof (struct exec))
|
||||||
|
#define EXTERNAL_LIST_SIZE (sizeof (struct nlist))
|
||||||
size_t data_pad = 0;
|
size_t data_pad = 0;
|
||||||
unsigned char exec_bytes[EXEC_BYTES_SIZE];
|
unsigned char exec_bytes[EXEC_BYTES_SIZE];
|
||||||
struct exec *execp = exec_hdr (abfd);
|
struct exec *execp = (struct exec *)exec_hdr (abfd);
|
||||||
|
|
||||||
execp->a_text = obj_textsec (abfd)->size;
|
execp->a_text = obj_textsec (abfd)->size;
|
||||||
|
|
||||||
|
WRITE_HEADERS (abfd, execp);
|
||||||
N_SET_MAGIC (*execp, OMAGIC);
|
|
||||||
if (abfd->flags & D_PAGED) {
|
|
||||||
/* This is not strictly true, but will probably do for the default
|
|
||||||
case. FIXME.
|
|
||||||
*/
|
|
||||||
|
|
||||||
execp->a_text = obj_textsec (abfd)->size + EXEC_BYTES_SIZE;
|
|
||||||
N_SET_MAGIC (*execp, ZMAGIC);
|
|
||||||
} else if (abfd->flags & WP_TEXT) {
|
|
||||||
N_SET_MAGIC (*execp, NMAGIC);
|
|
||||||
}
|
|
||||||
N_SET_FLAGS (*execp, 0x1); /* copied from ld.c; who the hell knows? */
|
|
||||||
|
|
||||||
if (abfd->flags & D_PAGED)
|
|
||||||
{
|
|
||||||
data_pad = ((obj_datasec(abfd)->size + PAGE_SIZE -1)
|
|
||||||
& (- PAGE_SIZE)) - obj_datasec(abfd)->size;
|
|
||||||
|
|
||||||
if (data_pad > obj_bsssec(abfd)->size)
|
|
||||||
execp->a_bss = 0;
|
|
||||||
else
|
|
||||||
execp->a_bss = obj_bsssec(abfd)->size - data_pad;
|
|
||||||
execp->a_data = obj_datasec(abfd)->size + data_pad;
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
execp->a_data = obj_datasec (abfd)->size;
|
|
||||||
execp->a_bss = obj_bsssec (abfd)->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
execp->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
|
|
||||||
execp->a_entry = bfd_get_start_address (abfd);
|
|
||||||
|
|
||||||
execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *
|
|
||||||
obj_reloc_entry_size (abfd));
|
|
||||||
|
|
||||||
execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *
|
|
||||||
obj_reloc_entry_size (abfd));
|
|
||||||
|
|
||||||
bfd_aout_swap_exec_header_out (abfd, execp, exec_bytes);
|
|
||||||
|
|
||||||
bfd_seek (abfd, 0L, false);
|
|
||||||
bfd_write ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd);
|
|
||||||
|
|
||||||
/* Now write out reloc info, followed by syms and strings */
|
|
||||||
|
|
||||||
if (bfd_get_symcount (abfd) != 0)
|
|
||||||
{
|
|
||||||
bfd_seek (abfd,
|
|
||||||
(long)(N_SYMOFF(*execp)), false);
|
|
||||||
|
|
||||||
aout_write_syms (abfd);
|
|
||||||
|
|
||||||
bfd_seek (abfd, (long)(N_TRELOFF(*execp)), false);
|
|
||||||
|
|
||||||
if (!aout_squirt_out_relocs (abfd, obj_textsec (abfd))) return false;
|
|
||||||
bfd_seek (abfd, (long)(N_DRELOFF(*execp)), false);
|
|
||||||
|
|
||||||
if (!aout_squirt_out_relocs (abfd, obj_datasec (abfd))) return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We use BFD generic archive files. */
|
/* We use BFD generic archive files. */
|
||||||
#define aout_openr_next_archived_file bfd_generic_openr_next_archived_file
|
#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file
|
||||||
#define aout_generic_stat_arch_elt bfd_generic_stat_arch_elt
|
#define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt
|
||||||
#define aout_slurp_armap bfd_slurp_bsd_armap
|
#define aout_32_slurp_armap bfd_slurp_bsd_armap
|
||||||
#define aout_slurp_extended_name_table bfd_true
|
#define aout_32_slurp_extended_name_table bfd_true
|
||||||
#define aout_write_armap bsd_write_armap
|
#define aout_32_write_armap bsd_write_armap
|
||||||
#define aout_truncate_arname bfd_bsd_truncate_arname
|
#define aout_32_truncate_arname bfd_bsd_truncate_arname
|
||||||
|
/* #define aout_32_machine_type sunos_machine_type */
|
||||||
|
|
||||||
/* We use traditional Unix core file format. */
|
/* Traditional Unix core files with upage */
|
||||||
#define aout_core_file_failing_command trad_unix_core_file_failing_command
|
#define aout_32_core_file_failing_command trad_unix_core_file_failing_command
|
||||||
#define aout_core_file_failing_signal trad_unix_core_file_failing_signal
|
#define aout_32_core_file_failing_signal trad_unix_core_file_failing_signal
|
||||||
#define aout_core_file_matches_executable_p \
|
#define aout_32_core_file_matches_executable_p trad_unix_core_file_matches_executable_p
|
||||||
trad_unix_core_file_matches_executable_p
|
|
||||||
|
|
||||||
/* We replace this function */
|
|
||||||
#define aout_write_object_contents host_aout_write_object_contents
|
#define aout_64_openr_next_archived_file bfd_generic_openr_next_archived_file
|
||||||
|
#define aout_64_generic_stat_arch_elt bfd_generic_stat_arch_elt
|
||||||
|
#define aout_64_slurp_armap bfd_slurp_bsd_armap
|
||||||
|
#define aout_64_slurp_extended_name_table bfd_true
|
||||||
|
#define aout_64_write_armap bsd_write_armap
|
||||||
|
#define aout_64_truncate_arname bfd_bsd_truncate_arname
|
||||||
|
/* #define aout_64_machine_type sunos_machine_type */
|
||||||
|
|
||||||
|
#define aout_64_core_file_failing_command trad_unix_core_file_failing_command
|
||||||
|
#define aout_64_core_file_failing_signal trad_unix_core_file_failing_signal
|
||||||
|
#define aout_64_core_file_matches_executable_p trad_unix_core_file_matches_executable_p
|
||||||
|
|
||||||
|
#define aout_64_bfd_debug_info_start bfd_void
|
||||||
|
#define aout_64_bfd_debug_info_end bfd_void
|
||||||
|
#define aout_64_bfd_debug_info_accumulate bfd_void
|
||||||
|
|
||||||
|
#define aout_32_bfd_debug_info_start bfd_void
|
||||||
|
#define aout_32_bfd_debug_info_end bfd_void
|
||||||
|
#define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
|
||||||
|
|
||||||
|
|
||||||
|
/* We implement these routines ourselves, rather than using the generic
|
||||||
|
a.out versions. */
|
||||||
|
#define aout_write_object_contents host_write_object_contents
|
||||||
|
|
||||||
bfd_target host_aout_big_vec =
|
bfd_target host_aout_big_vec =
|
||||||
{
|
{
|
||||||
"a.out-host-big", /* name */
|
"a.out-host-big",
|
||||||
bfd_target_aout_flavour_enum,
|
bfd_target_aout_flavour_enum,
|
||||||
true, /* target byte order */
|
true, /* target byte order */
|
||||||
true, /* target headers byte order */
|
true, /* target headers byte order */
|
||||||
(HAS_RELOC | EXEC_P | /* object flags */
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
HAS_LINENO | HAS_DEBUG |
|
HAS_LINENO | HAS_DEBUG |
|
||||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
' ', /* ar_pad_char */
|
' ', /* ar_pad_char */
|
||||||
16, /* ar_max_namelen */
|
16, /* ar_max_namelen */
|
||||||
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
|
3, /* minimum alignment power */
|
||||||
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
|
_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
|
||||||
|
_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
|
||||||
{_bfd_dummy_target, host_aout_object_p,
|
|
||||||
|
{_bfd_dummy_target, NAME(host_aout,object_p),
|
||||||
bfd_generic_archive_p, trad_unix_core_file_p},
|
bfd_generic_archive_p, trad_unix_core_file_p},
|
||||||
{bfd_false, host_aout_mkobject,
|
{bfd_false, NAME(host_aout,mkobject),
|
||||||
_bfd_generic_mkarchive, bfd_false},
|
_bfd_generic_mkarchive, bfd_false},
|
||||||
{bfd_false, aout_write_object_contents, /* bfd_write_contents */
|
{bfd_false, NAME(host_aout,write_object_contents), /* bfd_write_contents */
|
||||||
_bfd_write_archive_contents, bfd_false},
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
JUMP_TABLE(aout)
|
JUMP_TABLE(JNAME(aout))
|
||||||
};
|
};
|
||||||
|
|
||||||
bfd_target host_aout_little_vec =
|
bfd_target host_aout_little_vec =
|
||||||
{
|
{
|
||||||
"a.out-host-little", /* name */
|
"a.out-host-little",
|
||||||
bfd_target_aout_flavour_enum,
|
bfd_target_aout_flavour_enum,
|
||||||
false, /* target byte order */
|
false, /* target byte order */
|
||||||
false, /* target headers byte order */
|
false, /* target headers byte order */
|
||||||
(HAS_RELOC | EXEC_P | /* object flags */
|
(HAS_RELOC | EXEC_P | /* object flags */
|
||||||
HAS_LINENO | HAS_DEBUG |
|
HAS_LINENO | HAS_DEBUG |
|
||||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||||
' ', /* ar_pad_char */
|
' ', /* ar_pad_char */
|
||||||
16, /* ar_max_namelen */
|
16, /* ar_max_namelen */
|
||||||
_do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
|
3, /* minimum alignment power */
|
||||||
_do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* hdrs */
|
_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
|
||||||
|
_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
|
||||||
{_bfd_dummy_target, host_aout_object_p,
|
|
||||||
|
{_bfd_dummy_target, NAME(host_aout,object_p),
|
||||||
bfd_generic_archive_p, trad_unix_core_file_p},
|
bfd_generic_archive_p, trad_unix_core_file_p},
|
||||||
{bfd_false, host_aout_mkobject,
|
{bfd_false, NAME(host_aout,mkobject),
|
||||||
_bfd_generic_mkarchive, bfd_false},
|
_bfd_generic_mkarchive, bfd_false},
|
||||||
{bfd_false, aout_write_object_contents, /* bfd_write_contents */
|
{bfd_false, NAME(host_aout,write_object_contents), /* bfd_write_contents */
|
||||||
_bfd_write_archive_contents, bfd_false},
|
_bfd_write_archive_contents, bfd_false},
|
||||||
|
|
||||||
JUMP_TABLE(aout)
|
JUMP_TABLE(JNAME(aout))
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,6 +29,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
#include "oasys.h"
|
#include "oasys.h"
|
||||||
#include "liboasys.h"
|
#include "liboasys.h"
|
||||||
|
|
||||||
|
/* XXX - FIXME. offsetof belongs in the system-specific files in
|
||||||
|
../include/sys. */
|
||||||
/* Define offsetof for those systems which lack it */
|
/* Define offsetof for those systems which lack it */
|
||||||
|
|
||||||
#ifndef offsetof
|
#ifndef offsetof
|
||||||
|
@ -347,11 +349,9 @@ static boolean
|
||||||
DEFUN(oasys_mkobject,(abfd),
|
DEFUN(oasys_mkobject,(abfd),
|
||||||
bfd *abfd)
|
bfd *abfd)
|
||||||
{
|
{
|
||||||
oasys_data_type *oasys;
|
|
||||||
|
|
||||||
set_tdata (abfd,
|
set_tdata (abfd,
|
||||||
(oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type)));
|
(oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type)));
|
||||||
oasys = oasys_data(abfd);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,8 +757,8 @@ DEFUN(oasys_get_section_contents,(abfd, section, location, offset, count),
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
DEFUN(oasys_canonicalize_reloc,(abfd, section, relptr, symbols),
|
DEFUN(oasys_canonicalize_reloc,(ignore_abfd, section, relptr, symbols),
|
||||||
bfd *abfd AND
|
bfd *ignore_abfd AND
|
||||||
sec_ptr section AND
|
sec_ptr section AND
|
||||||
arelent **relptr AND
|
arelent **relptr AND
|
||||||
asymbol **symbols)
|
asymbol **symbols)
|
||||||
|
|
42
bfd/opncls.c
42
bfd/opncls.c
|
@ -30,27 +30,6 @@ FILE *bfd_open_file();
|
||||||
/* fdopen is a loser -- we should use stdio exclusively. Unfortunately
|
/* fdopen is a loser -- we should use stdio exclusively. Unfortunately
|
||||||
if we do that we can't use fcntl. */
|
if we do that we can't use fcntl. */
|
||||||
|
|
||||||
/** Locking
|
|
||||||
|
|
||||||
Locking is loosely controlled by the preprocessor variable
|
|
||||||
BFD_LOCKS. I say loosely because Unix barely understands locking
|
|
||||||
-- at least in BSD it doesn't affect programs which don't
|
|
||||||
explicitly use it! That is to say it's practically useless, though
|
|
||||||
if everyone uses this library you'll be OK.
|
|
||||||
|
|
||||||
From among the many and varied lock facilities available, (none of
|
|
||||||
which, of course, knows about any other) we use the fcntl locks,
|
|
||||||
because they're Posix.
|
|
||||||
|
|
||||||
The reason that @code{bfd_openr} and @code{bfd_fdopenr} exist, yet
|
|
||||||
only @code{bfd_openw} exists is because of locking. When we do
|
|
||||||
output, we lock the filename file for output, then open a temporary
|
|
||||||
file which does not actually get its correct filename until closing
|
|
||||||
time. This is safest, but requires the asymmetry in read and write
|
|
||||||
entry points.
|
|
||||||
|
|
||||||
Perhaps, since unix has so many different kinds of locking anyway,
|
|
||||||
we should use the emacs lock scheme?... */
|
|
||||||
|
|
||||||
#define obstack_chunk_alloc malloc
|
#define obstack_chunk_alloc malloc
|
||||||
#define obstack_chunk_free free
|
#define obstack_chunk_free free
|
||||||
|
@ -65,7 +44,7 @@ bfd *new_bfd()
|
||||||
if (!nbfd)
|
if (!nbfd)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
obstack_begin((PTR)&nbfd->memory, 128);
|
obstack_begin(&nbfd->memory, 128);
|
||||||
|
|
||||||
nbfd->direction = no_direction;
|
nbfd->direction = no_direction;
|
||||||
nbfd->iostream = NULL;
|
nbfd->iostream = NULL;
|
||||||
|
@ -170,19 +149,15 @@ DEFUN(bfd_fdopenr,(filename, target, fd),
|
||||||
bfd *nbfd;
|
bfd *nbfd;
|
||||||
bfd_target *target_vec;
|
bfd_target *target_vec;
|
||||||
int fdflags;
|
int fdflags;
|
||||||
#ifdef BFD_LOCKS
|
|
||||||
struct flock lock, *lockp = &lock;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bfd_error = system_call_error;
|
bfd_error = system_call_error;
|
||||||
|
|
||||||
|
#ifdef NO_FCNTL
|
||||||
|
fdflags = O_RDWR; /* Assume full access */
|
||||||
|
#else
|
||||||
fdflags = fcntl (fd, F_GETFL, NULL);
|
fdflags = fcntl (fd, F_GETFL, NULL);
|
||||||
if (fdflags == -1) return NULL;
|
|
||||||
|
|
||||||
#ifdef BFD_LOCKS
|
|
||||||
lockp->l_type = F_RDLCK;
|
|
||||||
if (fcntl (fd, F_SETLKW, lockp) == -1) return NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
if (fdflags == -1) return NULL;
|
||||||
|
|
||||||
nbfd = new_bfd();
|
nbfd = new_bfd();
|
||||||
|
|
||||||
|
@ -197,9 +172,6 @@ DEFUN(bfd_fdopenr,(filename, target, fd),
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BFD_LOCKS
|
|
||||||
nbfd->lock = (struct flock *) (nbfd + 1);
|
|
||||||
#endif
|
|
||||||
/* if the fd were open for read only, this still would not hurt: */
|
/* if the fd were open for read only, this still would not hurt: */
|
||||||
nbfd->iostream = (char *) fdopen (fd, "r+");
|
nbfd->iostream = (char *) fdopen (fd, "r+");
|
||||||
if (nbfd->iostream == NULL) {
|
if (nbfd->iostream == NULL) {
|
||||||
|
@ -221,10 +193,6 @@ DEFUN(bfd_fdopenr,(filename, target, fd),
|
||||||
default: abort ();
|
default: abort ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BFD_LOCKS
|
|
||||||
memcpy (nbfd->lock, lockp, sizeof (struct flock))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bfd_cache_init (nbfd);
|
bfd_cache_init (nbfd);
|
||||||
|
|
||||||
return nbfd;
|
return nbfd;
|
||||||
|
|
Loading…
Reference in New Issue