Uses the new small reloc type now.
Currently self hosts on sun4 and sun3
This commit is contained in:
parent
95a876f3fa
commit
e98e6ec111
21 changed files with 2596 additions and 1428 deletions
|
@ -88,6 +88,7 @@ newsos3.c
|
|||
oasys.c
|
||||
opncls.c
|
||||
reloc.c
|
||||
seclet.c
|
||||
section.c
|
||||
srec.c
|
||||
stab-syms.c
|
||||
|
@ -120,7 +121,12 @@ echo Done in `pwd`.
|
|||
#
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.34 1991/12/18 23:01:48 bothner
|
||||
# Revision 1.35 1992/01/24 22:42:49 sac
|
||||
# Uses the new small reloc type now.
|
||||
#
|
||||
# Currently self hosts on sun4 and sun3
|
||||
#
|
||||
# Revision 1.34 1991/12/18 23:01:48 bothner
|
||||
# Use aout-target.h more extensively.
|
||||
# Replace Berkeley functions (e.g. bcopy) with ANSI ones (e.g. memcpy).
|
||||
# Other improvements (see ChangeLog).
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
Fri Jan 24 14:40:17 1992 Steve Chamberlain (sac at rtl.cygnus.com)
|
||||
|
||||
* everything: now modified to use smaller reloc type. Self hosts
|
||||
on sun3 & sun4.
|
||||
|
||||
Sat Jan 18 17:00:16 1992 Fred Fish (fnf at cygnus.com)
|
||||
|
||||
* config/mh-stratus, config/mt-i860-elf, hosts/h-stratus:
|
||||
New files for stratus.
|
||||
|
||||
* configure.in: Add configuration fragments for stratus.
|
||||
|
||||
Wed Jan 15 10:02:43 1992 Fred Fish (fnf at cygnus.com)
|
||||
|
||||
* aoutx.h (NAME(aout,find_nearest_line)): Declare various filename
|
||||
|
|
332
bfd/aout-target.h
Normal file
332
bfd/aout-target.h
Normal file
|
@ -0,0 +1,332 @@
|
|||
/* Define a target vector for a variant of a.out.
|
||||
Copyright (C) 1990-1991 Free Software Foundation, Inc.
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* Set parameters about this a.out file that are machine-dependent.
|
||||
This routine is called from some_aout_object_p just before it returns. */
|
||||
static bfd_target *
|
||||
DEFUN(MY(callback),(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/* Calculate the file positions of the parts of a newly read aout header */
|
||||
obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
|
||||
|
||||
/* The virtual memory addresses of the sections */
|
||||
obj_textsec (abfd)->vma = N_TXTADDR(*execp);
|
||||
obj_datasec (abfd)->vma = N_DATADDR(*execp);
|
||||
obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
|
||||
|
||||
/* The file offsets of the sections */
|
||||
obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
|
||||
obj_datasec (abfd)->filepos = N_DATOFF (*execp);
|
||||
|
||||
/* The file offsets of the relocation info */
|
||||
obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
|
||||
obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
|
||||
|
||||
/* The file offsets of the string table and symbol table. */
|
||||
obj_sym_filepos (abfd) = N_SYMOFF (*execp);
|
||||
obj_str_filepos (abfd) = N_STROFF (*execp);
|
||||
|
||||
/* Determine the architecture and machine type of the object file.
|
||||
*/
|
||||
#ifdef SET_ARCH_MACH
|
||||
SET_ARCH_MACH(abfd, *execp);
|
||||
#else
|
||||
bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
|
||||
#endif
|
||||
|
||||
adata(abfd).page_size = PAGE_SIZE;
|
||||
#ifdef SEGMENT_SIZE
|
||||
adata(abfd).segment_size = SEGMENT_SIZE;
|
||||
#else
|
||||
adata(abfd).segment_size = PAGE_SIZE;
|
||||
#endif
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
#ifndef MY_object_p
|
||||
/* Finish up the reading of an a.out file header */
|
||||
|
||||
static bfd_target *
|
||||
DEFUN(MY(object_p),(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
struct external_exec exec_bytes; /* Raw exec header from file */
|
||||
struct internal_exec exec; /* Cleaned-up exec header */
|
||||
bfd_target *target;
|
||||
|
||||
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE) {
|
||||
bfd_error = wrong_format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
|
||||
|
||||
if (N_BADMAG (exec)) return 0;
|
||||
|
||||
NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
|
||||
target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
|
||||
|
||||
#ifdef ENTRY_CAN_BE_ZERO
|
||||
/* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
|
||||
* means that it isn't obvious if EXEC_P should be set.
|
||||
* All of the following must be true for an executable:
|
||||
* There must be no relocations, the bfd can be neither an
|
||||
* archive nor an archive element, and the file must be executable. */
|
||||
|
||||
if (exec.a_trsize + exec.a_drsize == 0
|
||||
&& bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
|
||||
{
|
||||
struct stat buf;
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR 0100 /* Execute by owner. */
|
||||
#endif
|
||||
if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
|
||||
abfd->flags |= EXEC_P;
|
||||
}
|
||||
#endif /* ENTRY_CAN_BE_ZERO */
|
||||
|
||||
return target;
|
||||
}
|
||||
#define MY_object_p MY(object_p)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MY_mkobject
|
||||
static boolean
|
||||
DEFUN(MY(mkobject),(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
if (NAME(aout,mkobject)(abfd) == false)
|
||||
return false;
|
||||
adata(abfd).page_size = PAGE_SIZE;
|
||||
#ifdef SEGMENT_SIZE
|
||||
adata(abfd).segment_size = SEGMENT_SIZE;
|
||||
#else
|
||||
adata(abfd).segment_size = PAGE_SIZE;
|
||||
#endif
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
return true;
|
||||
}
|
||||
#define MY_mkobject MY(mkobject)
|
||||
#endif
|
||||
|
||||
/* Write an object file.
|
||||
Section contents have already been written. We write the
|
||||
file header, symbols, and relocation. */
|
||||
|
||||
#ifndef MY_write_object_contents
|
||||
static boolean
|
||||
DEFUN(MY(write_object_contents),(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
bfd_size_type data_pad = 0;
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
WRITE_HEADERS(abfd, execp);
|
||||
return true;
|
||||
}
|
||||
#define MY_write_object_contents MY(write_object_contents)
|
||||
#endif
|
||||
|
||||
/* We assume BFD generic archive files. */
|
||||
#ifndef MY_openr_next_archived_file
|
||||
#define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
|
||||
#endif
|
||||
#ifndef MY_generic_stat_arch_elt
|
||||
#define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
|
||||
#endif
|
||||
#ifndef MY_slurp_armap
|
||||
#define MY_slurp_armap bfd_slurp_bsd_armap
|
||||
#endif
|
||||
#ifndef MY_slurp_extended_name_table
|
||||
#define MY_slurp_extended_name_table bfd_true
|
||||
#endif
|
||||
#ifndef MY_write_armap
|
||||
#define MY_write_armap bsd_write_armap
|
||||
#endif
|
||||
#ifndef MY_truncate_arname
|
||||
#define MY_truncate_arname bfd_bsd_truncate_arname
|
||||
#endif
|
||||
|
||||
/* No core file defined here -- configure in trad-core.c separately. */
|
||||
#ifndef MY_core_file_failing_command
|
||||
#define MY_core_file_failing_command _bfd_dummy_core_file_failing_command
|
||||
#endif
|
||||
#ifndef MY_core_file_failing_signal
|
||||
#define MY_core_file_failing_signal _bfd_dummy_core_file_failing_signal
|
||||
#endif
|
||||
#ifndef MY_core_file_matches_executable_p
|
||||
#define MY_core_file_matches_executable_p \
|
||||
_bfd_dummy_core_file_matches_executable_p
|
||||
#endif
|
||||
#ifndef MY_core_file_p
|
||||
#define MY_core_file_p _bfd_dummy_target
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_debug_info_start
|
||||
#define MY_bfd_debug_info_start bfd_void
|
||||
#endif
|
||||
#ifndef MY_bfd_debug_info_end
|
||||
#define MY_bfd_debug_info_end bfd_void
|
||||
#endif
|
||||
#ifndef MY_bfd_debug_info_accumulate
|
||||
#define MY_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
|
||||
#endif
|
||||
|
||||
#ifndef MY_core_file_failing_command
|
||||
#define MY_core_file_failing_command NAME(aout,core_file_failing_command)
|
||||
#endif
|
||||
#ifndef MY_core_file_failing_signal
|
||||
#define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
|
||||
#endif
|
||||
#ifndef MY_core_file_matches_executable_p
|
||||
#define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
|
||||
#endif
|
||||
#ifndef MY_slurp_armap
|
||||
#define MY_slurp_armap NAME(aout,slurp_armap)
|
||||
#endif
|
||||
#ifndef MY_slurp_extended_name_table
|
||||
#define MY_slurp_extended_name_table NAME(aout,slurp_extended_name_table)
|
||||
#endif
|
||||
#ifndef MY_truncate_arname
|
||||
#define MY_truncate_arname NAME(aout,truncate_arname)
|
||||
#endif
|
||||
#ifndef MY_write_armap
|
||||
#define MY_write_armap NAME(aout,write_armap)
|
||||
#endif
|
||||
#ifndef MY_close_and_cleanup
|
||||
#define MY_close_and_cleanup NAME(aout,close_and_cleanup)
|
||||
#endif
|
||||
#ifndef MY_set_section_contents
|
||||
#define MY_set_section_contents NAME(aout,set_section_contents)
|
||||
#endif
|
||||
#ifndef MY_get_section_contents
|
||||
#define MY_get_section_contents NAME(aout,get_section_contents)
|
||||
#endif
|
||||
#ifndef MY_new_section_hook
|
||||
#define MY_new_section_hook NAME(aout,new_section_hook)
|
||||
#endif
|
||||
#ifndef MY_get_symtab_upper_bound
|
||||
#define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
|
||||
#endif
|
||||
#ifndef MY_get_symtab
|
||||
#define MY_get_symtab NAME(aout,get_symtab)
|
||||
#endif
|
||||
#ifndef MY_get_reloc_upper_bound
|
||||
#define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
|
||||
#endif
|
||||
#ifndef MY_canonicalize_reloc
|
||||
#define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
|
||||
#endif
|
||||
#ifndef MY_make_empty_symbol
|
||||
#define MY_make_empty_symbol NAME(aout,make_empty_symbol)
|
||||
#endif
|
||||
#ifndef MY_print_symbol
|
||||
#define MY_print_symbol NAME(aout,print_symbol)
|
||||
#endif
|
||||
#ifndef MY_get_lineno
|
||||
#define MY_get_lineno NAME(aout,get_lineno)
|
||||
#endif
|
||||
#ifndef MY_set_arch_mach
|
||||
#define MY_set_arch_mach NAME(aout,set_arch_mach)
|
||||
#endif
|
||||
#ifndef MY_openr_next_archived_file
|
||||
#define MY_openr_next_archived_file NAME(aout,openr_next_archived_file)
|
||||
#endif
|
||||
#ifndef MY_find_nearest_line
|
||||
#define MY_find_nearest_line NAME(aout,find_nearest_line)
|
||||
#endif
|
||||
#ifndef MY_generic_stat_arch_elt
|
||||
#define MY_generic_stat_arch_elt NAME(aout,generic_stat_arch_elt)
|
||||
#endif
|
||||
#ifndef MY_sizeof_headers
|
||||
#define MY_sizeof_headers NAME(aout,sizeof_headers)
|
||||
#endif
|
||||
#ifndef MY_bfd_debug_info_start
|
||||
#define MY_bfd_debug_info_start NAME(aout,bfd_debug_info_start)
|
||||
#endif
|
||||
#ifndef MY_bfd_debug_info_end
|
||||
#define MY_bfd_debug_info_end NAME(aout,bfd_debug_info_end)
|
||||
#endif
|
||||
#ifndef MY_bfd_debug_info_accumulat
|
||||
#define MY_bfd_debug_info_accumulat NAME(aout,bfd_debug_info_accumulat)
|
||||
#endif
|
||||
|
||||
bfd_target MY(vec) =
|
||||
{
|
||||
TARGETNAME, /* name */
|
||||
bfd_target_aout_flavour,
|
||||
true, /* target byte order */
|
||||
true, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
1, /* minimum alignment */
|
||||
#ifdef TARGET_IS_BIG_ENDIAN_P
|
||||
_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 */
|
||||
#else
|
||||
_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
|
||||
_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */
|
||||
#endif
|
||||
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, MY_core_file_p},
|
||||
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
MY_core_file_failing_command,
|
||||
MY_core_file_failing_signal,
|
||||
MY_core_file_matches_executable_p,
|
||||
MY_slurp_armap,
|
||||
MY_slurp_extended_name_table,
|
||||
MY_truncate_arname,
|
||||
MY_write_armap,
|
||||
MY_close_and_cleanup,
|
||||
MY_set_section_contents,
|
||||
MY_get_section_contents,
|
||||
MY_new_section_hook,
|
||||
MY_get_symtab_upper_bound,
|
||||
MY_get_symtab,
|
||||
MY_get_reloc_upper_bound,
|
||||
MY_canonicalize_reloc,
|
||||
MY_make_empty_symbol,
|
||||
MY_print_symbol,
|
||||
MY_get_lineno,
|
||||
MY_set_arch_mach,
|
||||
MY_openr_next_archived_file,
|
||||
MY_find_nearest_line,
|
||||
MY_generic_stat_arch_elt,
|
||||
MY_sizeof_headers,
|
||||
MY_bfd_debug_info_start,
|
||||
MY_bfd_debug_info_end,
|
||||
MY_bfd_debug_info_accumulate,
|
||||
bfd_generic_get_relocated_section_contents
|
||||
};
|
62
bfd/bfd-in.h
62
bfd/bfd-in.h
|
@ -80,8 +80,6 @@ typedef HOST_64_BIT symvalue;
|
|||
typedef HOST_64_BIT bfd_64_type;
|
||||
#define fprintf_vma(s,x) \
|
||||
fprintf(s,"%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x))
|
||||
#define printf_vma(x) \
|
||||
printf( "%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x))
|
||||
#else
|
||||
typedef struct {int a,b;} bfd_64_type;
|
||||
typedef unsigned long rawdata_offset;
|
||||
|
@ -91,9 +89,9 @@ typedef unsigned long bfd_word;
|
|||
typedef unsigned long bfd_size;
|
||||
typedef unsigned long symvalue;
|
||||
typedef unsigned long bfd_size_type;
|
||||
#define printf_vma(x) printf( "%08lx", x)
|
||||
#define fprintf_vma(s,x) fprintf(s, "%08lx", x)
|
||||
#endif
|
||||
#define printf_vma(x) fprintf_vma(stdout,x)
|
||||
|
||||
typedef unsigned int flagword; /* 32 bits of flags */
|
||||
|
||||
|
@ -183,7 +181,7 @@ typedef struct lineno_cache_entry {
|
|||
typedef struct sec *sec_ptr;
|
||||
|
||||
#define bfd_section_name(bfd, ptr) ((ptr)->name)
|
||||
#define bfd_section_size(bfd, ptr) ((ptr)->size)
|
||||
#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
|
||||
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
|
||||
#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
|
||||
#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags)
|
||||
|
@ -209,10 +207,23 @@ typedef enum bfd_error {
|
|||
invalid_error_code} bfd_ec;
|
||||
|
||||
extern bfd_ec bfd_error;
|
||||
struct reloc_cache_entry;
|
||||
struct bfd_seclet_struct ;
|
||||
|
||||
|
||||
typedef struct bfd_error_vector {
|
||||
PROTO(void,(* nonrepresentable_section ),(CONST bfd *CONST abfd,
|
||||
CONST char *CONST name));
|
||||
PROTO(void,(* undefined_symbol),(CONST struct reloc_cache_entry *rel,
|
||||
CONST struct bfd_seclet_struct *sec
|
||||
));
|
||||
PROTO(void, (* reloc_value_truncated),(CONST struct
|
||||
reloc_cache_entry *rel,
|
||||
struct bfd_seclet_struct *sec));
|
||||
|
||||
PROTO(void, (* reloc_dangerous),(CONST struct reloc_cache_entry *rel,
|
||||
CONST struct bfd_seclet_struct *sec));
|
||||
|
||||
} bfd_error_vector_type;
|
||||
|
||||
PROTO (char *, bfd_errmsg, ());
|
||||
|
@ -223,7 +234,8 @@ typedef enum bfd_print_symbol
|
|||
{
|
||||
bfd_print_symbol_name,
|
||||
bfd_print_symbol_more,
|
||||
bfd_print_symbol_all
|
||||
bfd_print_symbol_all,
|
||||
bfd_print_symbol_nm, /* Pretty format suitable for nm program. */
|
||||
} bfd_print_symbol_type;
|
||||
|
||||
|
||||
|
@ -268,7 +280,8 @@ CAT(NAME,_generic_stat_arch_elt),\
|
|||
CAT(NAME,_sizeof_headers),\
|
||||
CAT(NAME,_bfd_debug_info_start),\
|
||||
CAT(NAME,_bfd_debug_info_end),\
|
||||
CAT(NAME,_bfd_debug_info_accumulate)
|
||||
CAT(NAME,_bfd_debug_info_accumulate),\
|
||||
CAT(NAME,_bfd_get_relocated_section_contents)
|
||||
|
||||
#define COFF_SWAP_TABLE \
|
||||
coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in, \
|
||||
|
@ -294,7 +307,7 @@ extern CONST short _bfd_host_big_endian;
|
|||
#define bfd_get_file_flags(abfd) ((abfd)->flags)
|
||||
#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
|
||||
#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
|
||||
#define bfd_my_archive(abfd) ((abfd)->my_archive);
|
||||
#define bfd_my_archive(abfd) ((abfd)->my_archive)
|
||||
#define bfd_has_map(abfd) ((abfd)->has_armap)
|
||||
#define bfd_header_twiddle_required(abfd) \
|
||||
((((abfd)->xvec->header_byteorder_big_p) \
|
||||
|
@ -318,38 +331,13 @@ extern CONST short _bfd_host_big_endian;
|
|||
|
||||
|
||||
|
||||
/*THE FOLLOWING IS EXTRACTED FROM THE SOURCE */
|
||||
|
||||
|
||||
/*:init.c*/
|
||||
|
||||
/*:opncls.c*/
|
||||
|
||||
|
||||
/*:libbfd.c*/
|
||||
|
||||
/*:section.c*/
|
||||
|
||||
|
||||
/*:archures.c*/
|
||||
|
||||
/*:reloc.c*/
|
||||
|
||||
/*:syms.c*/
|
||||
|
||||
/*:bfd.c*/
|
||||
|
||||
/*:archive.c*/
|
||||
|
||||
/*:core.c*/
|
||||
|
||||
/*:targets.c*/
|
||||
|
||||
/*:format.c*/
|
||||
|
||||
#endif
|
||||
/* ANd more from the source */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
406
bfd/bfd.c
406
bfd/bfd.c
|
@ -24,7 +24,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||
SECTION
|
||||
<<typedef bfd>>
|
||||
|
||||
DESCRIPTION
|
||||
A BFD is has type <<bfd>>; objects of this type are the
|
||||
cornerstone of any application using <<libbfd>>. References
|
||||
though the BFD and to data in the BFD give the entire BFD
|
||||
|
@ -34,131 +33,142 @@ DESCRIPTION
|
|||
contains he major data about the file, and contains pointers
|
||||
to the rest of the data.
|
||||
|
||||
CODE_FRAGMENT
|
||||
.
|
||||
.struct _bfd
|
||||
.{
|
||||
The filename the application opened the BFD with.
|
||||
|
||||
. CONST char *filename;
|
||||
|
||||
A pointer to the target jump table.
|
||||
|
||||
. struct bfd_target *xvec;
|
||||
|
||||
To avoid dragging too many header files into every file that
|
||||
includes @file{bfd.h}, IOSTREAM has been declared as a "char
|
||||
*", and MTIME as a "long". Their correct types, to which they
|
||||
are cast when used, are "FILE *" and "time_t". The iostream
|
||||
is the result of an fopen on the filename.
|
||||
|
||||
. char *iostream;
|
||||
|
||||
Is the file being cached @xref{File Caching}.
|
||||
|
||||
. boolean cacheable;
|
||||
|
||||
Marks whether there was a default target specified when the
|
||||
BFD was opened. This is used to select what matching algorithm
|
||||
to use to chose the back end.
|
||||
|
||||
. boolean target_defaulted;
|
||||
|
||||
The caching routines use these to maintain a
|
||||
least-recently-used list of BFDs (@pxref{File Caching}).
|
||||
|
||||
. struct _bfd *lru_prev, *lru_next;
|
||||
|
||||
When a file is closed by the caching routines, BFD retains
|
||||
state information on the file here:
|
||||
|
||||
. file_ptr where;
|
||||
|
||||
and here:
|
||||
|
||||
. boolean opened_once;
|
||||
|
||||
. boolean mtime_set;
|
||||
|
||||
File modified time
|
||||
|
||||
. long mtime;
|
||||
|
||||
Reserved for an unimplemented file locking extension.
|
||||
|
||||
. int ifd;
|
||||
|
||||
The format which belongs to the BFD.
|
||||
|
||||
. bfd_format format;
|
||||
|
||||
The direction the BFD was opened with
|
||||
|
||||
. enum bfd_direction {no_direction = 0,
|
||||
. read_direction = 1,
|
||||
. write_direction = 2,
|
||||
. both_direction = 3} direction;
|
||||
|
||||
Format_specific flags
|
||||
|
||||
. flagword flags;
|
||||
|
||||
Currently my_archive is tested before adding origin to
|
||||
anything. I believe that this can become always an add of
|
||||
origin, with origin set to 0 for non archive files.
|
||||
|
||||
. file_ptr origin;
|
||||
|
||||
Remember when output has begun, to stop strange things happening.
|
||||
|
||||
. boolean output_has_begun;
|
||||
|
||||
Pointer to linked list of sections
|
||||
|
||||
. struct sec *sections;
|
||||
|
||||
The number of sections
|
||||
|
||||
. unsigned int section_count;
|
||||
|
||||
Stuff only useful for object files:
|
||||
The start address.
|
||||
|
||||
. bfd_vma start_address;
|
||||
|
||||
Used for input and output
|
||||
|
||||
. unsigned int symcount;
|
||||
|
||||
Symbol table for output BFD
|
||||
|
||||
. struct symbol_cache_entry **outsymbols;
|
||||
|
||||
Pointer to structure which contains architecture information
|
||||
|
||||
. struct bfd_arch_info *arch_info;
|
||||
|
||||
Stuff only useful for archives:
|
||||
|
||||
. PTR arelt_data;
|
||||
. struct _bfd *my_archive;
|
||||
. struct _bfd *next;
|
||||
. struct _bfd *archive_head;
|
||||
. boolean has_armap;
|
||||
|
||||
Used by the back end to hold private data.
|
||||
|
||||
. PTR tdata;
|
||||
|
||||
Used by the application to hold private data
|
||||
|
||||
. PTR usrdata;
|
||||
|
||||
Where all the allocated stuff under this BFD goes
|
||||
(@pxref{Memory Usage}).
|
||||
|
||||
. struct obstack memory;
|
||||
. {* The filename the application opened the BFD with. *}
|
||||
. CONST char *filename;
|
||||
.
|
||||
. {* A pointer to the target jump table. *}
|
||||
. struct bfd_target *xvec;
|
||||
.
|
||||
. {* To avoid dragging too many header files into every file that
|
||||
. includes @file{bfd.h}, IOSTREAM has been declared as a "char
|
||||
. *", and MTIME as a "long". Their correct types, to which they
|
||||
. are cast when used, are "FILE *" and "time_t". The iostream
|
||||
. is the result of an fopen on the filename. *}
|
||||
. char *iostream;
|
||||
.
|
||||
. {* Is the file being cached *}
|
||||
.
|
||||
. boolean cacheable;
|
||||
.
|
||||
. {* Marks whether there was a default target specified when the
|
||||
. BFD was opened. This is used to select what matching algorithm
|
||||
. to use to chose the back end. *}
|
||||
.
|
||||
. boolean target_defaulted;
|
||||
.
|
||||
. {* The caching routines use these to maintain a
|
||||
. least-recently-used list of BFDs *}
|
||||
.
|
||||
. struct _bfd *lru_prev, *lru_next;
|
||||
.
|
||||
. {* When a file is closed by the caching routines, BFD retains
|
||||
. state information on the file here:
|
||||
. *}
|
||||
.
|
||||
. file_ptr where;
|
||||
.
|
||||
. {* and here:*}
|
||||
.
|
||||
. boolean opened_once;
|
||||
.
|
||||
. {* Set if we have a locally maintained mtime value, rather than
|
||||
. getting it from the file each time: *}
|
||||
.
|
||||
. boolean mtime_set;
|
||||
.
|
||||
. {* File modified time, if mtime_set is true: *}
|
||||
.
|
||||
. long mtime;
|
||||
.
|
||||
. {* Reserved for an unimplemented file locking extension.*}
|
||||
.
|
||||
. int ifd;
|
||||
.
|
||||
. {* The format which belongs to the BFD.*}
|
||||
.
|
||||
. bfd_format format;
|
||||
.
|
||||
. {* The direction the BFD was opened with*}
|
||||
.
|
||||
. enum bfd_direction {no_direction = 0,
|
||||
. read_direction = 1,
|
||||
. write_direction = 2,
|
||||
. both_direction = 3} direction;
|
||||
.
|
||||
. {* Format_specific flags*}
|
||||
.
|
||||
. flagword flags;
|
||||
.
|
||||
. {* Currently my_archive is tested before adding origin to
|
||||
. anything. I believe that this can become always an add of
|
||||
. origin, with origin set to 0 for non archive files. *}
|
||||
.
|
||||
. file_ptr origin;
|
||||
.
|
||||
. {* Remember when output has begun, to stop strange things
|
||||
. happening. *}
|
||||
. boolean output_has_begun;
|
||||
.
|
||||
. {* Pointer to linked list of sections*}
|
||||
. struct sec *sections;
|
||||
.
|
||||
. {* The number of sections *}
|
||||
. unsigned int section_count;
|
||||
.
|
||||
. {* Stuff only useful for object files:
|
||||
. The start address. *}
|
||||
. bfd_vma start_address;
|
||||
.
|
||||
. {* Used for input and output*}
|
||||
. unsigned int symcount;
|
||||
.
|
||||
. {* Symbol table for output BFD*}
|
||||
. struct symbol_cache_entry **outsymbols;
|
||||
.
|
||||
. {* Pointer to structure which contains architecture information*}
|
||||
. struct bfd_arch_info *arch_info;
|
||||
.
|
||||
. {* Stuff only useful for archives:*}
|
||||
. PTR arelt_data;
|
||||
. struct _bfd *my_archive;
|
||||
. struct _bfd *next;
|
||||
. struct _bfd *archive_head;
|
||||
. boolean has_armap;
|
||||
.
|
||||
. {* Used by the back end to hold private data. *}
|
||||
.
|
||||
. union
|
||||
. {
|
||||
. struct aout_data_struct *aout_data;
|
||||
. struct artdata *aout_ar_data;
|
||||
. struct _oasys_data *oasys_obj_data;
|
||||
. struct _oasys_ar_data *oasys_ar_data;
|
||||
. struct coff_tdata *coff_obj_data;
|
||||
. struct ieee_data_struct *ieee_data;
|
||||
. struct ieee_ar_data_struct *ieee_ar_data;
|
||||
. struct srec_data_struct *srec_data;
|
||||
. struct elf_obj_tdata_struct *elf_obj_data;
|
||||
. struct elf_core_tdata_struct *elf_core_data;
|
||||
. struct bout_data_struct *bout_data;
|
||||
. struct sun_core_struct *sun_core_data;
|
||||
. PTR any;
|
||||
. } tdata;
|
||||
.
|
||||
. {* Used by the application to hold private data*}
|
||||
. PTR usrdata;
|
||||
.
|
||||
. {* Where all the allocated stuff under this BFD goes *}
|
||||
. struct obstack memory;
|
||||
.
|
||||
. asymbol **ld_symbols;
|
||||
.};
|
||||
|
||||
.
|
||||
*/
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
@ -215,11 +225,47 @@ DEFUN(bfd_nonrepresentable_section,(abfd, name),
|
|||
exit(1);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
DEFUN(bfd_undefined_symbol,(relent, seclet),
|
||||
CONST arelent *relent AND
|
||||
CONST struct bfd_seclet_struct *seclet)
|
||||
{
|
||||
asymbol *symbol = *(relent->sym_ptr_ptr);
|
||||
printf("bfd error relocating, symbol %s is undefined\n",
|
||||
symbol->name);
|
||||
exit(1);
|
||||
}
|
||||
static
|
||||
void
|
||||
DEFUN(bfd_reloc_value_truncated,(relent, seclet),
|
||||
CONST arelent *relent AND
|
||||
struct bfd_seclet_struct *seclet)
|
||||
{
|
||||
asymbol *symbol = *(relent->sym_ptr_ptr);
|
||||
printf("bfd error relocating, value truncated\n");
|
||||
exit(1);
|
||||
}
|
||||
static
|
||||
void
|
||||
DEFUN(bfd_reloc_is_dangerous,(relent, seclet),
|
||||
CONST arelent *relent AND
|
||||
CONST struct bfd_seclet_struct *seclet)
|
||||
{
|
||||
asymbol *symbol = *(relent->sym_ptr_ptr);
|
||||
printf("bfd error relocating, dangerous\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bfd_error_vector_type bfd_error_vector =
|
||||
{
|
||||
bfd_nonrepresentable_section
|
||||
bfd_nonrepresentable_section ,
|
||||
bfd_undefined_symbol,
|
||||
bfd_reloc_value_truncated,
|
||||
bfd_reloc_is_dangerous,
|
||||
};
|
||||
|
||||
|
||||
char *
|
||||
bfd_errmsg (error_tag)
|
||||
bfd_ec error_tag;
|
||||
|
@ -264,12 +310,26 @@ DEFUN(bfd_perror,(message),
|
|||
|
||||
/** Symbols */
|
||||
|
||||
/* returns the number of octets of storage required */
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_reloc_upper_bound
|
||||
|
||||
SYNOPSIS
|
||||
unsigned int bfd_get_reloc_upper_bound(bfd *abfd, asection *sect);
|
||||
|
||||
DESCRIPTION
|
||||
This function return the number of bytes required to store the
|
||||
relocation information associated with section <<sect>>
|
||||
attached to bfd <<abfd>>
|
||||
|
||||
*/
|
||||
|
||||
|
||||
unsigned int
|
||||
get_reloc_upper_bound (abfd, asect)
|
||||
bfd *abfd;
|
||||
sec_ptr asect;
|
||||
DEFUN(bfd_get_reloc_upper_bound,(abfd, asect),
|
||||
bfd *abfd AND
|
||||
sec_ptr asect)
|
||||
{
|
||||
if (abfd->format != bfd_object) {
|
||||
bfd_error = invalid_operation;
|
||||
|
@ -279,6 +339,30 @@ get_reloc_upper_bound (abfd, asect)
|
|||
return BFD_SEND (abfd, _get_reloc_upper_bound, (abfd, asect));
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_canonicalize_reloc
|
||||
|
||||
SYNOPSIS
|
||||
unsigned int bfd_canonicalize_reloc
|
||||
(bfd *abfd,
|
||||
asection *sec,
|
||||
arelent **loc,
|
||||
asymbol **syms);
|
||||
|
||||
DESCRIPTION
|
||||
This function calls the back end associated with the open
|
||||
<<abfd>> and translates the external form of the relocation
|
||||
information attached to <<sec>> into the internal canonical
|
||||
form. The table is placed into memory at <<loc>>, which has
|
||||
been preallocated, usually by a call to
|
||||
<<bfd_get_reloc_upper_bound>>.
|
||||
|
||||
The <<syms>> table is also needed for horrible internal magic
|
||||
reasons.
|
||||
|
||||
|
||||
*/
|
||||
unsigned int
|
||||
DEFUN(bfd_canonicalize_reloc,(abfd, asect, location, symbols),
|
||||
bfd *abfd AND
|
||||
|
@ -287,13 +371,35 @@ DEFUN(bfd_canonicalize_reloc,(abfd, asect, location, symbols),
|
|||
asymbol **symbols)
|
||||
{
|
||||
if (abfd->format != bfd_object) {
|
||||
bfd_error = invalid_operation;
|
||||
return 0;
|
||||
}
|
||||
return BFD_SEND (abfd, _bfd_canonicalize_reloc, (abfd, asect, location, symbols));
|
||||
bfd_error = invalid_operation;
|
||||
return 0;
|
||||
}
|
||||
return BFD_SEND (abfd, _bfd_canonicalize_reloc,
|
||||
(abfd, asect, location, symbols));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_set_file_flags
|
||||
|
||||
SYNOPSIS
|
||||
boolean bfd_set_file_flags(bfd *abfd, flagword flags);
|
||||
|
||||
DESCRIPTION
|
||||
This function attempts to set the flag word in the referenced
|
||||
BFD structure to the value supplied.
|
||||
|
||||
Possible errors are:
|
||||
o wrong_format - The target bfd was not of object format.
|
||||
o invalid_operation - The target bfd was open for reading.
|
||||
o invalid_operation -
|
||||
The flag word contained a bit which was not applicable to the
|
||||
type of file. eg, an attempt was made to set the D_PAGED bit
|
||||
on a bfd format which does not support demand paging
|
||||
|
||||
*/
|
||||
|
||||
boolean
|
||||
bfd_set_file_flags (abfd, flags)
|
||||
bfd *abfd;
|
||||
|
@ -318,6 +424,19 @@ bfd_set_file_flags (abfd, flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_set_reloc
|
||||
|
||||
SYNOPSIS
|
||||
void bfd_set_reloc
|
||||
(bfd *abfd, asection *sec, arelent **rel, unsigned int count)
|
||||
|
||||
DESCRIPTION
|
||||
This function sets the relocation pointer and count within a
|
||||
section to the supplied values.
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
bfd_set_reloc (ignore_abfd, asect, location, count)
|
||||
|
@ -344,7 +463,6 @@ FUNCTION
|
|||
bfd_set_start_address
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Marks the entry point of an output BFD.
|
||||
|
||||
RETURNS
|
||||
|
@ -366,16 +484,15 @@ bfd_vma vma;
|
|||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_mtime
|
||||
|
||||
DESCRIPTION
|
||||
Return cached file modification time (e.g. as read from
|
||||
archive header for archive members, or from file system if we
|
||||
have been called before); else determine modify time, cache
|
||||
it, and return it.
|
||||
The bfd_get_mtime function
|
||||
|
||||
SYNOPSIS
|
||||
long bfd_get_mtime(bfd *);
|
||||
|
||||
DESCRIPTION
|
||||
Return file modification time (as read from file system, or
|
||||
from archive header for archive members).
|
||||
|
||||
*/
|
||||
|
||||
long
|
||||
|
@ -392,9 +509,8 @@ bfd_get_mtime (abfd)
|
|||
if (0 != fstat (fileno (fp), &buf))
|
||||
return 0;
|
||||
|
||||
abfd->mtime_set = true;
|
||||
abfd->mtime = buf.st_mtime;
|
||||
return abfd->mtime;
|
||||
abfd->mtime = buf.st_mtime; /* Save value in case anyone wants it */
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -407,8 +523,8 @@ DESCRIPTION
|
|||
.#define bfd_sizeof_headers(abfd, reloc) \
|
||||
. BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
|
||||
.
|
||||
.#define bfd_find_nearest_line(abfd, section, symbols, offset, filename_ptr, func, line_ptr) \
|
||||
. BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, section, symbols, offset, filename_ptr, func, line_ptr))
|
||||
.#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
|
||||
. BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
|
||||
.
|
||||
.#define bfd_debug_info_start(abfd) \
|
||||
. BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
|
||||
|
@ -455,6 +571,8 @@ DESCRIPTION
|
|||
.#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
|
||||
. BFD_SEND (abfd, _bfd_coff_swap_aouthdr_out, (abfd, i, o))
|
||||
.
|
||||
.#define bfd_get_relocated_section_contents(abfd, seclet) \
|
||||
. BFD_SEND (abfd, _bfd_get_relocated_section_contents, (abfd, seclet))
|
||||
*/
|
||||
|
||||
|
||||
|
|
48
bfd/bout.c
48
bfd/bout.c
|
@ -153,6 +153,10 @@ b_out_callback (abfd)
|
|||
/* The starting addresses of the sections. */
|
||||
obj_textsec (abfd)->vma = execp->a_tload;
|
||||
obj_datasec (abfd)->vma = execp->a_dload;
|
||||
|
||||
/* And reload the sizes, since the aout module zaps them */
|
||||
obj_textsec (abfd)->_raw_size = execp->a_text;
|
||||
|
||||
bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */
|
||||
obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
|
||||
|
||||
|
@ -164,14 +168,14 @@ b_out_callback (abfd)
|
|||
obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
|
||||
obj_datasec (abfd)->rel_filepos = N_DROFF(*execp);
|
||||
|
||||
adata(abfd)->page_size = 1; /* Not applicable. */
|
||||
adata(abfd)->segment_size = 1; /* Not applicable. */
|
||||
adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
adata(abfd).page_size = 1; /* Not applicable. */
|
||||
adata(abfd).segment_size = 1; /* Not applicable. */
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
struct container {
|
||||
struct bout_data_struct {
|
||||
struct aoutdata a;
|
||||
struct internal_exec e;
|
||||
};
|
||||
|
@ -180,15 +184,15 @@ static boolean
|
|||
b_out_mkobject (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct container *rawptr;
|
||||
struct bout_data_struct *rawptr;
|
||||
|
||||
rawptr = (struct container *) bfd_zalloc (abfd, sizeof (struct container));
|
||||
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
|
||||
if (rawptr == NULL) {
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
set_tdata (abfd, &rawptr->a);
|
||||
abfd->tdata.bout_data = rawptr;
|
||||
exec_hdr (abfd) = &rawptr->e;
|
||||
|
||||
/* For simplicity's sake we just make all the sections right here. */
|
||||
|
@ -211,9 +215,9 @@ b_out_write_object_contents (abfd)
|
|||
|
||||
exec_hdr (abfd)->a_info = BMAGIC;
|
||||
|
||||
exec_hdr (abfd)->a_text = obj_textsec (abfd)->size;
|
||||
exec_hdr (abfd)->a_data = obj_datasec (abfd)->size;
|
||||
exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->size;
|
||||
exec_hdr (abfd)->a_text = obj_textsec (abfd)->_cooked_size;
|
||||
exec_hdr (abfd)->a_data = obj_datasec (abfd)->_cooked_size;
|
||||
exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_cooked_size;
|
||||
exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
|
||||
exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
|
||||
exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) *
|
||||
|
@ -318,6 +322,9 @@ b_out_slurp_reloc_table (abfd, asect, symbols)
|
|||
sec_ptr asect;
|
||||
asymbol **symbols;
|
||||
{
|
||||
abort();
|
||||
|
||||
#if 0
|
||||
unsigned int count;
|
||||
size_t reloc_size;
|
||||
struct relocation_info *relocs;
|
||||
|
@ -399,7 +406,7 @@ b_out_slurp_reloc_table (abfd, asect, symbols)
|
|||
*/
|
||||
cache_ptr->sym_ptr_ptr = symbols + symnum;
|
||||
cache_ptr->addend = 0;
|
||||
cache_ptr->section = (asection*)NULL;
|
||||
/*!! cache_ptr->section = (asection*)NULL;*/
|
||||
} else {
|
||||
/* In a.out symbols are relative to the beginning of the
|
||||
* file rather than sections ?
|
||||
|
@ -449,6 +456,8 @@ b_out_slurp_reloc_table (abfd, asect, symbols)
|
|||
free (relocs);
|
||||
asect->relocation = reloc_cache;
|
||||
asect->reloc_count = count;
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -458,6 +467,9 @@ b_out_squirt_out_relocs (abfd, section)
|
|||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
abort();
|
||||
|
||||
#if 0
|
||||
arelent **generic;
|
||||
|
||||
unsigned int count = section->reloc_count;
|
||||
|
@ -556,7 +568,7 @@ b_out_squirt_out_relocs (abfd, section)
|
|||
return false;
|
||||
}
|
||||
free ((PTR)native);
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -617,14 +629,14 @@ b_out_set_section_contents (abfd, section, location, offset, count)
|
|||
{
|
||||
if (abfd->output_has_begun == false) { /* set by bfd.c handler */
|
||||
if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL) /*||
|
||||
(obj_textsec (abfd)->size == 0) || (obj_datasec (abfd)->size == 0)*/) {
|
||||
(obj_textsec (abfd)->_cooked_size == 0) || (obj_datasec (abfd)->_cooked_size == 0)*/) {
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
obj_textsec (abfd)->filepos = sizeof(struct internal_exec);
|
||||
obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos
|
||||
+ obj_textsec (abfd)->size;
|
||||
+ obj_textsec (abfd)->_cooked_size;
|
||||
|
||||
}
|
||||
/* regardless, once we know what we're doing, we might as well get going */
|
||||
|
@ -701,7 +713,7 @@ DEFUN(b_out_sizeof_headers,(ignore_abfd, ignore),
|
|||
#define aout_32_bfd_debug_info_end bfd_void
|
||||
#define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
|
||||
|
||||
|
||||
#define aout_32_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
|
||||
bfd_target b_out_vec_big_host =
|
||||
{
|
||||
"b.out.big", /* name */
|
||||
|
|
|
@ -45,7 +45,9 @@ asymbol *symbol;
|
|||
long relocation = 0;
|
||||
|
||||
if (symbol != (asymbol *)NULL) {
|
||||
if (symbol->flags & BSF_FORT_COMM) {
|
||||
if (symbol->section == &bfd_com_section)
|
||||
{
|
||||
|
||||
relocation = 0;
|
||||
} else {
|
||||
relocation = symbol->value;
|
||||
|
@ -83,7 +85,7 @@ DEFUN(a29k_reloc,(abfd, reloc_entry, symbol_in, data, input_section),
|
|||
r_type = reloc_entry->howto->type;
|
||||
|
||||
/* FIXME: Do we need to check for partial linking here */
|
||||
if (symbol_in && (symbol_in->flags & BSF_UNDEFINED))
|
||||
if (symbol_in && (symbol_in->section == &bfd_und_section))
|
||||
{
|
||||
/* Keep the state machine happy in case we're called again */
|
||||
if (r_type == R_IHIHALF)
|
||||
|
@ -233,7 +235,7 @@ static reloc_howto_type howto_table[] =
|
|||
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
void DEFUN(reloc_processing,(relent,reloc, symbols, abfd, section) ,
|
||||
static void DEFUN(reloc_processing,(relent,reloc, symbols, abfd, section) ,
|
||||
arelent *relent AND
|
||||
struct internal_reloc *reloc AND
|
||||
asymbol **symbols AND
|
||||
|
@ -266,7 +268,7 @@ void DEFUN(reloc_processing,(relent,reloc, symbols, abfd, section) ,
|
|||
relent->addend = 0;
|
||||
}
|
||||
relent->address-= section->vma;
|
||||
relent->section = 0;
|
||||
/* relent->section = 0;*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
101
bfd/coff-h8300.c
101
bfd/coff-h8300.c
|
@ -1,6 +1,7 @@
|
|||
/* Motorola 68000 COFF back-end for BFD.
|
||||
/* Hitachi H8/300 COFF back-end for BFD.
|
||||
Copyright (C) 1990-1991 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
Written by Steve Chamberlain
|
||||
sac@cygnus.com
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
|
@ -23,8 +24,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff-h8300.h"
|
||||
#include "internalcoff.h"
|
||||
#include "coff/h8300.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
|
@ -35,12 +36,21 @@ static reloc_howto_type howto_table[] =
|
|||
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff, true),
|
||||
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff, true),
|
||||
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff, true),
|
||||
HOWTO(R_MOVB1, 0, 1, 16, false, 0, true,
|
||||
true,0,"16/8", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_MOVB2, 0, 1, 16, false, 0, true,
|
||||
true,0,"8/16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_JMP1, 0, 1, 16, false, 0, true, true,0,"16/pcrel", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_JMP2, 0, 0, 8, false, 0, true, true,0,"pcrecl/16", true, 0x000000ff,0x000000ff, false),
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x = howto_table[howto->size +(int)howto->pc_relative*3].type; }
|
||||
#define SELECT_RELOC(x,howto) \
|
||||
{ x = howto_table[howto->size +(int)howto->pc_relative*3].type; }
|
||||
|
||||
#define BADMAG(x) H8300BADMAG(x)
|
||||
#define H8300 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
@ -48,8 +58,8 @@ static reloc_howto_type howto_table[] =
|
|||
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
@ -57,8 +67,45 @@ static reloc_howto_type howto_table[] =
|
|||
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||
*/
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) \
|
||||
(internal)->howto = ( howto_table + (relocentry).r_type - R_RELBYTE);
|
||||
static void
|
||||
DEFUN(rtype2howto,(internal, dst),
|
||||
arelent *internal AND
|
||||
struct internal_reloc *dst)
|
||||
{
|
||||
switch (dst->r_type) {
|
||||
case R_RELBYTE:
|
||||
internal->howto = howto_table+ 0;
|
||||
break;
|
||||
case R_RELWORD:
|
||||
internal->howto = howto_table+ 1;
|
||||
break;
|
||||
case R_PCRBYTE:
|
||||
internal->howto = howto_table+3;
|
||||
break;
|
||||
case R_PCRWORD:
|
||||
internal->howto = howto_table+ 4;
|
||||
break;
|
||||
case R_MOVB1:
|
||||
internal->howto = howto_table + 6;
|
||||
break;
|
||||
case R_MOVB2:
|
||||
internal->howto = howto_table + 7;
|
||||
break;
|
||||
case R_JMP1:
|
||||
internal->howto = howto_table +8;
|
||||
break;
|
||||
|
||||
case R_JMP2:
|
||||
internal->howto = howto_table +9;
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
|
||||
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||
|
@ -68,6 +115,40 @@ static reloc_howto_type howto_table[] =
|
|||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void DEFUN(reloc_processing,(relent,reloc, symbols, abfd, section) ,
|
||||
arelent *relent AND
|
||||
struct internal_reloc *reloc AND
|
||||
asymbol **symbols AND
|
||||
bfd *abfd AND
|
||||
asection *section)
|
||||
{
|
||||
|
||||
asymbol *ptr;
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto(relent,reloc);
|
||||
|
||||
if (reloc->r_symndx > 0)
|
||||
{
|
||||
|
||||
relent->sym_ptr_ptr = symbols + obj_convert(abfd)[reloc->r_symndx];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = &(bfd_abs_symbol);
|
||||
}
|
||||
|
||||
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
|
||||
relent->address-= section->vma;
|
||||
/* relent->section = 0;*/
|
||||
}
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
|
||||
|
@ -84,7 +165,7 @@ bfd_target h8300coff_vec =
|
|||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
|
||||
|
||||
(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 */
|
||||
15, /* ar_max_namelen */
|
||||
1, /* minimum section alignment */
|
||||
|
|
690
bfd/coffcode.h
690
bfd/coffcode.h
File diff suppressed because it is too large
Load diff
|
@ -132,18 +132,18 @@ void DEFUN(bfd_constructor_entry,(abfd, symbol_ptr_ptr, type),
|
|||
arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd,
|
||||
sizeof(arelent_chain));
|
||||
|
||||
reloc->relent.section = (asection *)NULL;
|
||||
/* reloc->relent.section = (asection *)NULL;*/
|
||||
reloc->relent.addend = 0;
|
||||
|
||||
reloc->relent.sym_ptr_ptr = symbol_ptr_ptr;
|
||||
reloc->next = rel_section->constructor_chain;
|
||||
rel_section->constructor_chain = reloc;
|
||||
reloc->relent.address = rel_section->size;
|
||||
reloc->relent.address = rel_section->_cooked_size;
|
||||
/* ask the cpu which howto to use */
|
||||
reloc->relent.howto =
|
||||
bfd_reloc_type_lookup(abfd->arch_info,
|
||||
BFD_RELOC_CTOR);
|
||||
rel_section->size += sizeof(int *);
|
||||
rel_section->_cooked_size += sizeof(int *);
|
||||
rel_section->reloc_count++;
|
||||
}
|
||||
|
||||
|
|
45
bfd/elf.c
45
bfd/elf.c
|
@ -100,16 +100,17 @@ typedef struct
|
|||
in the bfd structure. This information is different for ELF core files
|
||||
and other ELF files. */
|
||||
|
||||
typedef struct
|
||||
typedef struct elf_core_tdata_struct
|
||||
{
|
||||
void *prstatus; /* The raw /proc prstatus structure */
|
||||
void *prpsinfo; /* The raw /proc prpsinfo structure */
|
||||
} elf_core_tdata;
|
||||
|
||||
#define core_prpsinfo(bfd) (((elf_core_tdata *)((bfd)->tdata))->prpsinfo)
|
||||
#define core_prstatus(bfd) (((elf_core_tdata *)((bfd)->tdata))->prstatus)
|
||||
#define core_prpsinfo(bfd) (((bfd)->tdata.elf_core_data))->prpsinfo)
|
||||
#define core_prpstatus(bfd) (((bfd)->tdata.elf_core_data))->prpstatus)
|
||||
|
||||
typedef struct
|
||||
|
||||
typedef struct elf_obj_tdata_struct
|
||||
{
|
||||
file_ptr symtab_filepos; /* Offset to start of ELF symtab section */
|
||||
long symtab_filesz; /* Size of ELF symtab section */
|
||||
|
@ -117,7 +118,7 @@ typedef struct
|
|||
long strtab_filesz; /* Size of ELF string tbl section */
|
||||
} elf_obj_tdata;
|
||||
|
||||
#define elf_tdata(bfd) ((elf_obj_tdata *) ((bfd) -> tdata))
|
||||
#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
|
||||
#define elf_symtab_filepos(bfd) (elf_tdata(bfd) -> symtab_filepos)
|
||||
#define elf_symtab_filesz(bfd) (elf_tdata(bfd) -> symtab_filesz)
|
||||
#define elf_strtab_filepos(bfd) (elf_tdata(bfd) -> strtab_filepos)
|
||||
|
@ -150,7 +151,7 @@ DEFUN(elf_swap_ehdr_in,(abfd, src, dst),
|
|||
Elf_External_Ehdr *src AND
|
||||
Elf_Internal_Ehdr *dst)
|
||||
{
|
||||
bcopy (src -> e_ident, dst -> e_ident, EI_NIDENT);
|
||||
memcpy (dst -> e_ident, src -> e_ident, EI_NIDENT);
|
||||
dst -> e_type = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_type);
|
||||
dst -> e_machine = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_machine);
|
||||
dst -> e_version = bfd_h_get_32 (abfd, (bfd_byte *) src -> e_version);
|
||||
|
@ -223,7 +224,7 @@ DEFUN(bfd_section_from_shdr, (abfd, hdr, shstrtab),
|
|||
name = hdr -> sh_name ? shstrtab + hdr -> sh_name : "unnamed";
|
||||
newsect = bfd_make_section (abfd, name);
|
||||
newsect -> vma = hdr -> sh_addr;
|
||||
newsect -> size = hdr -> sh_size;
|
||||
newsect -> _raw_size = hdr -> sh_size;
|
||||
if (!(hdr -> sh_type == SHT_NOBITS))
|
||||
{
|
||||
newsect -> filepos = hdr -> sh_offset;
|
||||
|
@ -298,7 +299,7 @@ DEFUN(bfd_section_from_phdr, (abfd, hdr, index),
|
|||
(void) strcpy (name, namebuf);
|
||||
newsect = bfd_make_section (abfd, name);
|
||||
newsect -> vma = hdr -> p_vaddr;
|
||||
newsect -> size = hdr -> p_filesz;
|
||||
newsect -> _raw_size = hdr -> p_filesz;
|
||||
newsect -> filepos = hdr -> p_offset;
|
||||
newsect -> flags |= SEC_HAS_CONTENTS;
|
||||
if (hdr -> p_type == PT_LOAD)
|
||||
|
@ -324,7 +325,7 @@ DEFUN(bfd_section_from_phdr, (abfd, hdr, index),
|
|||
(void) strcpy (name, namebuf);
|
||||
newsect = bfd_make_section (abfd, name);
|
||||
newsect -> vma = hdr -> p_vaddr + hdr -> p_filesz;
|
||||
newsect -> size = hdr -> p_memsz - hdr -> p_filesz;
|
||||
newsect -> _raw_size = hdr -> p_memsz - hdr -> p_filesz;
|
||||
if (hdr -> p_type == PT_LOAD)
|
||||
{
|
||||
newsect -> flags |= SEC_ALLOC;
|
||||
|
@ -362,7 +363,7 @@ DEFUN(bfd_prstatus,(abfd, descdata, descsz, filepos),
|
|||
newsect -> alignment_power = 2;
|
||||
if ((core_prstatus (abfd) = bfd_alloc (abfd, descsz)) != NULL)
|
||||
{
|
||||
bcopy (descdata, core_prstatus (abfd), descsz);
|
||||
memcpy (core_prstatus (abfd), descdata, descsz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -418,7 +419,7 @@ char *
|
|||
DEFUN(elf_core_file_failing_command, (abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
#if HAVE_PROCFS
|
||||
#ifdef HAVE_PROCFS
|
||||
if (core_prpsinfo (abfd))
|
||||
{
|
||||
prpsinfo_t *p = core_prpsinfo (abfd);
|
||||
|
@ -444,7 +445,7 @@ static int
|
|||
DEFUN(elf_core_file_failing_signal, (abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
#if HAVE_PROCFS
|
||||
#ifdef HAVE_PROCFS
|
||||
if (core_prstatus (abfd))
|
||||
{
|
||||
return (((prstatus_t *)(core_prstatus (abfd))) -> pr_cursig);
|
||||
|
@ -464,7 +465,7 @@ DEFUN(elf_core_file_matches_executable_p, (core_bfd, exec_bfd),
|
|||
bfd *core_bfd AND
|
||||
bfd *exec_bfd)
|
||||
{
|
||||
#if HAVE_PROCFS
|
||||
#ifdef HAVE_PROCFS
|
||||
char *corename;
|
||||
char *execname;
|
||||
#endif
|
||||
|
@ -477,7 +478,7 @@ DEFUN(elf_core_file_matches_executable_p, (core_bfd, exec_bfd),
|
|||
return (false);
|
||||
}
|
||||
|
||||
#if HAVE_PROCFS
|
||||
#ifdef HAVE_PROCFS
|
||||
|
||||
/* If no prpsinfo, just return true. Otherwise, grab the last component
|
||||
of the exec'd pathname from the prpsinfo. */
|
||||
|
@ -587,7 +588,7 @@ DEFUN(elf_corefile_note, (abfd, hdr),
|
|||
if (sectname != NULL)
|
||||
{
|
||||
newsect = bfd_make_section (abfd, sectname);
|
||||
newsect -> size = i_note.descsz;
|
||||
newsect -> _raw_size = i_note.descsz;
|
||||
newsect -> filepos = filepos;
|
||||
newsect -> flags = SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
newsect -> alignment_power = 2;
|
||||
|
@ -707,7 +708,9 @@ wrong:
|
|||
/* Allocate an instance of the elf_obj_tdata structure and hook it up to
|
||||
the tdata pointer in the bfd. */
|
||||
|
||||
if ((abfd -> tdata = bfd_zalloc (abfd, sizeof (elf_obj_tdata))) == NULL)
|
||||
if ((abfd -> tdata.elf_obj_data =
|
||||
(elf_obj_tdata*) bfd_zalloc (abfd, sizeof (elf_obj_tdata)))
|
||||
== NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return (NULL);
|
||||
|
@ -882,7 +885,9 @@ wrong:
|
|||
/* Allocate an instance of the elf_core_tdata structure and hook it up to
|
||||
the tdata pointer in the bfd. */
|
||||
|
||||
if ((abfd -> tdata = bfd_zalloc (abfd, sizeof (elf_core_tdata))) == NULL)
|
||||
if ((abfd -> tdata.elf_core_data =
|
||||
(elf_core_tdata *) bfd_zalloc (abfd, sizeof (elf_core_tdata)))
|
||||
== NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return (NULL);
|
||||
|
@ -1049,11 +1054,11 @@ DEFUN (elf_slurp_symbol_table, (abfd), bfd *abfd)
|
|||
}
|
||||
else if (i_sym.st_shndx == SHN_ABS)
|
||||
{
|
||||
sym -> flags |= BSF_ABSOLUTE;
|
||||
/* sym -> flags |= BSF_ABSOLUTE; OBSOLETE */
|
||||
}
|
||||
else if (i_sym.st_shndx == SHN_COMMON)
|
||||
{
|
||||
sym -> flags |= BSF_FORT_COMM;
|
||||
sym -> section = &bfd_com_section;
|
||||
}
|
||||
switch (ELF_ST_BIND (i_sym.st_info))
|
||||
{
|
||||
|
@ -1256,6 +1261,8 @@ DEFUN (elf_sizeof_headers, (abfd, reloc),
|
|||
#define elf_bfd_debug_info_start bfd_void
|
||||
#define elf_bfd_debug_info_end bfd_void
|
||||
#define elf_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
|
||||
#define elf_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
|
||||
bfd_target elf_big_vec =
|
||||
{
|
||||
|
|
352
bfd/ieee.c
352
bfd/ieee.c
|
@ -185,19 +185,21 @@ DEFUN(read_id,(ieee),
|
|||
}
|
||||
|
||||
static void
|
||||
DEFUN(ieee_write_expression,(abfd, value, section, symbol, pcrel, index),
|
||||
DEFUN(ieee_write_expression,(abfd, value,/* section,*/ symbol, pcrel, index),
|
||||
bfd*abfd AND
|
||||
bfd_vma value AND
|
||||
asection *section AND
|
||||
/* asection *section AND*/
|
||||
asymbol *symbol AND
|
||||
boolean pcrel AND
|
||||
unsigned int index)
|
||||
{
|
||||
asection *section;
|
||||
|
||||
unsigned int plus_count = 0;
|
||||
if (value != 0)
|
||||
ieee_write_int(abfd, value);
|
||||
|
||||
if (section != (asection *)NULL) {
|
||||
if (section != &bfd_abs_section) {
|
||||
plus_count++;
|
||||
ieee_write_byte(abfd, ieee_variable_R_enum);
|
||||
ieee_write_byte(abfd, section->index +IEEE_SECTION_NUMBER_BASE);
|
||||
|
@ -207,8 +209,8 @@ DEFUN(ieee_write_expression,(abfd, value, section, symbol, pcrel, index),
|
|||
|
||||
if (symbol != (asymbol *)NULL) {
|
||||
plus_count++;
|
||||
if ((symbol->flags & BSF_UNDEFINED ) ||
|
||||
(symbol->flags & BSF_FORT_COMM)) {
|
||||
if ((symbol->section == &bfd_und_section) ||
|
||||
(symbol->section == &bfd_com_section)) {
|
||||
ieee_write_byte(abfd, ieee_variable_X_enum);
|
||||
ieee_write_int(abfd, symbol->value);
|
||||
}
|
||||
|
@ -219,8 +221,8 @@ DEFUN(ieee_write_expression,(abfd, value, section, symbol, pcrel, index),
|
|||
else if (symbol->flags & BSF_LOCAL) {
|
||||
/* This is a reference to a defined local symbol,
|
||||
We can easily do a local as a section+offset */
|
||||
if (symbol->section != (asection *)NULL) {
|
||||
/* If this symbol is not absolute, add the base of it */
|
||||
if (bfd_symbol_is_absolute(symbol) == false) {
|
||||
/* If this symbol is not absolute, add the base of it */
|
||||
ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */
|
||||
ieee_write_byte(abfd, symbol->section->index +
|
||||
IEEE_SECTION_NUMBER_BASE);
|
||||
|
@ -369,10 +371,10 @@ static ieee_symbol_index_type NOSYMBOL = { 0, 0};
|
|||
|
||||
|
||||
static void
|
||||
DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
|
||||
DEFUN(parse_expression,(ieee, value,/* section,*/ symbol, pcrel, extra),
|
||||
ieee_data_type *ieee AND
|
||||
bfd_vma *value AND
|
||||
asection **section AND
|
||||
/* asection **section AND*/
|
||||
ieee_symbol_index_type *symbol AND
|
||||
boolean *pcrel AND
|
||||
unsigned int *extra)
|
||||
|
@ -383,7 +385,8 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
|
|||
#define NOS sp[-1]
|
||||
#define INC sp++;
|
||||
#define DEC sp--;
|
||||
|
||||
asection **section;
|
||||
|
||||
boolean loop = true;
|
||||
ieee_value_type stack[10];
|
||||
|
||||
|
@ -423,7 +426,7 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
|
|||
next_byte(&(ieee->h));
|
||||
PUSH(NOSYMBOL,
|
||||
0,
|
||||
ieee->section_table[must_parse_int(&(ieee->h))]->size);
|
||||
ieee->section_table[must_parse_int(&(ieee->h))]->_cooked_size);
|
||||
break;
|
||||
case ieee_variable_I_enum:
|
||||
case ieee_variable_X_enum:
|
||||
|
@ -501,9 +504,9 @@ DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra),
|
|||
|
||||
|
||||
#define ieee_seek(abfd, offset) \
|
||||
ieee_data(abfd)->h.input_p = ieee_data(abfd)->h.first_byte + offset
|
||||
IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset
|
||||
|
||||
#define ieee_pos(abfd) ieee_data(abfd)->h.input_p -ieee_data(abfd)->h.first_byte
|
||||
#define ieee_pos(abfd) IEEE_DATA(abfd)->h.input_p -IEEE_DATA(abfd)->h.first_byte
|
||||
|
||||
static unsigned int last_index;
|
||||
|
||||
|
@ -545,7 +548,7 @@ static void
|
|||
DEFUN(ieee_slurp_external_symbols,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
file_ptr offset = ieee->w.r.external_part;
|
||||
|
||||
|
||||
|
@ -628,16 +631,13 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
|
|||
symbol_name_index = must_parse_int(&(ieee->h));
|
||||
parse_expression(ieee,
|
||||
&symbol->symbol.value,
|
||||
&symbol->symbol.section,
|
||||
/* &symbol->symbol.section,*/
|
||||
&symbol_ignore,
|
||||
&pcrel_ignore,
|
||||
&extra);
|
||||
if (symbol->symbol.section != (asection *)NULL) {
|
||||
|
||||
symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
|
||||
}
|
||||
else {
|
||||
symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT | BSF_ABSOLUTE;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case ieee_weak_external_reference_enum:
|
||||
|
@ -653,7 +653,7 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
|
|||
value = 0;
|
||||
}
|
||||
/* This turns into a common */
|
||||
symbol->symbol.flags = BSF_FORT_COMM;
|
||||
symbol->symbol.section = &bfd_com_section;
|
||||
symbol->symbol.value = size;
|
||||
}
|
||||
break;
|
||||
|
@ -669,9 +669,9 @@ DEFUN(ieee_slurp_external_symbols,(abfd),
|
|||
symbol->symbol.the_bfd = abfd;
|
||||
symbol->symbol.name = read_id(&(ieee->h));
|
||||
symbol->symbol.udata = (PTR)NULL;
|
||||
symbol->symbol.section = (asection *)NULL;
|
||||
symbol->symbol.section = &bfd_und_section;
|
||||
symbol->symbol.value = (bfd_vma)0;
|
||||
symbol->symbol.flags = BSF_UNDEFINED;
|
||||
symbol->symbol.flags = 0;
|
||||
|
||||
BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);
|
||||
break;
|
||||
|
@ -717,9 +717,9 @@ static void
|
|||
DEFUN(ieee_slurp_symbol_table,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
if (ieee_data(abfd)->read_symbols == false) {
|
||||
if (IEEE_DATA(abfd)->read_symbols == false) {
|
||||
ieee_slurp_external_symbols(abfd);
|
||||
ieee_data(abfd)->read_symbols= true;
|
||||
IEEE_DATA(abfd)->read_symbols= true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -747,14 +747,14 @@ DEFUN(ieee_get_symtab,(abfd, location),
|
|||
ieee_symbol_type *symp;
|
||||
static bfd dummy_bfd;
|
||||
static asymbol empty_symbol =
|
||||
{ &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING | BSF_ABSOLUTE};
|
||||
{ &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING };
|
||||
|
||||
if (abfd->symcount) {
|
||||
|
||||
|
||||
|
||||
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
dummy_bfd.xvec= &ieee_vec;
|
||||
ieee_slurp_symbol_table(abfd);
|
||||
|
||||
|
@ -769,7 +769,7 @@ if (abfd->symcount) {
|
|||
|
||||
|
||||
ieee->external_symbol_base_offset= - ieee->external_symbol_min_index;
|
||||
for (symp = ieee_data(abfd)->external_symbols;
|
||||
for (symp = IEEE_DATA(abfd)->external_symbols;
|
||||
symp != (ieee_symbol_type *)NULL;
|
||||
symp = symp->next) {
|
||||
/* Place into table at correct index locations */
|
||||
|
@ -781,7 +781,7 @@ if (abfd->symcount) {
|
|||
ieee->external_reference_base_offset =
|
||||
- ieee->external_reference_min_index +ieee->external_symbol_count ;
|
||||
|
||||
for (symp = ieee_data(abfd)->external_reference;
|
||||
for (symp = IEEE_DATA(abfd)->external_reference;
|
||||
symp != (ieee_symbol_type *)NULL;
|
||||
symp = symp->next) {
|
||||
location[symp->index + ieee->external_reference_base_offset] =
|
||||
|
@ -815,7 +815,7 @@ static void
|
|||
DEFUN(ieee_slurp_sections,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
file_ptr offset = ieee->w.r.section_part;
|
||||
|
||||
asection *section = (asection *)NULL;
|
||||
|
@ -923,11 +923,11 @@ DEFUN(ieee_slurp_sections,(abfd),
|
|||
switch (t) {
|
||||
case ieee_section_size_enum:
|
||||
section = ieee->section_table[must_parse_int(&(ieee->h))];
|
||||
section->size = must_parse_int(&(ieee->h));
|
||||
section->_raw_size = must_parse_int(&(ieee->h));
|
||||
break;
|
||||
case ieee_physical_region_size_enum:
|
||||
section = ieee->section_table[must_parse_int(&(ieee->h))];
|
||||
section->size = must_parse_int(&(ieee->h));
|
||||
section->_raw_size = must_parse_int(&(ieee->h));
|
||||
break;
|
||||
case ieee_region_base_address_enum:
|
||||
section = ieee->section_table[must_parse_int(&(ieee->h))];
|
||||
|
@ -975,10 +975,10 @@ DEFUN(ieee_archive_p,(abfd),
|
|||
uint8e_type buffer[512];
|
||||
|
||||
int buffer_offset = 0;
|
||||
ieee_ar_data_type *save = ieee_ar_data(abfd);
|
||||
ieee_ar_data_type *save = IEEE_AR_DATA(abfd);
|
||||
ieee_ar_data_type *ieee ;
|
||||
set_tdata(abfd, bfd_alloc(abfd, sizeof(ieee_ar_data_type)));
|
||||
ieee= ieee_ar_data(abfd);
|
||||
abfd->tdata.ieee_ar_data = (ieee_ar_data_type *)bfd_alloc(abfd, sizeof(ieee_ar_data_type));
|
||||
ieee= IEEE_AR_DATA(abfd);
|
||||
|
||||
|
||||
bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
|
||||
|
@ -994,7 +994,7 @@ uint8e_type buffer[512];
|
|||
library= read_id(&(ieee->h));
|
||||
if (strcmp(library , "LIBRARY") != 0) {
|
||||
bfd_release(abfd, ieee);
|
||||
set_tdata (abfd, save);
|
||||
abfd->tdata.ieee_ar_data = save;
|
||||
return (bfd_target *)NULL;
|
||||
}
|
||||
/* Throw away the filename */
|
||||
|
@ -1066,7 +1066,7 @@ static boolean
|
|||
DEFUN(ieee_mkobject,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
set_tdata (abfd, bfd_zalloc(abfd,sizeof(ieee_data_type)));
|
||||
abfd->tdata.ieee_data = (ieee_data_type *)bfd_zalloc(abfd,sizeof(ieee_data_type));
|
||||
|
||||
|
||||
return true;
|
||||
|
@ -1080,10 +1080,10 @@ DEFUN(ieee_object_p,(abfd),
|
|||
unsigned int part;
|
||||
ieee_data_type *ieee;
|
||||
uint8e_type buffer[300];
|
||||
ieee_data_type *save = ieee_data(abfd);
|
||||
set_tdata (abfd, 0);
|
||||
ieee_data_type *save = IEEE_DATA(abfd);
|
||||
abfd->tdata.ieee_data = 0;
|
||||
ieee_mkobject(abfd);
|
||||
ieee = ieee_data(abfd);
|
||||
ieee = IEEE_DATA(abfd);
|
||||
|
||||
/* Read the first few bytes in to see if it makes sense */
|
||||
bfd_read((PTR)buffer, 1, sizeof(buffer), abfd);
|
||||
|
@ -1155,16 +1155,16 @@ DEFUN(ieee_object_p,(abfd),
|
|||
quickly. We can work out how big the file is from the trailer
|
||||
record */
|
||||
|
||||
ieee_data(abfd)->h.first_byte = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
|
||||
IEEE_DATA(abfd)->h.first_byte = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record
|
||||
+ 50);
|
||||
bfd_seek(abfd, 0, 0);
|
||||
bfd_read((PTR)(ieee_data(abfd)->h.first_byte), 1, ieee->w.r.me_record+50, abfd);
|
||||
bfd_read((PTR)(IEEE_DATA(abfd)->h.first_byte), 1, ieee->w.r.me_record+50, abfd);
|
||||
|
||||
ieee_slurp_sections(abfd);
|
||||
return abfd->xvec;
|
||||
fail:
|
||||
(void) bfd_release(abfd, ieee);
|
||||
set_tdata (abfd, save);
|
||||
abfd->tdata.ieee_data = save;
|
||||
return (bfd_target *)NULL;
|
||||
}
|
||||
|
||||
|
@ -1262,9 +1262,11 @@ DEFUN(do_one,(ieee, current_map, location_ptr,s),
|
|||
current_map->reloc_tail_ptr= &r->next;
|
||||
r->next = (ieee_reloc_type *)NULL;
|
||||
next_byte(&(ieee->h));
|
||||
abort();
|
||||
|
||||
parse_expression(ieee,
|
||||
&r->relent.addend,
|
||||
&r->relent.section,
|
||||
/* &r->relent.section,*/
|
||||
&r->symbol,
|
||||
&pcrel, &extra);
|
||||
r->relent.address = current_map->pc;
|
||||
|
@ -1394,7 +1396,7 @@ DEFUN(ieee_slurp_section_data,(abfd),
|
|||
bfd *abfd)
|
||||
{
|
||||
bfd_byte *location_ptr = (bfd_byte *)NULL;
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
unsigned int section_number ;
|
||||
|
||||
ieee_per_section_type *current_map = (ieee_per_section_type *)NULL;
|
||||
|
@ -1409,7 +1411,7 @@ DEFUN(ieee_slurp_section_data,(abfd),
|
|||
|
||||
for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
|
||||
ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
|
||||
per->data = (bfd_byte *) bfd_alloc(ieee->h.abfd, s->size);
|
||||
per->data = (bfd_byte *) bfd_alloc(ieee->h.abfd, s->_raw_size);
|
||||
/*SUPPRESS 68*/
|
||||
per->reloc_tail_ptr =
|
||||
(ieee_reloc_type **)&(s->relocation);
|
||||
|
@ -1450,10 +1452,12 @@ DEFUN(ieee_slurp_section_data,(abfd),
|
|||
boolean pcrel;
|
||||
next_byte(&(ieee->h));
|
||||
must_parse_int(&(ieee->h)); /* Thow away section #*/
|
||||
parse_expression(ieee, &value, &dsection, &symbol,
|
||||
parse_expression(ieee, &value,
|
||||
/* &dsection, */
|
||||
&symbol,
|
||||
&pcrel, &extra);
|
||||
current_map->pc = value;
|
||||
BFD_ASSERT((unsigned)(value - s->vma) <= s->size);
|
||||
BFD_ASSERT((unsigned)(value - s->vma) <= s->_raw_size);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1556,7 +1560,7 @@ DEFUN(ieee_canonicalize_reloc,(abfd, section, relptr, symbols),
|
|||
{
|
||||
/* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
|
||||
ieee_reloc_type *src = (ieee_reloc_type *)(section->relocation);
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
|
||||
while (src != (ieee_reloc_type *)NULL) {
|
||||
/* Work out which symbol to attach it this reloc to */
|
||||
|
@ -1599,25 +1603,28 @@ static void
|
|||
DEFUN(ieee_write_section_part,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
asection *s;
|
||||
ieee->w.r.section_part = bfd_tell(abfd);
|
||||
for (s = abfd->sections; s != (asection *)NULL; s=s->next) {
|
||||
ieee_write_byte(abfd, ieee_section_type_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
if (s != &bfd_abs_section)
|
||||
{
|
||||
|
||||
ieee_write_byte(abfd, ieee_section_type_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
|
||||
if (abfd->flags & EXEC_P)
|
||||
if (abfd->flags & EXEC_P)
|
||||
{
|
||||
/* This image is executable, so output absolute sections */
|
||||
ieee_write_byte(abfd, ieee_variable_A_enum);
|
||||
ieee_write_byte(abfd, ieee_variable_S_enum);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
ieee_write_byte(abfd, ieee_variable_C_enum);
|
||||
}
|
||||
|
||||
switch (s->flags &(SEC_CODE | SEC_DATA | SEC_ROM))
|
||||
switch (s->flags &(SEC_CODE | SEC_DATA | SEC_ROM))
|
||||
{
|
||||
case SEC_CODE | SEC_LOAD:
|
||||
case SEC_CODE:
|
||||
|
@ -1636,30 +1643,31 @@ DEFUN(ieee_write_section_part,(abfd),
|
|||
}
|
||||
|
||||
|
||||
ieee_write_id(abfd, s->name);
|
||||
ieee_write_id(abfd, s->name);
|
||||
#if 0
|
||||
ieee_write_int(abfd, 0); /* Parent */
|
||||
ieee_write_int(abfd, 0); /* Brother */
|
||||
ieee_write_int(abfd, 0); /* Context */
|
||||
ieee_write_int(abfd, 0); /* Parent */
|
||||
ieee_write_int(abfd, 0); /* Brother */
|
||||
ieee_write_int(abfd, 0); /* Context */
|
||||
#endif
|
||||
/* Alignment */
|
||||
ieee_write_byte(abfd, ieee_section_alignment_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_int(abfd, 1 << s->alignment_power);
|
||||
/* Alignment */
|
||||
ieee_write_byte(abfd, ieee_section_alignment_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_int(abfd, 1 << s->alignment_power);
|
||||
|
||||
/* Size */
|
||||
ieee_write_2bytes(abfd, ieee_section_size_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_int(abfd, s->size);
|
||||
if (abfd->flags & EXEC_P) {
|
||||
/* Relocateable sections don't have asl records */
|
||||
/* Vma */
|
||||
ieee_write_2bytes(abfd, ieee_section_base_address_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_int(abfd, s->vma);
|
||||
/* Size */
|
||||
ieee_write_2bytes(abfd, ieee_section_size_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_int(abfd, s->_cooked_size);
|
||||
if (abfd->flags & EXEC_P) {
|
||||
/* Relocateable sections don't have asl records */
|
||||
/* Vma */
|
||||
ieee_write_2bytes(abfd, ieee_section_base_address_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_int(abfd, s->vma);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1688,19 +1696,19 @@ DEFUN(do_with_relocs,(abfd, s),
|
|||
|
||||
ieee_write_twobyte(abfd, ieee_set_current_pc_enum);
|
||||
ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_expression(abfd, 0, s, 0, 0, 0);
|
||||
ieee_write_expression(abfd, 0,/* s,!!!!*/ 0, 0, 0);
|
||||
|
||||
if (relocs_to_go == 0)
|
||||
{
|
||||
/* If there arn't any relocations then output the load constant byte
|
||||
opcode rather than the load with relocation opcode */
|
||||
|
||||
while (current_byte_index < s->size) {
|
||||
while (current_byte_index < s->_cooked_size) {
|
||||
bfd_size_type run;
|
||||
unsigned int MAXRUN = 32;
|
||||
run = MAXRUN;
|
||||
if (run > s->size - current_byte_index) {
|
||||
run = s->size - current_byte_index;
|
||||
if (run > s->_cooked_size - current_byte_index) {
|
||||
run = s->_cooked_size - current_byte_index;
|
||||
}
|
||||
|
||||
if (run != 0) {
|
||||
|
@ -1726,10 +1734,10 @@ DEFUN(do_with_relocs,(abfd, s),
|
|||
|
||||
if ((PTR)stream == (PTR)NULL) {
|
||||
/* Outputting a section without data, fill it up */
|
||||
stream = (uint8e_type *)(bfd_alloc(abfd, s->size));
|
||||
memset((PTR)stream, 0, s->size);
|
||||
stream = (uint8e_type *)(bfd_alloc(abfd, s->_cooked_size));
|
||||
memset((PTR)stream, 0, s->_cooked_size);
|
||||
}
|
||||
while (current_byte_index < s->size) {
|
||||
while (current_byte_index < s->_cooked_size) {
|
||||
bfd_size_type run;
|
||||
unsigned int MAXRUN = 32;
|
||||
if (relocs_to_go) {
|
||||
|
@ -1738,8 +1746,8 @@ DEFUN(do_with_relocs,(abfd, s),
|
|||
else {
|
||||
run = MAXRUN;
|
||||
}
|
||||
if (run > s->size - current_byte_index) {
|
||||
run = s->size - current_byte_index;
|
||||
if (run > s->_cooked_size - current_byte_index) {
|
||||
run = s->_cooked_size - current_byte_index;
|
||||
}
|
||||
|
||||
if (run != 0) {
|
||||
|
@ -1786,16 +1794,17 @@ DEFUN(do_with_relocs,(abfd, s),
|
|||
BFD_FAIL();
|
||||
}
|
||||
ieee_write_byte(abfd, ieee_function_either_open_b_enum);
|
||||
|
||||
abort();
|
||||
|
||||
if (r->sym_ptr_ptr != (asymbol **)NULL) {
|
||||
ieee_write_expression(abfd, r->addend + ov,
|
||||
r->section,
|
||||
/* !!! r->section,*/
|
||||
*(r->sym_ptr_ptr),
|
||||
r->howto->pc_relative, s->index);
|
||||
}
|
||||
else {
|
||||
ieee_write_expression(abfd, r->addend + ov,
|
||||
r->section,
|
||||
/*!!! r->section,*/
|
||||
(asymbol *)NULL,
|
||||
r->howto->pc_relative, s->index);
|
||||
}
|
||||
|
@ -1833,7 +1842,7 @@ DEFUN(do_as_repeat, (abfd, s),
|
|||
ieee_write_int(abfd, s->vma );
|
||||
|
||||
ieee_write_byte(abfd,ieee_repeat_data_enum);
|
||||
ieee_write_int(abfd, s->size);
|
||||
ieee_write_int(abfd, s->_cooked_size);
|
||||
ieee_write_byte(abfd, ieee_load_constant_bytes_enum);
|
||||
ieee_write_byte(abfd, 1);
|
||||
ieee_write_byte(abfd, 0);
|
||||
|
@ -1853,7 +1862,7 @@ DEFUN(do_without_relocs, (abfd, s),
|
|||
else
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < s->size; i++) {
|
||||
for (i = 0; i < s->_cooked_size; i++) {
|
||||
if (stream[i] != 0) {
|
||||
do_with_relocs(abfd, s);
|
||||
return;
|
||||
|
@ -2004,7 +2013,7 @@ NEXT();
|
|||
section_number = THIS();
|
||||
|
||||
NEXT();
|
||||
ieee= ieee_data(input_bfd);
|
||||
ieee= IEEE_DATA(input_bfd);
|
||||
s = ieee->section_table[section_number];
|
||||
if (s->output_section) {
|
||||
value = s->output_section->vma ;
|
||||
|
@ -2387,7 +2396,7 @@ static void
|
|||
DEFUN(ieee_write_debug_part, (abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
bfd_chain_type *chain = ieee->chain_root;
|
||||
unsigned char output_buffer[OBS];
|
||||
boolean some_debug = false;
|
||||
|
@ -2400,58 +2409,64 @@ DEFUN(ieee_write_debug_part, (abfd),
|
|||
|
||||
if (chain == (bfd_chain_type *)NULL) {
|
||||
#if 0
|
||||
/* There is no debug info, so we'll fake some up */
|
||||
CONST static char fake[] = {
|
||||
0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
|
||||
'1','.','1',0x82, 1991>>8, 1991 & 0xff, 9, 20, 11, 07,50 };
|
||||
ieee->w.r.debug_information_part = 0;
|
||||
|
||||
|
||||
here;
|
||||
|
||||
|
||||
/* bfd_write(fake, 1, sizeof(fake), abfd);*/
|
||||
/* Now write a header for each section */
|
||||
{
|
||||
int i = 0;
|
||||
asection *s = abfd->sections;
|
||||
while (s) {
|
||||
ieee_write_byte(abfd, 0xf8);
|
||||
ieee_write_byte(abfd, 0x0b);
|
||||
ieee_write_byte(abfd, 0);
|
||||
ieee_write_byte(abfd, 0);
|
||||
ieee_write_byte(abfd, 1);
|
||||
ieee_write_byte(abfd, i + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_expression(abfd, 0, s, 0, 0, 0);
|
||||
ieee_write_byte(abfd,0);
|
||||
ieee_write_byte(abfd, 0xf9);
|
||||
ieee_write_expression(abfd, s->size, 0, 0, 0, 0);
|
||||
s = s->next;
|
||||
i++;
|
||||
}
|
||||
/* Close the scope */
|
||||
ieee_write_byte(abfd, 0xf9);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
while (chain != (bfd_chain_type *)NULL) {
|
||||
bfd *entry = chain->this;
|
||||
ieee_data_type *entry_ieee = ieee_data(entry);
|
||||
if (entry_ieee->w.r.debug_information_part) {
|
||||
bfd_seek(entry, entry_ieee->w.r.debug_information_part, SEEK_SET);
|
||||
relocate_debug(abfd, entry);
|
||||
}
|
||||
|
||||
chain = chain->next;
|
||||
}
|
||||
if (some_debug) {
|
||||
ieee->w.r.debug_information_part = here;
|
||||
}
|
||||
else {
|
||||
/* There is no debug info, so we'll fake some up */
|
||||
CONST static char fake[] = {
|
||||
0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3,
|
||||
'1','.','1',0x82, 1991>>8, 1991 & 0xff, 9, 20, 11, 07,50 };
|
||||
ieee->w.r.debug_information_part = 0;
|
||||
|
||||
|
||||
here;
|
||||
|
||||
|
||||
/* bfd_write(fake, 1, sizeof(fake), abfd);*/
|
||||
/* Now write a header for each section */
|
||||
{
|
||||
int i = 0;
|
||||
asection *s = abfd->sections;
|
||||
while (s) {
|
||||
if (s != abfd->abs_section)
|
||||
{
|
||||
|
||||
ieee_write_byte(abfd, 0xf8);
|
||||
ieee_write_byte(abfd, 0x0b);
|
||||
ieee_write_byte(abfd, 0);
|
||||
ieee_write_byte(abfd, 0);
|
||||
ieee_write_byte(abfd, 1);
|
||||
ieee_write_byte(abfd, i + IEEE_SECTION_NUMBER_BASE);
|
||||
ieee_write_expression(abfd, 0, s, 0, 0, 0);
|
||||
ieee_write_byte(abfd,0);
|
||||
ieee_write_byte(abfd, 0xf9);
|
||||
ieee_write_expression(abfd, s->size, 0, 0, 0, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
s = s->next;
|
||||
|
||||
}
|
||||
/* Close the scope */
|
||||
ieee_write_byte(abfd, 0xf9);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
while (chain != (bfd_chain_type *)NULL) {
|
||||
bfd *entry = chain->this;
|
||||
ieee_data_type *entry_ieee = IEEE_DATA(entry);
|
||||
if (entry_ieee->w.r.debug_information_part) {
|
||||
bfd_seek(entry, entry_ieee->w.r.debug_information_part, SEEK_SET);
|
||||
relocate_debug(abfd, entry);
|
||||
}
|
||||
|
||||
chain = chain->next;
|
||||
}
|
||||
if (some_debug) {
|
||||
ieee->w.r.debug_information_part = here;
|
||||
}
|
||||
else {
|
||||
ieee->w.r.debug_information_part = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
flush();
|
||||
|
||||
}
|
||||
|
@ -2461,7 +2476,7 @@ DEFUN(ieee_write_data_part,(abfd),
|
|||
bfd *abfd)
|
||||
{
|
||||
asection *s;
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
ieee->w.r.data_part = bfd_tell(abfd);
|
||||
for (s = abfd->sections; s != (asection *)NULL; s = s->next)
|
||||
{
|
||||
|
@ -2486,8 +2501,8 @@ DEFUN(init_for_output,(abfd),
|
|||
{
|
||||
asection *s;
|
||||
for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
|
||||
if (s->size != 0) {
|
||||
ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->size));
|
||||
if (s->_cooked_size != 0) {
|
||||
ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->_cooked_size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2525,7 +2540,7 @@ DEFUN(ieee_write_external_part,(abfd),
|
|||
bfd *abfd)
|
||||
{
|
||||
asymbol **q;
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
|
||||
unsigned int reference_index = IEEE_REFERENCE_BASE;
|
||||
unsigned int public_index = IEEE_PUBLIC_BASE+2;
|
||||
|
@ -2536,7 +2551,7 @@ DEFUN(ieee_write_external_part,(abfd),
|
|||
for (q = abfd->outsymbols; *q != (asymbol *)NULL; q++) {
|
||||
asymbol *p = *q;
|
||||
hadone = true;
|
||||
if (p->flags & BSF_UNDEFINED) {
|
||||
if (p->section == &bfd_und_section) {
|
||||
/* This must be a symbol reference .. */
|
||||
ieee_write_byte(abfd, ieee_external_reference_enum);
|
||||
ieee_write_int(abfd, reference_index);
|
||||
|
@ -2544,7 +2559,7 @@ DEFUN(ieee_write_external_part,(abfd),
|
|||
p->value = reference_index;
|
||||
reference_index++;
|
||||
}
|
||||
else if(p->flags & BSF_FORT_COMM) {
|
||||
else if(p->section == &bfd_com_section) {
|
||||
/* This is a weak reference */
|
||||
ieee_write_byte(abfd, ieee_external_reference_enum);
|
||||
ieee_write_int(abfd, reference_index);
|
||||
|
@ -2574,28 +2589,28 @@ DEFUN(ieee_write_external_part,(abfd),
|
|||
/* Write out the value */
|
||||
ieee_write_2bytes(abfd, ieee_value_record_enum);
|
||||
ieee_write_int(abfd, public_index);
|
||||
if (p->section != (asection *)NULL)
|
||||
if (p->section != &bfd_abs_section)
|
||||
{
|
||||
if (abfd->flags & EXEC_P)
|
||||
{
|
||||
/* If fully linked, then output all symbols
|
||||
relocated */
|
||||
ieee_write_int(abfd,
|
||||
p->value + p->section->output_offset+ p->section->output_section->vma);
|
||||
{
|
||||
/* If fully linked, then output all symbols
|
||||
relocated */
|
||||
ieee_write_int(abfd,
|
||||
p->value + p->section->output_offset+ p->section->output_section->vma);
|
||||
|
||||
}
|
||||
else {
|
||||
ieee_write_expression(abfd,
|
||||
p->value + p->section->output_offset,
|
||||
p->section->output_section,
|
||||
(asymbol *)NULL, false, 0);
|
||||
}
|
||||
else {
|
||||
ieee_write_expression(abfd,
|
||||
p->value + p->section->output_offset,
|
||||
/*!!! p->section->output_section,*/
|
||||
(asymbol *)NULL, false, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ieee_write_expression(abfd,
|
||||
p->value,
|
||||
(asection *)NULL,
|
||||
/*!!! (asection *)NULL,*/
|
||||
(asymbol *)NULL, false, 0);
|
||||
}
|
||||
p->value = public_index;
|
||||
|
@ -2639,7 +2654,7 @@ void
|
|||
DEFUN(ieee_write_me_part,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
ieee_data_type *ieee= ieee_data(abfd);
|
||||
ieee_data_type *ieee= IEEE_DATA(abfd);
|
||||
ieee->w.r.trailer_part = bfd_tell(abfd);
|
||||
if (abfd->start_address) {
|
||||
ieee->w.r.me_record = bfd_tell(abfd);
|
||||
|
@ -2658,7 +2673,7 @@ boolean
|
|||
DEFUN(ieee_write_object_contents,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
ieee_data_type *ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(abfd);
|
||||
unsigned int i;
|
||||
file_ptr old;
|
||||
/* Fast forward over the header area */
|
||||
|
@ -2695,7 +2710,7 @@ DEFUN(ieee_write_object_contents,(abfd),
|
|||
else
|
||||
ieee_write_byte(abfd, 0x2); /* Relocateable */
|
||||
|
||||
ieee->w.r.envimental_record = bfd_tell(abfd);
|
||||
ieee->w.r.environmental_record = bfd_tell(abfd);
|
||||
bfd_write(envi, 1, sizeof(envi), abfd);
|
||||
output_bfd = abfd;
|
||||
flush();
|
||||
|
@ -2768,7 +2783,7 @@ DEFUN(ieee_openr_next_archived_file,(arch, prev),
|
|||
bfd *arch AND
|
||||
bfd *prev)
|
||||
{
|
||||
ieee_ar_data_type *ar = ieee_ar_data(arch);
|
||||
ieee_ar_data_type *ar = IEEE_AR_DATA(arch);
|
||||
/* take the next one from the arch state, or reset */
|
||||
if (prev == (bfd *)NULL) {
|
||||
/* Reset the index - the first two entries are bogus*/
|
||||
|
@ -2819,7 +2834,7 @@ ieee_generic_stat_arch_elt(abfd, buf)
|
|||
bfd *abfd;
|
||||
struct stat *buf;
|
||||
{
|
||||
ieee_ar_data_type *ar = ieee_ar_data(abfd);
|
||||
ieee_ar_data_type *ar = IEEE_AR_DATA(abfd);
|
||||
if (ar == (ieee_ar_data_type *)NULL) {
|
||||
bfd_error = invalid_operation;
|
||||
return -1;
|
||||
|
@ -2863,8 +2878,8 @@ DEFUN(ieee_bfd_debug_info_accumulate,(abfd, section),
|
|||
bfd *abfd AND
|
||||
asection *section)
|
||||
{
|
||||
ieee_data_type *ieee = ieee_data(section->owner);
|
||||
ieee_data_type *output_ieee = ieee_data(abfd);
|
||||
ieee_data_type *ieee = IEEE_DATA(section->owner);
|
||||
ieee_data_type *output_ieee = IEEE_DATA(abfd);
|
||||
/* can only accumulate data from other ieee bfds */
|
||||
if (section->owner->xvec != abfd->xvec)
|
||||
return;
|
||||
|
@ -2911,6 +2926,7 @@ DEFUN(ieee_bfd_debug_info_accumulate,(abfd, section),
|
|||
#define ieee_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
|
||||
#define ieee_close_and_cleanup bfd_generic_close_and_cleanup
|
||||
#define ieee_set_arch_mach bfd_default_set_arch_mach
|
||||
#define ieee_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
|
||||
|
||||
/*SUPPRESS 460 */
|
||||
bfd_target ieee_vec =
|
||||
|
@ -2922,7 +2938,7 @@ bfd_target ieee_vec =
|
|||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|
||||
( SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|
||||
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
|
|
29
bfd/libbfd.h
29
bfd/libbfd.h
|
@ -46,7 +46,7 @@ struct artdata {
|
|||
char *extended_names; /* clever intel extension */
|
||||
};
|
||||
|
||||
#define bfd_ardata(bfd) ((struct artdata *) ((bfd)->tdata))
|
||||
#define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
|
||||
|
||||
/* Goes in bfd's arelt_data slot */
|
||||
struct areltdata {
|
||||
|
@ -189,11 +189,16 @@ extern bfd *bfd_last_cache;
|
|||
/* And more follows */
|
||||
|
||||
void EXFUN(bfd_check_init, (void));
|
||||
PTR EXFUN(bfd_xmalloc, ( bfd_size_type size));
|
||||
void EXFUN(bfd_write_bigendian_4byte_int, (bfd *abfd, int i));
|
||||
bfd_vma EXFUN(bfd_log2, (bfd_vma x));
|
||||
void EXFUN(bfd_check_init, (void));
|
||||
PTR EXFUN(bfd_xmalloc, ( bfd_size_type size));
|
||||
void EXFUN(bfd_write_bigendian_4byte_int, (bfd *abfd, int i));
|
||||
bfd_vma EXFUN(bfd_log2, (bfd_vma x));
|
||||
#define BFD_CACHE_MAX_OPEN 10
|
||||
extern bfd *bfd_last_cache;
|
||||
|
||||
#define bfd_cache_lookup(x) \
|
||||
((x)==bfd_last_cache? \
|
||||
(FILE*)(bfd_last_cache->iostream): \
|
||||
|
@ -203,17 +208,23 @@ void EXFUN(bfd_cache_close , (bfd *));
|
|||
FILE* EXFUN(bfd_open_file, (bfd *));
|
||||
FILE *EXFUN(bfd_cache_lookup_worker, (bfd *));
|
||||
void EXFUN(bfd_constructor_entry, (bfd *abfd,
|
||||
asymbol **symbol_ptr_ptr,
|
||||
CONST char*type));
|
||||
asymbol **symbol_ptr_ptr,
|
||||
CONST char*type));
|
||||
CONST struct reloc_howto_struct *EXFUN(bfd_default_reloc_type_lookup
|
||||
, (CONST struct bfd_arch_info *,
|
||||
bfd_reloc_code_type code));
|
||||
, (CONST struct bfd_arch_info *,
|
||||
bfd_reloc_code_type code));
|
||||
bfd_byte *
|
||||
EXFUN(bfd_generic_get_relocated_section_contents, (bfd *abfd,
|
||||
struct bfd_seclet_struct *seclet)
|
||||
|
||||
);
|
||||
extern bfd_arch_info_type bfd_default_arch_struct;
|
||||
boolean EXFUN(bfd_default_set_arch_mach, (bfd *abfd,
|
||||
enum bfd_architecture arch,
|
||||
unsigned long mach));
|
||||
enum bfd_architecture arch,
|
||||
unsigned long mach));
|
||||
void EXFUN(bfd_arch_init, (void));
|
||||
void EXFUN(bfd_arch_linkin, (bfd_arch_info_type *));
|
||||
CONST bfd_arch_info_type *EXFUN(bfd_default_compatible
|
||||
, (CONST bfd_arch_info_type *a,
|
||||
CONST bfd_arch_info_type *b));
|
||||
, (CONST bfd_arch_info_type *a,
|
||||
CONST bfd_arch_info_type *b));
|
||||
boolean EXFUN(bfd_default_scan, (CONST struct bfd_arch_info *, CONST char *));
|
||||
|
|
124
bfd/oasys.c
124
bfd/oasys.c
|
@ -21,10 +21,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||
/* $Id$ */
|
||||
|
||||
#define UNDERSCORE_HACK 1
|
||||
#include <ansidecl.h>
|
||||
#include <sysdep.h>
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "oasys.h"
|
||||
#include "liboasys.h"
|
||||
|
@ -83,7 +81,7 @@ DEFUN(oasys_slurp_symbol_table,(abfd),
|
|||
bfd * CONST abfd)
|
||||
{
|
||||
oasys_record_union_type record;
|
||||
oasys_data_type *data = oasys_data(abfd);
|
||||
oasys_data_type *data = OASYS_DATA(abfd);
|
||||
boolean loop = true;
|
||||
asymbol *dest_defined;
|
||||
asymbol *dest;
|
||||
|
@ -118,7 +116,7 @@ DEFUN(oasys_slurp_symbol_table,(abfd),
|
|||
case oasys_record_is_local_enum:
|
||||
case oasys_record_is_symbol_enum:
|
||||
{
|
||||
int flag = record.header.type == oasys_record_is_local_enum ?
|
||||
int flag = record.header.type == (int)oasys_record_is_local_enum ?
|
||||
(BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT);
|
||||
|
||||
|
||||
|
@ -126,15 +124,16 @@ DEFUN(oasys_slurp_symbol_table,(abfd),
|
|||
switch (record.symbol.relb & RELOCATION_TYPE_BITS) {
|
||||
case RELOCATION_TYPE_ABS:
|
||||
dest = dest_defined--;
|
||||
dest->section = 0;
|
||||
dest->flags = BSF_ABSOLUTE | flag;
|
||||
dest->section = &bfd_abs_section;
|
||||
dest->flags = 0;
|
||||
|
||||
break;
|
||||
case RELOCATION_TYPE_REL:
|
||||
dest = dest_defined--;
|
||||
dest->section =
|
||||
oasys_data(abfd)->sections[record.symbol.relb &
|
||||
OASYS_DATA(abfd)->sections[record.symbol.relb &
|
||||
RELOCATION_SECT_BITS];
|
||||
if (record.header.type == oasys_record_is_local_enum)
|
||||
if (record.header.type == (int)oasys_record_is_local_enum)
|
||||
{
|
||||
dest->flags = BSF_LOCAL;
|
||||
if (dest->section ==(asection *)(~0)) {
|
||||
|
@ -151,16 +150,15 @@ DEFUN(oasys_slurp_symbol_table,(abfd),
|
|||
break;
|
||||
case RELOCATION_TYPE_UND:
|
||||
dest = data->symbols + bfd_h_get_16(abfd, (bfd_byte *)&record.symbol.refno[0]);
|
||||
dest->section = (asection *)NULL;
|
||||
dest->flags = BSF_UNDEFINED;
|
||||
dest->section = &bfd_und_section;
|
||||
break;
|
||||
case RELOCATION_TYPE_COM:
|
||||
dest = dest_defined--;
|
||||
dest->name = string_ptr;
|
||||
dest->the_bfd = abfd;
|
||||
|
||||
dest->section = (asection *)NULL;
|
||||
dest->flags = BSF_FORT_COMM;
|
||||
dest->section = &bfd_com_section;
|
||||
|
||||
break;
|
||||
default:
|
||||
dest = dest_defined--;
|
||||
|
@ -216,7 +214,7 @@ DEFUN(oasys_get_symtab,(abfd, location),
|
|||
if (oasys_slurp_symbol_table(abfd) == false) {
|
||||
return 0;
|
||||
}
|
||||
symbase = oasys_data(abfd)->symbols;
|
||||
symbase = OASYS_DATA(abfd)->symbols;
|
||||
for (counter = 0; counter < abfd->symcount; counter++) {
|
||||
*(location++) = symbase++;
|
||||
}
|
||||
|
@ -279,7 +277,7 @@ DEFUN(oasys_archive_p,(abfd),
|
|||
oasys_module_table_type record;
|
||||
|
||||
|
||||
set_tdata(abfd, ar);
|
||||
abfd->tdata.oasys_ar_data = ar;
|
||||
ar->module = module;
|
||||
ar->module_count = header.mod_count;
|
||||
|
||||
|
@ -350,8 +348,7 @@ DEFUN(oasys_mkobject,(abfd),
|
|||
bfd *abfd)
|
||||
{
|
||||
|
||||
set_tdata (abfd,
|
||||
(oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type)));
|
||||
abfd->tdata.oasys_obj_data = (oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -361,13 +358,13 @@ DEFUN(oasys_object_p,(abfd),
|
|||
bfd *abfd)
|
||||
{
|
||||
oasys_data_type *oasys;
|
||||
oasys_data_type *save = oasys_data(abfd);
|
||||
oasys_data_type *save = OASYS_DATA(abfd);
|
||||
boolean loop = true;
|
||||
boolean had_usefull = false;
|
||||
|
||||
set_tdata (abfd, 0);
|
||||
abfd->tdata.oasys_obj_data = 0;
|
||||
oasys_mkobject(abfd);
|
||||
oasys = oasys_data(abfd);
|
||||
oasys = OASYS_DATA(abfd);
|
||||
memset((PTR)oasys->sections, 0xff, sizeof(oasys->sections));
|
||||
|
||||
/* Point to the start of the file */
|
||||
|
@ -418,7 +415,7 @@ DEFUN(oasys_object_p,(abfd),
|
|||
BFD_FAIL();
|
||||
}
|
||||
|
||||
s->size = bfd_h_get_32(abfd, (bfd_byte *) & record.section.value[0]) ;
|
||||
s->_raw_size = bfd_h_get_32(abfd, (bfd_byte *) & record.section.value[0]) ;
|
||||
s->vma = bfd_h_get_32(abfd, (bfd_byte *)&record.section.vma[0]);
|
||||
s->flags= 0;
|
||||
had_usefull = true;
|
||||
|
@ -442,8 +439,7 @@ DEFUN(oasys_object_p,(abfd),
|
|||
Oasys support several architectures, but I can't see a simple way
|
||||
to discover which one is in a particular file - we'll guess
|
||||
*/
|
||||
abfd->obj_arch = bfd_arch_m68k;
|
||||
abfd->obj_machine =0;
|
||||
bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0);
|
||||
if (abfd->symcount != 0) {
|
||||
abfd->flags |= HAS_SYMS;
|
||||
}
|
||||
|
@ -459,7 +455,7 @@ DEFUN(oasys_object_p,(abfd),
|
|||
|
||||
fail:
|
||||
(void) bfd_release(abfd, oasys);
|
||||
set_tdata (abfd, save);
|
||||
abfd->tdata.oasys_obj_data = save;
|
||||
return (bfd_target *)NULL;
|
||||
}
|
||||
|
||||
|
@ -469,19 +465,20 @@ DEFUN(oasys_print_symbol,(ignore_abfd, afile, symbol, how),
|
|||
bfd *ignore_abfd AND
|
||||
PTR afile AND
|
||||
asymbol *symbol AND
|
||||
bfd_print_symbol_enum_type how)
|
||||
bfd_print_symbol_type how)
|
||||
{
|
||||
FILE *file = (FILE *)afile;
|
||||
|
||||
switch (how) {
|
||||
case bfd_print_symbol_name_enum:
|
||||
case bfd_print_symbol_type_enum:
|
||||
case bfd_print_symbol_name:
|
||||
case bfd_print_symbol_more:
|
||||
fprintf(file,"%s", symbol->name);
|
||||
break;
|
||||
case bfd_print_symbol_all_enum:
|
||||
case bfd_print_symbol_all:
|
||||
case bfd_print_symbol_nm:
|
||||
{
|
||||
CONST char *section_name = symbol->section == (asection *)NULL ?
|
||||
"*abs" : symbol->section->name;
|
||||
CONST char *section_name = symbol->section == (asection *)NULL ?
|
||||
(CONST char *) "*abs" : symbol->section->name;
|
||||
|
||||
bfd_print_symbol_vandf((PTR)file,symbol);
|
||||
|
||||
|
@ -511,7 +508,7 @@ DEFUN(oasys_slurp_section_data,(abfd),
|
|||
bfd *CONST abfd)
|
||||
{
|
||||
oasys_record_union_type record;
|
||||
oasys_data_type *data = oasys_data(abfd);
|
||||
oasys_data_type *data = OASYS_DATA(abfd);
|
||||
boolean loop = true;
|
||||
|
||||
oasys_per_section_type *per ;
|
||||
|
@ -552,7 +549,7 @@ DEFUN(oasys_slurp_section_data,(abfd),
|
|||
|
||||
if (per->initialized == false)
|
||||
{
|
||||
per->data = (bfd_byte *) bfd_zalloc(abfd, section->size);
|
||||
per->data = (bfd_byte *) bfd_zalloc(abfd, section->_raw_size);
|
||||
per->reloc_tail_ptr = (oasys_reloc_type **)&(section->relocation);
|
||||
per->had_vma = false;
|
||||
per->initialized = true;
|
||||
|
@ -623,9 +620,15 @@ DEFUN(oasys_slurp_section_data,(abfd),
|
|||
/* There is no symbol */
|
||||
r->symbol = 0;
|
||||
/* Work out the howto */
|
||||
abort();
|
||||
#if 0
|
||||
r->relent.section =
|
||||
data->sections[reloc & RELOCATION_SECT_BITS];
|
||||
r->relent.addend = - r->relent.section->vma;
|
||||
data->sections[reloc &
|
||||
RELOCATION_SECT_BITS];
|
||||
|
||||
r->relent.addend = -
|
||||
r->relent.section->vma;
|
||||
#endif
|
||||
r->relent.address = dst_ptr - dst_base_ptr;
|
||||
r->relent.howto = &howto_table[reloc>>6];
|
||||
r->relent.sym_ptr_ptr = (asymbol **)NULL;
|
||||
|
@ -658,7 +661,12 @@ DEFUN(oasys_slurp_section_data,(abfd),
|
|||
/* Get symbol number */
|
||||
r->symbol = (src[0]<<8) | src[1];
|
||||
/* Work out the howto */
|
||||
r->relent.section = (asection *)NULL;
|
||||
abort();
|
||||
|
||||
#if 0
|
||||
r->relent.section = (asection
|
||||
*)NULL;
|
||||
#endif
|
||||
r->relent.addend = 0;
|
||||
r->relent.address = dst_ptr - dst_base_ptr;
|
||||
r->relent.howto = &howto_table[reloc>>6];
|
||||
|
@ -766,10 +774,15 @@ DEFUN(oasys_canonicalize_reloc,(ignore_abfd, section, relptr, symbols),
|
|||
unsigned int reloc_count = 0;
|
||||
oasys_reloc_type *src = (oasys_reloc_type *)(section->relocation);
|
||||
while (src != (oasys_reloc_type *)NULL) {
|
||||
abort();
|
||||
|
||||
#if 0
|
||||
if (src->relent.section == (asection *)NULL)
|
||||
{
|
||||
src->relent.sym_ptr_ptr = symbols + src->symbol;
|
||||
}
|
||||
#endif
|
||||
|
||||
*relptr ++ = &src->relent;
|
||||
src = src->next;
|
||||
reloc_count++;
|
||||
|
@ -779,17 +792,6 @@ DEFUN(oasys_canonicalize_reloc,(ignore_abfd, section, relptr, symbols),
|
|||
}
|
||||
|
||||
|
||||
boolean
|
||||
DEFUN(oasys_set_arch_mach, (abfd, arch, machine),
|
||||
bfd *abfd AND
|
||||
enum bfd_architecture arch AND
|
||||
unsigned long machine)
|
||||
{
|
||||
abfd->obj_arch = arch;
|
||||
abfd->obj_machine = machine;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Writing */
|
||||
|
@ -807,7 +809,7 @@ DEFUN(oasys_write_record,(abfd, type, record, size),
|
|||
size_t i;
|
||||
uint8e_type *ptr;
|
||||
record->header.length = size;
|
||||
record->header.type = type;
|
||||
record->header.type = (int)type;
|
||||
record->header.check_sum = 0;
|
||||
record->header.fill = 0;
|
||||
ptr = &record->pad[0];
|
||||
|
@ -837,17 +839,17 @@ DEFUN(oasys_write_syms, (abfd),
|
|||
char *dst = symbol.name;
|
||||
unsigned int l = 0;
|
||||
|
||||
if (g->flags & BSF_FORT_COMM) {
|
||||
if (g->section == & bfd_com_section) {
|
||||
symbol.relb = RELOCATION_TYPE_COM;
|
||||
bfd_h_put_16(abfd, index, (uint8e_type *)(&symbol.refno[0]));
|
||||
index++;
|
||||
}
|
||||
else if (g->flags & BSF_ABSOLUTE) {
|
||||
else if (g->section == & bfd_abs_section) {
|
||||
symbol.relb = RELOCATION_TYPE_ABS;
|
||||
bfd_h_put_16(abfd, 0, (uint8e_type *)(&symbol.refno[0]));
|
||||
|
||||
}
|
||||
else if (g->flags & BSF_UNDEFINED) {
|
||||
else if (g->section == &bfd_und_section) {
|
||||
symbol.relb = RELOCATION_TYPE_UND ;
|
||||
bfd_h_put_16(abfd, index, (uint8e_type *)(&symbol.refno[0]));
|
||||
/* Overload the value field with the output index number */
|
||||
|
@ -909,7 +911,7 @@ DEFUN(oasys_write_sections, (abfd),
|
|||
s->name);
|
||||
}
|
||||
out.relb = RELOCATION_TYPE_REL | s->target_index;
|
||||
bfd_h_put_32(abfd, s->size, (bfd_byte *) out.value);
|
||||
bfd_h_put_32(abfd, s->_cooked_size, (bfd_byte *) out.value);
|
||||
bfd_h_put_32(abfd, s->vma, (bfd_byte *) out.vma);
|
||||
|
||||
oasys_write_record(abfd,
|
||||
|
@ -1003,7 +1005,7 @@ DEFUN(oasys_write_data, (abfd),
|
|||
current_byte_index = 0;
|
||||
processed_data.relb = s->target_index | RELOCATION_TYPE_REL;
|
||||
|
||||
while (current_byte_index < s->size)
|
||||
while (current_byte_index < s->_cooked_size)
|
||||
{
|
||||
/* Scan forwards by eight bytes or however much is left and see if
|
||||
there are any relocations going on */
|
||||
|
@ -1015,8 +1017,8 @@ DEFUN(oasys_write_data, (abfd),
|
|||
|
||||
|
||||
bfd_h_put_32(abfd, s->vma + current_byte_index, processed_data.addr);
|
||||
if ((size_t)(long_length + current_byte_index) > (size_t)(s->size)) {
|
||||
long_length = s->size - current_byte_index;
|
||||
if ((size_t)(long_length + current_byte_index) > (size_t)(s->_cooked_size)) {
|
||||
long_length = s->_cooked_size - current_byte_index;
|
||||
}
|
||||
while (long_length > 0 && (dst - (uint8e_type*)&processed_data < 128)) {
|
||||
|
||||
|
@ -1062,6 +1064,9 @@ DEFUN(oasys_write_data, (abfd),
|
|||
|
||||
/* Is this a section relative relocation, or a symbol
|
||||
relative relocation ? */
|
||||
abort();
|
||||
|
||||
#if 0
|
||||
if (r->section != (asection*)NULL)
|
||||
{
|
||||
/* The relent has a section attached, so it must be section
|
||||
|
@ -1071,6 +1076,7 @@ DEFUN(oasys_write_data, (abfd),
|
|||
*dst++ = rel_byte;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
asymbol *p = *(r->sym_ptr_ptr);
|
||||
|
||||
|
@ -1155,7 +1161,7 @@ DEFUN(oasys_set_section_contents,(abfd, section, location, offset, count),
|
|||
if (oasys_per_section(section)->data == (bfd_byte *)NULL )
|
||||
{
|
||||
oasys_per_section(section)->data =
|
||||
(bfd_byte *)(bfd_alloc(abfd,section->size));
|
||||
(bfd_byte *)(bfd_alloc(abfd,section->_cooked_size));
|
||||
}
|
||||
(void) memcpy((PTR)(oasys_per_section(section)->data + offset),
|
||||
location,
|
||||
|
@ -1195,7 +1201,7 @@ oasys_openr_next_archived_file(arch, prev)
|
|||
bfd *arch;
|
||||
bfd *prev;
|
||||
{
|
||||
oasys_ar_data_type *ar = oasys_ar_data(arch);
|
||||
oasys_ar_data_type *ar = OASYS_AR_DATA(arch);
|
||||
oasys_module_info_type *p;
|
||||
/* take the next one from the arch state, or reset */
|
||||
if (prev == (bfd *)NULL) {
|
||||
|
@ -1277,17 +1283,17 @@ return 0;
|
|||
#define oasys_write_armap 0
|
||||
#define oasys_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
|
||||
#define oasys_close_and_cleanup bfd_generic_close_and_cleanup
|
||||
|
||||
#define oasys_set_arch_mach bfd_default_set_arch_mach
|
||||
#define oasys_bfd_debug_info_start bfd_void
|
||||
#define oasys_bfd_debug_info_end bfd_void
|
||||
#define oasys_bfd_debug_info_accumulate (FOO(void, (*), (bfd *, asection *)))bfd_void
|
||||
|
||||
#define oasys_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
|
||||
|
||||
/*SUPPRESS 460 */
|
||||
bfd_target oasys_vec =
|
||||
{
|
||||
"oasys", /* name */
|
||||
bfd_target_oasys_flavour_enum,
|
||||
bfd_target_oasys_flavour,
|
||||
true, /* target byte order */
|
||||
true, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
|
|
887
bfd/reloc.c
887
bfd/reloc.c
File diff suppressed because it is too large
Load diff
370
bfd/seclet.c
Normal file
370
bfd/seclet.c
Normal file
|
@ -0,0 +1,370 @@
|
|||
/* This module is part of BFD */
|
||||
|
||||
|
||||
/* The intention is that one day, all the code which uses sections
|
||||
will change and use seclets instead - maybe seglet would have been
|
||||
a better name..
|
||||
|
||||
Anyway, a seclet contains enough info to be able to describe an
|
||||
area of output memory in one go.
|
||||
|
||||
The only description so far catered for is that of the
|
||||
<<bfd_indirect_seclet>>, which is a select which points to a
|
||||
<<section>> and the <<asymbols>> associated with the section, so
|
||||
that relocation can be done when needed.
|
||||
|
||||
One day there will be more types - they will at least migrate from
|
||||
the linker's data structures - also there could be extra stuff,
|
||||
like a bss seclet, which descibes a lump of memory as containing
|
||||
zeros compactly, without the horrible SEC_* flag cruft.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "seclet.h"
|
||||
#include "coff/internal.h"
|
||||
bfd_seclet_type *
|
||||
DEFUN(bfd_new_seclet,(abfd, section),
|
||||
bfd *abfd AND
|
||||
asection *section)
|
||||
{
|
||||
bfd_seclet_type *n = (bfd_seclet_type *)bfd_alloc(abfd, sizeof(bfd_seclet_type));
|
||||
if (section->seclets_tail != (bfd_seclet_type *)NULL) {
|
||||
section->seclets_tail->next = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
section->seclets_head = n;
|
||||
}
|
||||
section->seclets_tail = n;
|
||||
|
||||
return n;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define MAX_ERRORS_IN_A_ROW 10
|
||||
extern bfd_error_vector_type bfd_error_vector;
|
||||
bfd_vma
|
||||
DEFUN(get_value,(reloc, seclet),
|
||||
arelent *reloc AND
|
||||
bfd_seclet_type *seclet)
|
||||
{
|
||||
bfd_vma value;
|
||||
if (reloc->sym_ptr_ptr)
|
||||
{
|
||||
asymbol *symbol = *(reloc->sym_ptr_ptr);
|
||||
|
||||
|
||||
/* A symbol holds a pointer to a section, and an offset from the
|
||||
base of the section. To relocate, we find where the section will
|
||||
live in the output and add that in */
|
||||
|
||||
if (symbol->section == (asection *)NULL)
|
||||
{
|
||||
/* Ouch, this is an undefined symbol.. */
|
||||
bfd_error_vector.undefined_symbol(reloc, seclet);
|
||||
value = symbol->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = symbol->value +
|
||||
symbol->section->output_offset +
|
||||
symbol->section->output_section->vma;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
/* Add the value contained in the relocation */
|
||||
value += (short)((reloc->addend) & 0xffff);
|
||||
|
||||
return value;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static char *
|
||||
DEFUN(foo_bfd_get_relocated_section_contents,(seclet),
|
||||
bfd_seclet_type *seclet)
|
||||
|
||||
{
|
||||
asymbol **symbols = 0;
|
||||
extern bfd *output_bfd;
|
||||
bfd *abfd;
|
||||
|
||||
/* Get enough memory to hold the stuff */
|
||||
bfd *input_bfd = seclet->u.indirect.section->owner;
|
||||
asection *input_section = seclet->u.indirect.section;
|
||||
|
||||
char *data = malloc(input_section->_raw_size);
|
||||
char *dst = data;
|
||||
char *prev_dst = data;
|
||||
unsigned int gap = 0;
|
||||
|
||||
bfd_size_type reloc_size = bfd_get_reloc_upper_bound(input_bfd,
|
||||
input_section);
|
||||
arelent **reloc_vector = (arelent **)ldmalloc(reloc_size);
|
||||
abfd = output_bfd;
|
||||
|
||||
/* read in the section */
|
||||
bfd_get_section_contents(input_bfd,
|
||||
input_section,
|
||||
data,
|
||||
0,
|
||||
input_section->_raw_size);
|
||||
|
||||
|
||||
if (bfd_canonicalize_reloc(input_bfd,
|
||||
input_section,
|
||||
reloc_vector,
|
||||
seclet->u.indirect.symbols) )
|
||||
{
|
||||
arelent **parent = reloc_vector;
|
||||
arelent *reloc ;
|
||||
|
||||
|
||||
|
||||
unsigned int dst_address = 0;
|
||||
unsigned int src_address = 0;
|
||||
unsigned int run;
|
||||
unsigned int idx;
|
||||
|
||||
/* Find how long a run we can do */
|
||||
while (dst_address < seclet->size)
|
||||
{
|
||||
|
||||
reloc = *parent;
|
||||
if (reloc)
|
||||
{
|
||||
/* Note that the relaxing didn't tie up the addresses in the
|
||||
relocation, so we use the original address to work out the
|
||||
run of non-relocated data */
|
||||
run = reloc->address - src_address;
|
||||
parent++;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
run = seclet->size - dst_address;
|
||||
}
|
||||
/* Copy the bytes */
|
||||
for (idx = 0; idx < run; idx++)
|
||||
{
|
||||
data[dst_address++] = data[src_address++];
|
||||
}
|
||||
|
||||
/* Now do the relocation */
|
||||
|
||||
if (reloc)
|
||||
{
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_JMP2:
|
||||
/* Speciial relaxed type */
|
||||
{
|
||||
bfd_vma dot = seclet->offset + dst_address + seclet->u.indirect.section->output_section->vma;
|
||||
int gap = get_value(reloc,seclet)-dot-1;
|
||||
if ((gap & ~0xff ) != 0 &&((gap & 0xff00)!= 0xff00)) abort();
|
||||
|
||||
bfd_put_8(abfd,gap, data+dst_address);
|
||||
|
||||
switch (data[dst_address-1])
|
||||
{
|
||||
|
||||
case 0x5e:
|
||||
/* jsr -> bsr */
|
||||
bfd_put_8(abfd, 0x55, data+dst_address-1);
|
||||
break;
|
||||
case 0x5a:
|
||||
/* jmp ->bra */
|
||||
bfd_put_8(abfd, 0x40, data+dst_address-1);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
dst_address++;
|
||||
src_address+=3;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case R_MOVB2:
|
||||
/* Special relaxed type, there will be a gap between where we
|
||||
get stuff from and where we put stuff to now
|
||||
|
||||
for a mov.b @aa:16 -> mov.b @aa:8
|
||||
opcode 0x6a 0x0y offset
|
||||
-> 0x2y off
|
||||
*/
|
||||
if (data[dst_address-1] != 0x6a)
|
||||
abort();
|
||||
switch (data[dst_address] & 0xf0)
|
||||
{
|
||||
case 0x00:
|
||||
/* Src is memory */
|
||||
data[dst_address-1] = (data[src_address] & 0xf) | 0x20;
|
||||
break;
|
||||
case 0x80:
|
||||
/* Src is reg */
|
||||
data[dst_address-1] = (data[src_address] & 0xf) | 0x30;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
/* the offset must fit ! after all, what was all the relaxing
|
||||
about ? */
|
||||
|
||||
bfd_put_8(abfd, get_value(reloc, seclet), data + dst_address);
|
||||
|
||||
/* Note the magic - src goes up by two bytes, but dst by only
|
||||
one */
|
||||
dst_address+=1;
|
||||
src_address+=3;
|
||||
|
||||
break;
|
||||
/* PCrel 8 bits */
|
||||
case R_PCRBYTE:
|
||||
{
|
||||
bfd_vma dot = seclet->offset + dst_address + seclet->u.indirect.section->output_section->vma;
|
||||
int gap = get_value(reloc,seclet)-dot;
|
||||
if (gap > 127 || gap < -128)
|
||||
{
|
||||
bfd_error_vector.reloc_value_truncated(reloc, seclet);
|
||||
}
|
||||
|
||||
bfd_put_8(abfd,gap, data+dst_address);
|
||||
dst_address++;
|
||||
src_address++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case R_RELBYTE:
|
||||
{
|
||||
unsigned int gap =get_value(reloc,seclet);
|
||||
if (gap > 256)
|
||||
{
|
||||
bfd_error_vector.reloc_value_truncated(reloc, seclet);
|
||||
}
|
||||
|
||||
bfd_put_8(abfd, gap, data+dst_address);
|
||||
dst_address+=1;
|
||||
src_address+=1;
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case R_JMP1:
|
||||
/* A relword which would have like to have been a pcrel */
|
||||
case R_MOVB1:
|
||||
/* A relword which would like to have been modified but
|
||||
didn't make it */
|
||||
case R_RELWORD:
|
||||
bfd_put_16(abfd, get_value(reloc,seclet), data+dst_address);
|
||||
dst_address+=2;
|
||||
src_address+=2;
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free((char *)reloc_vector);
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DEFUN(rel,(abfd, seclet, output_section),
|
||||
bfd *abfd AND
|
||||
bfd_seclet_type *seclet AND
|
||||
asection *output_section)
|
||||
{
|
||||
bfd_byte *data;
|
||||
if (output_section->flags & SEC_HAS_CONTENTS )
|
||||
{
|
||||
|
||||
data = bfd_get_relocated_section_contents(abfd, seclet);
|
||||
|
||||
if(bfd_set_section_contents(abfd,
|
||||
output_section,
|
||||
data,
|
||||
seclet->offset,
|
||||
seclet->size) == false)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DEFUN(seclet_dump_seclet,(abfd, seclet, section),
|
||||
bfd *abfd AND
|
||||
bfd_seclet_type *seclet AND
|
||||
asection *section)
|
||||
{
|
||||
switch (seclet->type)
|
||||
{
|
||||
|
||||
case bfd_indirect_seclet:
|
||||
/* The contents of this section come from another one somewhere
|
||||
else */
|
||||
rel(abfd, seclet, section);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DEFUN(seclet_dump,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
/* Write all the seclets on the bfd out, relocate etc according to the
|
||||
rules */
|
||||
|
||||
asection *o = abfd->sections;
|
||||
while (o != (asection *)NULL)
|
||||
{
|
||||
bfd_seclet_type *p = o->seclets_head;
|
||||
while (p != (bfd_seclet_type *)NULL)
|
||||
{
|
||||
seclet_dump_seclet(abfd, p, o);
|
||||
p = p ->next;
|
||||
}
|
||||
|
||||
o = o->next;
|
||||
}
|
||||
|
||||
}
|
29
bfd/seclet.h
Normal file
29
bfd/seclet.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
typedef enum
|
||||
{
|
||||
|
||||
bfd_indirect_seclet,
|
||||
|
||||
} bfd_seclet_enum_type;
|
||||
|
||||
|
||||
struct bfd_seclet_struct
|
||||
{
|
||||
struct bfd_seclet_struct *next;
|
||||
bfd_seclet_enum_type type;
|
||||
unsigned int offset;
|
||||
unsigned int size;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
asection *section;
|
||||
asymbol **symbols;
|
||||
|
||||
} indirect;
|
||||
}
|
||||
u;
|
||||
};
|
||||
|
||||
typedef struct bfd_seclet_struct bfd_seclet_type;
|
||||
|
||||
bfd_seclet_type *EXFUN(bfd_new_seclet,(bfd*,asection*));
|
167
bfd/section.c
167
bfd/section.c
|
@ -36,9 +36,7 @@ SECTION
|
|||
* section prototypes::
|
||||
@end menu
|
||||
|
||||
INODE
|
||||
Section Input, Section Output, Sections, Sections
|
||||
|
||||
@node Section Input, Section Output, Sections, Sections
|
||||
SUBSECTION
|
||||
Section Input
|
||||
|
||||
|
@ -67,8 +65,7 @@ SUBSECTION
|
|||
the data area has to be parsed to get out the data and
|
||||
relocations.
|
||||
|
||||
INODE
|
||||
Section Output, typedef asection, Section Input, Sections
|
||||
@node Section Output, typedef asection, Section Input, Sections
|
||||
|
||||
SUBSECTION
|
||||
Section Output
|
||||
|
@ -104,6 +101,25 @@ SUBSECTION
|
|||
| output_section --------|
|
||||
|
||||
|
||||
SUBSECTION
|
||||
Seglets
|
||||
|
||||
The data within a section is stored in a <<seglet>>. These
|
||||
are much like the fixups in <<gas>>. The seglet abstraction
|
||||
allows the a section to grow and shrink within itself.
|
||||
|
||||
A seglet knows how big it is, and which is the next seglet and
|
||||
where the raw data for it is, and also points to a list of
|
||||
relocations which apply to it.
|
||||
|
||||
The seglet is used by the linker to perform relaxing on final
|
||||
code. The application creates code which is as big as
|
||||
necessary to make it work without relaxing, and the user can
|
||||
select whether to relax. Sometimes relaxing takes a lot of
|
||||
time. The linker runs around the relocations to see if any
|
||||
are attached to data which can be shrunk, if so it does it on
|
||||
a seglet by seglet basis.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
@ -111,12 +127,9 @@ SUBSECTION
|
|||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/*
|
||||
INODE
|
||||
typedef asection, section prototypes, Section Output, Sections
|
||||
SUBSECTION
|
||||
typedef asection
|
||||
|
||||
/*doc*
|
||||
@node typedef asection, section prototypes, Section Output, Sections
|
||||
SUBSECTION
|
||||
typedef asection
|
||||
|
||||
|
@ -131,6 +144,11 @@ CODE_FRAGMENT
|
|||
.
|
||||
. CONST char *name;
|
||||
.
|
||||
.
|
||||
. {* Which section is it 0.nth *}
|
||||
.
|
||||
. int index;
|
||||
.
|
||||
. {* The next section in the list belonging to the BFD, or NULL. *}
|
||||
.
|
||||
. struct sec *next;
|
||||
|
@ -214,16 +232,21 @@ CODE_FRAGMENT
|
|||
.
|
||||
.#define SEC_NEVER_LOAD 0x400
|
||||
.
|
||||
. {* The base address of the section in the address space of the
|
||||
. target. *}
|
||||
.
|
||||
.
|
||||
. bfd_vma vma;
|
||||
.
|
||||
. {* The size of the section in bytes of the loaded section. This
|
||||
. {* The size of the section in bytes, as it will be output.
|
||||
. contains a value even if the section has no contents (eg, the
|
||||
. size of <<.bss>>). *}
|
||||
. size of <<.bss>>). This will be filled in after relocation *}
|
||||
.
|
||||
. bfd_size_type size;
|
||||
. bfd_size_type _cooked_size;
|
||||
.
|
||||
. {* The size on disk of the section in bytes originally. Normally this
|
||||
. value is the same as the size, but if some relaxing has
|
||||
. been done, then this value will be bigger. *}
|
||||
.
|
||||
. bfd_size_type _raw_size;
|
||||
.
|
||||
. {* If this section is going to be output, then this value is the
|
||||
. offset into the output section of the first byte in the input
|
||||
|
@ -255,10 +278,6 @@ CODE_FRAGMENT
|
|||
.
|
||||
. unsigned reloc_count;
|
||||
.
|
||||
. {* Which section is it 0.nth *}
|
||||
.
|
||||
. int index;
|
||||
.
|
||||
. {* Information below is back end specific - and not always used
|
||||
. or updated
|
||||
.
|
||||
|
@ -295,7 +314,7 @@ CODE_FRAGMENT
|
|||
.
|
||||
. {* what the section number is in the target world *}
|
||||
.
|
||||
. unsigned int target_index;
|
||||
. int target_index;
|
||||
.
|
||||
. PTR used_by_bfd;
|
||||
.
|
||||
|
@ -308,13 +327,47 @@ CODE_FRAGMENT
|
|||
.
|
||||
. bfd *owner;
|
||||
.
|
||||
. boolean reloc_done;
|
||||
. {* A symbol which points at this section only *}
|
||||
. struct symbol_cache_entry *symbol;
|
||||
. struct symbol_cache_entry **symbol_ptr_ptr;
|
||||
. struct bfd_seclet_struct *seclets_head;
|
||||
. struct bfd_seclet_struct *seclets_tail;
|
||||
.} asection ;
|
||||
.
|
||||
.
|
||||
.#define BFD_ABS_SECTION_NAME "*ABS*"
|
||||
.#define BFD_UND_SECTION_NAME "*UND*"
|
||||
.#define BFD_COM_SECTION_NAME "*COM*"
|
||||
.
|
||||
. {* the absolute section *}
|
||||
. extern asection bfd_abs_section;
|
||||
. {* Pointer to the undefined section *}
|
||||
. extern asection bfd_und_section;
|
||||
. {* Pointer to the common section *}
|
||||
. extern asection bfd_com_section;
|
||||
.
|
||||
. extern struct symbol_cache_entry *bfd_abs_symbol;
|
||||
. extern struct symbol_cache_entry *bfd_com_symbol;
|
||||
. extern struct symbol_cache_entry *bfd_und_symbol;
|
||||
.#define bfd_get_section_size_before_reloc(section) \
|
||||
. (section->reloc_done ? (abort(),1): (section)->_raw_size)
|
||||
.#define bfd_get_section_size_after_reloc(section) \
|
||||
. ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
|
||||
*/
|
||||
|
||||
/*
|
||||
INODE
|
||||
section prototypes, , typedef asection, Sections
|
||||
|
||||
|
||||
asection bfd_com_section = { BFD_COM_SECTION_NAME ,0 };
|
||||
asection bfd_und_section = { BFD_UND_SECTION_NAME ,0 };
|
||||
asection bfd_abs_section = { BFD_ABS_SECTION_NAME ,0 };
|
||||
|
||||
struct symbol_cache_entry *bfd_abs_symbol;
|
||||
struct symbol_cache_entry *bfd_com_symbol;
|
||||
struct symbol_cache_entry *bfd_und_symbol;
|
||||
|
||||
/*
|
||||
@node section prototypes, , typedef asection, Sections
|
||||
SUBSECTION
|
||||
section prototypes
|
||||
|
||||
|
@ -424,6 +477,19 @@ DEFUN(bfd_make_section,(abfd, name),
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp(name, BFD_ABS_SECTION_NAME) == 0)
|
||||
{
|
||||
return &bfd_abs_section;
|
||||
}
|
||||
if (strcmp(name, BFD_COM_SECTION_NAME) == 0)
|
||||
{
|
||||
return &bfd_com_section;
|
||||
}
|
||||
if (strcmp(name, BFD_UND_SECTION_NAME) == 0)
|
||||
{
|
||||
return &bfd_und_section;
|
||||
}
|
||||
|
||||
while (sect) {
|
||||
if (!strcmp(sect->name, name)) return NULL;
|
||||
prev = §->next;
|
||||
|
@ -446,6 +512,20 @@ DEFUN(bfd_make_section,(abfd, name),
|
|||
newsect->reloc_count = 0;
|
||||
newsect->line_filepos =0;
|
||||
newsect->owner = abfd;
|
||||
|
||||
/* Create a symbol whos only job is to point to this section. This is
|
||||
usfull for things like relocs which are relative to the base of a
|
||||
section
|
||||
*/
|
||||
newsect->symbol = bfd_make_empty_symbol(abfd);
|
||||
newsect->symbol->name = name;
|
||||
newsect->symbol->value = 0;
|
||||
newsect->symbol->section = newsect;
|
||||
newsect->symbol->flags = BSF_SECTION_SYM;
|
||||
|
||||
|
||||
newsect->symbol_ptr_ptr = &newsect->symbol;
|
||||
|
||||
if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true) {
|
||||
free (newsect);
|
||||
return NULL;
|
||||
|
@ -564,7 +644,8 @@ DEFUN(bfd_set_section_size,(abfd, ptr, val),
|
|||
return false;
|
||||
}
|
||||
|
||||
ptr->size = val;
|
||||
ptr->_cooked_size = val;
|
||||
ptr->_raw_size = val;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -588,6 +669,8 @@ DESCRIPTION
|
|||
data is written to the output section starting at offset
|
||||
@var{offset} for @var{count} bytes.
|
||||
|
||||
|
||||
|
||||
Normally <<true>> is returned, else <<false>>. Possible error
|
||||
returns are:
|
||||
o no_contents
|
||||
|
@ -668,3 +751,39 @@ DEFUN(bfd_get_section_contents,(abfd, section, location, offset, count),
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the internal data structures */
|
||||
DEFUN_VOID(bfd_section_init)
|
||||
{
|
||||
|
||||
bfd_com_symbol = (asymbol *)zalloc(sizeof(asymbol));
|
||||
bfd_com_symbol->name = BFD_COM_SECTION_NAME;
|
||||
bfd_com_symbol->flags = BSF_SECTION_SYM;
|
||||
bfd_com_symbol->section = &bfd_com_section;
|
||||
bfd_com_section.symbol = bfd_com_symbol;
|
||||
bfd_com_section.symbol_ptr_ptr = &bfd_com_symbol;
|
||||
bfd_com_section.output_section = &bfd_com_section;
|
||||
|
||||
|
||||
|
||||
bfd_und_symbol = (asymbol *)zalloc(sizeof(asymbol));
|
||||
bfd_und_symbol->name = BFD_UND_SECTION_NAME;
|
||||
bfd_und_symbol->flags = BSF_SECTION_SYM;
|
||||
bfd_und_symbol->section = &bfd_und_section;
|
||||
bfd_und_section.symbol = bfd_und_symbol;
|
||||
bfd_und_section.symbol_ptr_ptr = &bfd_und_symbol;
|
||||
bfd_und_section.output_section = &bfd_und_section;
|
||||
|
||||
bfd_abs_symbol = (asymbol *)zalloc(sizeof(asymbol));
|
||||
bfd_abs_symbol->name = BFD_ABS_SECTION_NAME;
|
||||
bfd_abs_symbol->flags = BSF_SECTION_SYM;
|
||||
bfd_abs_symbol->section = &bfd_abs_section;
|
||||
bfd_abs_section.symbol = bfd_abs_symbol;
|
||||
bfd_abs_section.symbol_ptr_ptr = &bfd_abs_symbol;
|
||||
bfd_abs_section.output_section = &bfd_abs_section;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
27
bfd/srec.c
27
bfd/srec.c
|
@ -93,7 +93,7 @@ d[0] = digs[((x)>>4)&0xf]; ch += (x & 0xff);
|
|||
|
||||
|
||||
|
||||
static
|
||||
static void
|
||||
DEFUN_VOID(srec_init)
|
||||
{
|
||||
unsigned int i;
|
||||
|
@ -142,7 +142,7 @@ struct srec_data_list_struct
|
|||
typedef struct srec_data_list_struct srec_data_list_type;
|
||||
|
||||
|
||||
typedef struct
|
||||
typedef struct srec_data_struct
|
||||
{
|
||||
srec_data_list_type *head;
|
||||
unsigned int type;
|
||||
|
@ -208,7 +208,7 @@ DEFUN(pass_over,(abfd, func, section),
|
|||
{
|
||||
unsigned int bytes_on_line;
|
||||
boolean eof = false;
|
||||
bfd_vma address;
|
||||
|
||||
/* To the front of the file */
|
||||
bfd_seek(abfd, (file_ptr)0, SEEK_SET);
|
||||
while (eof == false)
|
||||
|
@ -291,12 +291,12 @@ DEFUN(srec_object_p, (abfd),
|
|||
and allocate enough room for the entire file. */
|
||||
|
||||
section = bfd_make_section(abfd, ".text");
|
||||
section->size = 0;
|
||||
section->_raw_size = 0;
|
||||
section->vma = 0xffffffff;
|
||||
low = 0xffffffff;
|
||||
high = 0;
|
||||
pass_over(abfd, size_srec, section);
|
||||
section->size = high - low;
|
||||
section->_raw_size = high - low;
|
||||
section->vma = low;
|
||||
section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
|
||||
|
||||
|
@ -314,7 +314,7 @@ DEFUN(srec_get_section_contents,(abfd, section, location, offset, count),
|
|||
{
|
||||
if (section->used_by_bfd == (PTR)NULL)
|
||||
{
|
||||
section->used_by_bfd = (PTR)bfd_alloc (abfd, section->size);
|
||||
section->used_by_bfd = (PTR)bfd_alloc (abfd, section->_raw_size);
|
||||
pass_over(abfd, fillup, section);
|
||||
}
|
||||
(void) memcpy((PTR)location,
|
||||
|
@ -346,7 +346,7 @@ DEFUN(srec_set_section_contents,(abfd, section, location, offset, bytes_to_do),
|
|||
file_ptr offset AND
|
||||
bfd_size_type bytes_to_do)
|
||||
{
|
||||
tdata_type *tdata = (tdata_type *)(abfd->tdata);
|
||||
tdata_type *tdata = abfd->tdata.srec_data;
|
||||
srec_data_list_type *entry = (srec_data_list_type *)
|
||||
bfd_alloc(abfd, sizeof(srec_data_list_type));
|
||||
unsigned char *data = (unsigned char *) bfd_alloc(abfd, bytes_to_do);
|
||||
|
@ -371,7 +371,7 @@ DEFUN(srec_set_section_contents,(abfd, section, location, offset, bytes_to_do),
|
|||
entry->size = bytes_to_do;
|
||||
entry->next = tdata->head;
|
||||
tdata->head = entry;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Write a record of type, of the supplied number of bytes. The
|
||||
|
@ -471,7 +471,6 @@ DEFUN(srec_write_section,(abfd, tdata, list),
|
|||
char buffer[MAXCHUNK];
|
||||
char *dst = buffer;
|
||||
bfd_vma address;
|
||||
unsigned int i;
|
||||
|
||||
unsigned int bytes_this_chunk = list->size - bytes_written;
|
||||
|
||||
|
@ -511,7 +510,7 @@ DEFUN(srec_mkobject, (abfd),
|
|||
bfd *abfd)
|
||||
{
|
||||
tdata_type *tdata = (tdata_type *)bfd_alloc(abfd, sizeof(tdata_type));
|
||||
abfd->tdata = (PTR)tdata;
|
||||
abfd->tdata.srec_data = tdata;
|
||||
tdata->type = 1;
|
||||
tdata->head = (srec_data_list_type *)NULL;
|
||||
return true;
|
||||
|
@ -523,12 +522,8 @@ static boolean
|
|||
DEFUN(srec_write_object_contents,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
bfd_vma address;
|
||||
int bytes_written;
|
||||
|
||||
int type;
|
||||
unsigned int i;
|
||||
tdata_type *tdata = (tdata_type *)(abfd->tdata);
|
||||
tdata_type *tdata = abfd->tdata.srec_data;
|
||||
srec_data_list_type *list;
|
||||
|
||||
bytes_written = 0;
|
||||
|
@ -591,7 +586,7 @@ DEFUN(srec_make_empty_symbol, (abfd),
|
|||
#define srec_bfd_debug_info_start bfd_void
|
||||
#define srec_bfd_debug_info_end bfd_void
|
||||
#define srec_bfd_debug_info_accumulate (FOO(void, (*), (bfd *, asection *))) bfd_void
|
||||
|
||||
#define srec_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
|
||||
|
||||
bfd_target srec_vec =
|
||||
{
|
||||
|
|
311
bfd/syms.c
311
bfd/syms.c
|
@ -22,11 +22,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||
SECTION
|
||||
Symbols
|
||||
|
||||
DESCRIPTION
|
||||
BFD trys to maintain as much symbol information as it can when
|
||||
it moves information from file to file. BFD passes information
|
||||
to applications though the <<asymbol>> structure. When the
|
||||
applicationrequests the symbol table, BFD reads the table in
|
||||
application requests the symbol table, BFD reads the table in
|
||||
the native form and translates parts of it into the internal
|
||||
format. To maintain more than the infomation passed to
|
||||
applications some targets keep some information 'behind the
|
||||
|
@ -38,7 +37,7 @@ DESCRIPTION
|
|||
information unique to coff which BFD doesn't know or
|
||||
understand. If a coff symbol table was read, but was written
|
||||
through an a.out back end, all the coff specific information
|
||||
would be lost. (.. until BFD 2 :). The symbol table of a BFD
|
||||
would be lost. The symbol table of a BFD
|
||||
is not necessarily read in until a canonicalize request is
|
||||
made. Then the BFD back end fills in a table provided by the
|
||||
application with pointers to the canonical information. To
|
||||
|
@ -57,33 +56,28 @@ DESCRIPTION
|
|||
SUBSECTION
|
||||
Reading Symbols
|
||||
|
||||
DESCRIPTION
|
||||
There are two stages to reading a symbol table from a BFD;
|
||||
allocating storage, and the actual reading process. This is an
|
||||
excerpt from an appliction which reads the symbol table:
|
||||
|
||||
EXAMPLE
|
||||
|
||||
unsigned int storage_needed;
|
||||
asymbol **symbol_table;
|
||||
unsigned int number_of_symbols;
|
||||
unsigned int i;
|
||||
|
||||
storage_needed = get_symtab_upper_bound (abfd);
|
||||
|
||||
if (storage_needed == 0) {
|
||||
return ;
|
||||
}
|
||||
symbol_table = (asymbol **) bfd_xmalloc (storage_needed);
|
||||
...
|
||||
number_of_symbols =
|
||||
bfd_canonicalize_symtab (abfd, symbol_table);
|
||||
|
||||
for (i = 0; i < number_of_symbols; i++) {
|
||||
process_symbol (symbol_table[i]);
|
||||
}
|
||||
|
||||
DESCRIPTION
|
||||
| unsigned int storage_needed;
|
||||
| asymbol **symbol_table;
|
||||
| unsigned int number_of_symbols;
|
||||
| unsigned int i;
|
||||
|
|
||||
| storage_needed = get_symtab_upper_bound (abfd);
|
||||
|
|
||||
| if (storage_needed == 0) {
|
||||
| return ;
|
||||
| }
|
||||
| symbol_table = (asymbol **) bfd_xmalloc (storage_needed);
|
||||
| ...
|
||||
| number_of_symbols =
|
||||
| bfd_canonicalize_symtab (abfd, symbol_table);
|
||||
|
|
||||
| for (i = 0; i < number_of_symbols; i++) {
|
||||
| process_symbol (symbol_table[i]);
|
||||
| }
|
||||
|
||||
All storage for the symbols themselves is in an obstack
|
||||
connected to the BFD, and is freed when the BFD is closed.
|
||||
|
@ -93,7 +87,6 @@ DESCRIPTION
|
|||
SUBSECTION
|
||||
Writing Symbols
|
||||
|
||||
DESCRIPTION
|
||||
Writing of a symbol table is automatic when a BFD open for
|
||||
writing is closed. The application attaches a vector of
|
||||
pointers to pointers to symbols to the BFD being written, and
|
||||
|
@ -104,35 +97,32 @@ DESCRIPTION
|
|||
which has been created using <<bfd_make_empty_symbol>>. An
|
||||
example showing the creation of a symbol table with only one element:
|
||||
|
||||
EXAMPLE
|
||||
#include "bfd.h"
|
||||
main()
|
||||
{
|
||||
bfd *abfd;
|
||||
asymbol *ptrs[2];
|
||||
asymbol *new;
|
||||
| #include "bfd.h"
|
||||
| main()
|
||||
| {
|
||||
| bfd *abfd;
|
||||
| asymbol *ptrs[2];
|
||||
| asymbol *new;
|
||||
|
|
||||
| abfd = bfd_openw("foo","a.out-sunos-big");
|
||||
| bfd_set_format(abfd, bfd_object);
|
||||
| new = bfd_make_empty_symbol(abfd);
|
||||
| new->name = "dummy_symbol";
|
||||
| new->section = bfd_make_section_old_way(abfd, ".text");
|
||||
| new->flags = BSF_GLOBAL;
|
||||
| new->value = 0x12345;
|
||||
|
|
||||
| ptrs[0] = new;
|
||||
| ptrs[1] = (asymbol *)0;
|
||||
|
|
||||
| bfd_set_symtab(abfd, ptrs, 1);
|
||||
| bfd_close(abfd);
|
||||
| }
|
||||
|
|
||||
| ./makesym
|
||||
| nm foo
|
||||
| 00012345 A dummy_symbol
|
||||
|
||||
abfd = bfd_openw("foo","a.out-sunos-big");
|
||||
bfd_set_format(abfd, bfd_object);
|
||||
new = bfd_make_empty_symbol(abfd);
|
||||
new->name = "dummy_symbol";
|
||||
new->section = (asection *)0;
|
||||
new->flags = BSF_ABSOLUTE | BSF_GLOBAL;
|
||||
new->value = 0x12345;
|
||||
|
||||
ptrs[0] = new;
|
||||
ptrs[1] = (asymbol *)0;
|
||||
|
||||
bfd_set_symtab(abfd, ptrs, 1);
|
||||
bfd_close(abfd);
|
||||
}
|
||||
|
||||
./makesym
|
||||
nm foo
|
||||
00012345 A dummy_symbol
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
Many formats cannot represent arbitary symbol information; for
|
||||
instance the <<a.out>> object format does not allow an
|
||||
arbitary number of sections. A symbol pointing to a section
|
||||
|
@ -142,148 +132,135 @@ DESCRIPTION
|
|||
*/
|
||||
|
||||
|
||||
/*doc*
|
||||
/*
|
||||
@node typedef asymbol, symbol handling functions, Writing Symbols, Symbols
|
||||
|
||||
*/
|
||||
/*
|
||||
TYPEDEF
|
||||
SUBSECTION
|
||||
typedef asymbol
|
||||
|
||||
DESCRIPTION
|
||||
An <<asymbol>> has the form:
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
CODE_FRAGMENT
|
||||
|
||||
.typedef struct symbol_cache_entry
|
||||
.{
|
||||
A pointer to the BFD which owns the symbol. This information
|
||||
is necessary so that a back end can work out what additional
|
||||
(invisible to the application writer) information is carried
|
||||
with the symbol.
|
||||
|
||||
. {* A pointer to the BFD which owns the symbol. This information
|
||||
. is necessary so that a back end can work out what additional
|
||||
. (invisible to the application writer) information is carried
|
||||
. with the symbol. *}
|
||||
.
|
||||
. struct _bfd *the_bfd;
|
||||
|
||||
The text of the symbol. The name is left alone, and not copied - the
|
||||
application may not alter it.
|
||||
|
||||
. CONST char *name;
|
||||
|
||||
The value of the symbol.
|
||||
|
||||
. symvalue value;
|
||||
|
||||
Attributes of a symbol:
|
||||
|
||||
.
|
||||
. {* The text of the symbol. The name is left alone, and not copied - the
|
||||
. application may not alter it. *}
|
||||
. CONST char *name;
|
||||
.
|
||||
. {* The value of the symbol.*}
|
||||
. symvalue value;
|
||||
.
|
||||
. {* Attributes of a symbol: *}
|
||||
.
|
||||
.#define BSF_NO_FLAGS 0x00
|
||||
|
||||
The symbol has local scope; <<static>> in <<C>>. The value is
|
||||
the offset into the section of the data.
|
||||
|
||||
.
|
||||
. {* The symbol has local scope; <<static>> in <<C>>. The value
|
||||
. is the offset into the section of the data. *}
|
||||
.#define BSF_LOCAL 0x01
|
||||
|
||||
The symbol has global scope; initialized data in <<C>>. The value
|
||||
is the offset into the section of the data.
|
||||
|
||||
.
|
||||
. {* The symbol has global scope; initialized data in <<C>>. The
|
||||
. value is the offset into the section of the data. *}
|
||||
.#define BSF_GLOBAL 0x02
|
||||
|
||||
Obsolete
|
||||
|
||||
.
|
||||
. {* Obsolete *}
|
||||
.#define BSF_IMPORT 0x04
|
||||
|
||||
The symbol has global scope, and is exported. The value is the offset
|
||||
into the section of the data.
|
||||
|
||||
.
|
||||
. {* The symbol has global scope, and is exported. The value is
|
||||
. the offset into the section of the data. *}
|
||||
.#define BSF_EXPORT 0x08
|
||||
|
||||
The symbol is undefined. <<extern>> in <<C>>. The value has no meaning.
|
||||
|
||||
.#define BSF_UNDEFINED 0x10
|
||||
|
||||
The symbol is common, initialized to zero; default in <<C>>. The
|
||||
value is the size of the object in bytes.
|
||||
|
||||
.#define BSF_FORT_COMM 0x20
|
||||
|
||||
A normal <<C>> symbol would be one of:
|
||||
<<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or <<BSF_EXPORT|BSD_GLOBAL>>
|
||||
|
||||
The symbol is a debugging record. The value has an arbitary meaning.
|
||||
|
||||
.
|
||||
. {* The symbol is undefined. <<extern>> in <<C>>. The value has
|
||||
. no meaning. *}
|
||||
.#define BSF_UNDEFINED_OBS 0x10
|
||||
.
|
||||
. {* The symbol is common, initialized to zero; default in
|
||||
. <<C>>. The value is the size of the object in bytes. *}
|
||||
.#define BSF_FORT_COMM_OBS 0x20
|
||||
.
|
||||
. {* A normal C symbol would be one of:
|
||||
. <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
|
||||
. <<BSF_EXPORT|BSD_GLOBAL>> *}
|
||||
.
|
||||
. {* The symbol is a debugging record. The value has an arbitary
|
||||
. meaning. *}
|
||||
.#define BSF_DEBUGGING 0x40
|
||||
|
||||
The symbol has no section attached, any value is the actual value and
|
||||
is not a relative offset to a section.
|
||||
|
||||
.#define BSF_ABSOLUTE 0x80
|
||||
|
||||
Used by the linker
|
||||
|
||||
.
|
||||
. {* Used by the linker *}
|
||||
.#define BSF_KEEP 0x10000
|
||||
.#define BSF_KEEP_G 0x80000
|
||||
|
||||
Unused
|
||||
|
||||
.
|
||||
. {* Unused *}
|
||||
.#define BSF_WEAK 0x100000
|
||||
.#define BSF_CTOR 0x200000
|
||||
.#define BSF_FAKE 0x400000
|
||||
|
||||
The symbol used to be a common symbol, but now it is allocated.
|
||||
|
||||
.
|
||||
. {* This symbol was created to point to a section *}
|
||||
.#define BSF_SECTION_SYM 0x400000
|
||||
.
|
||||
. {* The symbol used to be a common symbol, but now it is
|
||||
. allocated. *}
|
||||
.#define BSF_OLD_COMMON 0x800000
|
||||
|
||||
The default value for common data.
|
||||
|
||||
.
|
||||
. {* The default value for common data. *}
|
||||
.#define BFD_FORT_COMM_DEFAULT_VALUE 0
|
||||
|
||||
In some files the type of a symbol sometimes alters its location
|
||||
in an output file - ie in coff a <<ISFCN>> symbol which is also <<C_EXT>>
|
||||
symbol appears where it was declared and not at the end of a section.
|
||||
This bit is set by the target BFD part to convey this information.
|
||||
|
||||
.
|
||||
. {* In some files the type of a symbol sometimes alters its
|
||||
. location in an output file - ie in coff a <<ISFCN>> symbol
|
||||
. which is also <<C_EXT>> symbol appears where it was
|
||||
. declared and not at the end of a section. This bit is set
|
||||
. by the target BFD part to convey this information. *}
|
||||
.
|
||||
.#define BSF_NOT_AT_END 0x40000
|
||||
|
||||
Signal that the symbol is the label of constructor section.
|
||||
|
||||
.
|
||||
. {* Signal that the symbol is the label of constructor section. *}
|
||||
.#define BSF_CONSTRUCTOR 0x1000000
|
||||
|
||||
Signal that the symbol is a warning symbol. If the symbol is a warning
|
||||
symbol, then the value field (I know this is tacky) will point to the
|
||||
asymbol which when referenced will cause the warning.
|
||||
|
||||
.
|
||||
. {* Signal that the symbol is a warning symbol. If the symbol
|
||||
. is a warning symbol, then the value field (I know this is
|
||||
. tacky) will point to the asymbol which when referenced will
|
||||
. cause the warning. *}
|
||||
.#define BSF_WARNING 0x2000000
|
||||
|
||||
Signal that the symbol is indirect. The value of the symbol is a
|
||||
pointer to an undefined asymbol which contains the name to use
|
||||
instead.
|
||||
|
||||
.
|
||||
. {* Signal that the symbol is indirect. The value of the symbol
|
||||
. is a pointer to an undefined asymbol which contains the
|
||||
. name to use instead. *}
|
||||
.#define BSF_INDIRECT 0x4000000
|
||||
|
||||
.
|
||||
. flagword flags;
|
||||
|
||||
A pointer to the section to which this symbol is relative, or 0 if the
|
||||
symbol is absolute or undefined. Note that it is not sufficient to set
|
||||
this location to 0 to mark a symbol as absolute - the flag
|
||||
<<BSF_ABSOLUTE>> must be set also.
|
||||
|
||||
.
|
||||
. {* A pointer to the section to which this symbol is
|
||||
. relative. This will always be non NULL, there are special
|
||||
. sections for undefined and absolute symbols *}
|
||||
. struct sec *section;
|
||||
|
||||
Back end special data. This is being phased out in favour of making
|
||||
this a union.
|
||||
|
||||
.
|
||||
. {* Back end special data. This is being phased out in favour
|
||||
. of making this a union. *}
|
||||
. PTR udata;
|
||||
.
|
||||
.} asymbol;
|
||||
|
||||
*/
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "stab.gnu.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
|
||||
/*
|
||||
@node symbol handling functions, , typedef asymbol, Symbols
|
||||
SUBSECTION
|
||||
Symbol Handling Functions
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -372,13 +349,11 @@ asymbol *symbol)
|
|||
{
|
||||
fprintf_vma(file, symbol->value);
|
||||
}
|
||||
fprintf(file," %c%c%c%c%c%c%c%c%c%c",
|
||||
fprintf(file," %c%c%c%c%c%c%c%c",
|
||||
(type & BSF_LOCAL) ? 'l':' ',
|
||||
(type & BSF_GLOBAL) ? 'g' : ' ',
|
||||
(type & BSF_IMPORT) ? 'i' : ' ',
|
||||
(type & BSF_EXPORT) ? 'e' : ' ',
|
||||
(type & BSF_UNDEFINED) ? 'u' : ' ',
|
||||
(type & BSF_FORT_COMM) ? 'c' : ' ',
|
||||
(type & BSF_CONSTRUCTOR) ? 'C' : ' ',
|
||||
(type & BSF_WARNING) ? 'W' : ' ',
|
||||
(type & BSF_INDIRECT) ? 'I' : ' ',
|
||||
|
@ -421,14 +396,12 @@ asymbol *symbol)
|
|||
{
|
||||
flagword flags = symbol->flags;
|
||||
|
||||
if (flags & BSF_FORT_COMM) return 'C';
|
||||
if (flags & BSF_UNDEFINED) return 'U';
|
||||
if (flags & BSF_ABSOLUTE)
|
||||
return (flags & BSF_GLOBAL) ? 'A' : 'a';
|
||||
if (symbol->section == &bfd_com_section) return 'C';
|
||||
if (symbol->section == &bfd_und_section) return 'U';
|
||||
|
||||
if ( flags & (BSF_GLOBAL|BSF_LOCAL) ) {
|
||||
if (symbol->section == (asection *)NULL)
|
||||
return '*';
|
||||
if ( symbol->section == &bfd_abs_section)
|
||||
return (flags & BSF_GLOBAL) ? 'A' : 'a';
|
||||
else if ( !strcmp(symbol->section->name, ".text") )
|
||||
return (flags & BSF_GLOBAL) ? 'T' : 't';
|
||||
else if ( !strcmp(symbol->section->name, ".data") )
|
||||
|
@ -450,3 +423,11 @@ asymbol *symbol)
|
|||
|
||||
return '?';
|
||||
}
|
||||
|
||||
|
||||
bfd_symbol_is_absolute()
|
||||
{
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||
SECTION
|
||||
Targets
|
||||
|
||||
DESCRIPTION
|
||||
Each port of BFD to a different machine requries the creation
|
||||
of a target back end. All the back end provides to the root
|
||||
part of BFD is a structure containing pointers to functions
|
||||
|
@ -66,18 +67,20 @@ SECTION
|
|||
<<bfd_check_format>> on the BFD with a suggested format. The
|
||||
routine returns <<true>> when the application guesses right.
|
||||
@menu
|
||||
* bfd_target::
|
||||
@* bfd_target::
|
||||
@end menu
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@node bfd_target, , Targets, Targets
|
||||
INODE
|
||||
bfd_target, , Targets, Targets
|
||||
|
||||
SUBSECTION
|
||||
bfd_target
|
||||
|
||||
DESCRIPTION
|
||||
This structure contains everything that BFD knows about a
|
||||
target. It includes things like its byte order, name, what
|
||||
routines to call to do various operations, etc.
|
||||
|
@ -264,6 +267,7 @@ Symbols and reloctions
|
|||
. SDEF (void, _bfd_debug_info_start, (bfd *));
|
||||
. SDEF (void, _bfd_debug_info_end, (bfd *));
|
||||
. SDEF (void, _bfd_debug_info_accumulate, (bfd *, struct sec *));
|
||||
. SDEF (bfd_byte *, _bfd_get_relocated_section_contents, (bfd*,struct bfd_seclet_struct *));
|
||||
|
||||
Special entry points for gdb to swap in coff symbol table parts
|
||||
|
||||
|
|
Loading…
Reference in a new issue