mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-24 12:39:59 +00:00
Initial revision
This commit is contained in:
parent
907621824e
commit
4a81b56152
249
bfd/COPYING
Normal file
249
bfd/COPYING
Normal file
@ -0,0 +1,249 @@
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 1, February 1989
|
||||
|
||||
Copyright (C) 1989 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The license agreements of most software companies try to keep users
|
||||
at the mercy of those companies. By contrast, our General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. The
|
||||
General Public License applies to the Free Software Foundation's
|
||||
software and to any other program whose authors commit to using it.
|
||||
You can use it for your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Specifically, the General Public License is designed to make
|
||||
sure that you have the freedom to give away or sell copies of free
|
||||
software, that you receive source code or can get it if you want it,
|
||||
that you can change the software or use pieces of it in new free
|
||||
programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of a such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must tell them their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any program or other work which
|
||||
contains a notice placed by the copyright holder saying it may be
|
||||
distributed under the terms of this General Public License. The
|
||||
"Program", below, refers to any such program or work, and a "work based
|
||||
on the Program" means either the Program or any work containing the
|
||||
Program or a portion of it, either verbatim or with modifications. Each
|
||||
licensee is addressed as "you".
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source
|
||||
code as you receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice and
|
||||
disclaimer of warranty; keep intact all the notices that refer to this
|
||||
General Public License and to the absence of any warranty; and give any
|
||||
other recipients of the Program a copy of this General Public License
|
||||
along with the Program. You may charge a fee for the physical act of
|
||||
transferring a copy.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of
|
||||
it, and copy and distribute such modifications under the terms of Paragraph
|
||||
1 above, provided that you also do the following:
|
||||
|
||||
a) cause the modified files to carry prominent notices stating that
|
||||
you changed the files and the date of any change; and
|
||||
|
||||
b) cause the whole of any work that you distribute or publish, that
|
||||
in whole or in part contains the Program or any part thereof, either
|
||||
with or without modifications, to be licensed at no charge to all
|
||||
third parties under the terms of this General Public License (except
|
||||
that you may choose to grant warranty protection to some or all
|
||||
third parties, at your option).
|
||||
|
||||
c) If the modified program normally reads commands interactively when
|
||||
run, you must cause it, when started running for such interactive use
|
||||
in the simplest and most usual way, to print or display an
|
||||
announcement including an appropriate copyright notice and a notice
|
||||
that there is no warranty (or else, saying that you provide a
|
||||
warranty) and that users may redistribute the program under these
|
||||
conditions, and telling the user how to view a copy of this General
|
||||
Public License.
|
||||
|
||||
d) You may charge a fee for the physical act of transferring a
|
||||
copy, and you may at your option offer warranty protection in
|
||||
exchange for a fee.
|
||||
|
||||
Mere aggregation of another independent work with the Program (or its
|
||||
derivative) on a volume of a storage or distribution medium does not bring
|
||||
the other work under the scope of these terms.
|
||||
|
||||
3. You may copy and distribute the Program (or a portion or derivative of
|
||||
it, under Paragraph 2) in object code or executable form under the terms of
|
||||
Paragraphs 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of
|
||||
Paragraphs 1 and 2 above; or,
|
||||
|
||||
b) accompany it with a written offer, valid for at least three
|
||||
years, to give any third party free (except for a nominal charge
|
||||
for the cost of distribution) a complete machine-readable copy of the
|
||||
corresponding source code, to be distributed under the terms of
|
||||
Paragraphs 1 and 2 above; or,
|
||||
|
||||
c) accompany it with the information you received as to where the
|
||||
corresponding source code may be obtained. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form alone.)
|
||||
|
||||
Source code for a work means the preferred form of the work for making
|
||||
modifications to it. For an executable file, complete source code means
|
||||
all the source code for all modules it contains; but, as a special
|
||||
exception, it need not include source code for modules which are standard
|
||||
libraries that accompany the operating system on which the executable
|
||||
file runs, or for standard header files or definitions files that
|
||||
accompany that operating system.
|
||||
|
||||
4. You may not copy, modify, sublicense, distribute or transfer the
|
||||
Program except as expressly provided under this General Public License.
|
||||
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
|
||||
the Program is void, and will automatically terminate your rights to use
|
||||
the Program under this License. However, parties who have received
|
||||
copies, or rights to use copies, from you under this General Public
|
||||
License will not have their licenses terminated so long as such parties
|
||||
remain in full compliance.
|
||||
|
||||
5. By copying, distributing or modifying the Program (or any work based
|
||||
on the Program) you indicate your acceptance of this license to do so,
|
||||
and all its terms and conditions.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the original
|
||||
licensor to copy, distribute or modify the Program subject to these
|
||||
terms and conditions. You may not impose any further restrictions on the
|
||||
recipients' exercise of the rights granted herein.
|
||||
|
||||
7. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of the license which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
the license, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
8. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to humanity, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively convey
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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 1, 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.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19xx name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the
|
||||
appropriate parts of the General Public License. Of course, the
|
||||
commands you use may be called something other than `show w' and `show
|
||||
c'; they could even be mouse-clicks or menu items--whatever suits your
|
||||
program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
program `Gnomovision' (a program to direct compilers to make passes
|
||||
at assemblers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
314
bfd/ChangeLog
Normal file
314
bfd/ChangeLog
Normal file
@ -0,0 +1,314 @@
|
||||
Tue Mar 5 01:47:57 1991 John Gilmore (gnu at cygint.cygnus.com)
|
||||
|
||||
* coff-code.h (bfd_coff_swap_sym, bfd_coff_swap_aux,
|
||||
bfd_coff_swap_lineno): Export the routines that byte-swap COFF
|
||||
symbol tables if necessary when reading them in, so gdb can use
|
||||
them. Add "bfd_coff_" to the names so they won't conflict with
|
||||
names in calling programs. FIXME-soon: if coff-code.h is
|
||||
included in two BFD modules, this will cause duplicate
|
||||
definitions; the routines should be exported to a separate,
|
||||
common, module (probably along with a mess of other ones).
|
||||
|
||||
Sat Mar 2 12:11:26 1991 John Gilmore (gnu at cygint.cygnus.com)
|
||||
|
||||
Improve modtime support.
|
||||
|
||||
* bfd.h: Add boolean mtime_set, and declare bfd_get_mtime.
|
||||
Remove #define for bfd_get_mtime. Remove gratuitous comment.
|
||||
* bfd.c (bfd_get_mtime): New fn, caches mtime, gets if not cached.
|
||||
BUG: archive members still do not get correct mod times.
|
||||
|
||||
Improve floating point support for core files.
|
||||
|
||||
* sunos.c (struct core): Change void *fpa_dummy to double fp_stuff.
|
||||
(sunos4_core_file_p): Create a second registers section in the
|
||||
core file, called ".reg2", for the float registers.
|
||||
|
||||
Thu Feb 14 15:49:06 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com)
|
||||
|
||||
* many changes to improve archive handling; found a logic flaw in
|
||||
bfd_check_format which only just happened to work by cooncidence.
|
||||
|
||||
Thu Feb 14 07:53:16 1991 Steve Chamberlain (steve at cygint.cygnus.com)
|
||||
|
||||
* bfd.c (bfd_perform_relocation): fixed to use output_offsets
|
||||
correctly.
|
||||
|
||||
* bfd.h: changed type of udata in asymbol to void *, like it
|
||||
should be. Added bfd_reloc_dangerous enum member.
|
||||
|
||||
* coff-code.h: Fixed it so that internally generated symbols get
|
||||
their values relocated correctly in all cases. Removed calls to
|
||||
xmalloc.
|
||||
|
||||
* icoff.c: Not understanding the destination symbol of a reloc is
|
||||
not a failure any more, just 'dangerous'. This allows linking of
|
||||
b.out and coff images.
|
||||
|
||||
* sunos.c: Cleaned up the way that ZMAGIC section sizes are
|
||||
calculated.
|
||||
|
||||
|
||||
Tue Feb 12 13:25:46 1991 Steve Chamberlain (steve at cygint.cygnus.com)
|
||||
|
||||
* sunos.c (translate_to_native_sym_flags): fixed
|
||||
sym_pointer->n_value so that symbols on the way out get their
|
||||
section relative values calculated correctly.
|
||||
|
||||
* coff-code.h (mangle_symbols): fixed problem where tags were not
|
||||
being relocated for structs, enums, unions. Also various lints.
|
||||
|
||||
Mon Feb 11 19:52:26 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com)
|
||||
|
||||
* archive.c (get_elt_at_filepos): system_call_error returned
|
||||
incorrectly.
|
||||
|
||||
Sun Feb 10 23:18:40 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com)
|
||||
|
||||
* Resolve the use of no_error and system_call_error.
|
||||
The bfd library itself now will never set bfd_error to
|
||||
no_error.
|
||||
|
||||
The code still needs to be combed to make sure all the error
|
||||
codes are correct. I suspect they are not always set correctly.
|
||||
|
||||
* The names of all the messages have _ prepended because the sun
|
||||
bundled compiler can't distinguish from a macro which takes an
|
||||
argument and the same identifier in a non-macro context.
|
||||
|
||||
* The reason for the above being that entry points which used to
|
||||
be trampoline functions are now just macros which expand to a
|
||||
direct call through the bfd's xfer vector.
|
||||
|
||||
* (../include/intel-coff.h) F_AR32WR: fix this constant. Why
|
||||
must gas have its own version of everything (the gas version
|
||||
had the correct value)
|
||||
|
||||
Tue Feb 5 11:46:53 1991 Steve Chamberlain (steve at cygint.cygnus.com)
|
||||
|
||||
* b.out.c: Added patches supplied by chrisb@mipon2.intel.com to
|
||||
properly support i960 architecture and output correct reloc stuff.
|
||||
|
||||
* bfd.h: added prototype for bfd_printable_arch_mach, added
|
||||
BFD_FAIL
|
||||
|
||||
* coff-code.h: Applied patches from chrisb to support i960
|
||||
architecture, zero relocs and swap them correcly and conditionally
|
||||
compiled the timestamp.
|
||||
|
||||
* sunos.c: Made the default section alignment 2^3 so that doubles
|
||||
are done properly. Fixed the same reloc bug that was in b.out.c
|
||||
|
||||
* sysdep.h: Now compiles on a Posix box
|
||||
|
||||
Wed Jan 30 21:36:26 1991 John Gilmore (gnu at cygint.cygnus.com)
|
||||
|
||||
* icoff.c: Fix comment on big-endian version.
|
||||
* coff-code.h: Make HAS_RELOC really work (it's backwards from
|
||||
F_RELFLG). Set F_AR32WR in output files if little endian
|
||||
architecture.
|
||||
|
||||
Tue Jan 29 20:56:10 PST 1991 steve@cygnus.com
|
||||
|
||||
* archures.c fixed =/== typo
|
||||
|
||||
* sunos.c added architecture stuff for output. Fixed
|
||||
bug where files where vma(data) != size(text)
|
||||
were processed wrong.
|
||||
|
||||
* coff-code.h added a lint cast
|
||||
|
||||
* (../include/a.out.sun4.h) fixed it so zmagic
|
||||
worked
|
||||
|
||||
Mon Jan 28 19:15:29 PST 1991 steve@cygnus.com
|
||||
|
||||
* archive.c removed loads of includes, and fixed bug where string
|
||||
table didn't have a null at the end.
|
||||
|
||||
* bfd.c fixed includes, added symbols argument to
|
||||
canonicalize_reloc entry point.
|
||||
|
||||
* libbfd.c fixed includes and added some lint patches.
|
||||
|
||||
* targets.c added both sorts of intel coff.
|
||||
|
||||
* b.out.c fixed included, changed was the canonical
|
||||
relocs were done.
|
||||
|
||||
* icoff.c added support for callj and big and little
|
||||
enidian tables.
|
||||
|
||||
* opncls.c added chmod+xing for files with EXEC_P set.
|
||||
|
||||
* sunos.c fixed includes. Changed default section
|
||||
alignement to words. Fixed relocation stuff to work with
|
||||
new scheme
|
||||
|
||||
* bfd.h various new types added, prototype for new
|
||||
reloc calls, changed bfd->iostream to a void *
|
||||
to including files don't need stdio.h.
|
||||
|
||||
* libcoff.h added conversion table to tie relocs to
|
||||
canonical symbols
|
||||
|
||||
* sysdep.h created
|
||||
|
||||
* coff-code.h fixed includes. Added code to support
|
||||
big and little endian formats. Various lints. Better
|
||||
processing of symbols. Changed reloc stuff to new
|
||||
order
|
||||
|
||||
* libbfd.h fixed includes
|
||||
|
||||
|
||||
Mon Jan 21 11:53:51 PST 1991 steve@cygnus.com
|
||||
|
||||
* bfd.h changed name of alignment entry in sec_struct to
|
||||
alignment_power, because of conflicting uses within bfd.
|
||||
Now it should be obvious that it's a 2**n alignment
|
||||
specifier. Removed start_pad, end_alignment, block, minsize,
|
||||
output_file_alignment, subsection_alignment and original_vma fields.
|
||||
Added align_power() macro. Fixed bfd_section_alignment
|
||||
acessor macros. Added bfd_symbol_same_target macro.
|
||||
|
||||
* b.out.c (b_out_write_object_contents) fixed to use
|
||||
new alignment member. Fixed (callj_callback) to use section
|
||||
relative symbols properly.
|
||||
|
||||
* sunos.c (sunos4_object_p) fixed to use new alignment_power.
|
||||
Fixed (translate_from_native_sym_flags) to correctly make
|
||||
symbols section relative.
|
||||
|
||||
* bfd.c (bfd_errmsg) fixed various enum cast problems.
|
||||
(bfd_make_section) took out initialization of obsolete members.
|
||||
(bfd_print_symbol_vandf) added
|
||||
|
||||
* opncls.c (bfd_create) created.
|
||||
|
||||
* coff-code.h (coff_new_section_hook) took away refs
|
||||
to obsolete members. (make_a_section_from_file) added
|
||||
conversion between alignment types. (coff_symbol_from)
|
||||
added. (coff_count_linenumbers) only counts linenumbers
|
||||
if symbol is of coff-type. (coff_mangle_symbols) only
|
||||
heavily mangles symbols if symbol is coff-type.
|
||||
(coff_write_symbols) various lints. (coff_write_object_contents)
|
||||
various lints and modification for alignment conversion.
|
||||
(coff_slurp_relocs) fixed for use with new asection shape.
|
||||
|
||||
Sat Jan 19 16:10:42 PST 1991 steve@cygnus.com
|
||||
|
||||
* archive.c lots of lint
|
||||
|
||||
* b.out.c added callj relocation support, upgrated reloc howto.
|
||||
Fixed so that asymbol and reloc records are output
|
||||
correctly.
|
||||
|
||||
* bfd.c lots of lint, support for new bfd entry point
|
||||
bfd_print_symbol.
|
||||
|
||||
* bfd.h changed definition of asymbol to contain pointer to
|
||||
owning bfd, removed target dependencies.
|
||||
|
||||
* cache.c took out print statements, put in BFD_ASSERT calls.
|
||||
|
||||
* coff-code.h various lints, corrected linenumber output
|
||||
functionality. Added support for new style asymbols and
|
||||
bfd_print_symbol. Fixed so that asymbol and
|
||||
reloc records are handled correctly. Added timestamp.
|
||||
|
||||
* icoff.c Added support for new howto shape.
|
||||
|
||||
* liba.out.h Added support for new asymbol shape
|
||||
|
||||
* libbfd.c various lints
|
||||
|
||||
* libbfd.h various lints
|
||||
|
||||
* libcoff.h added support for new asymbol shape.
|
||||
|
||||
* sunos.c various lints. Added support for new asymbol shape
|
||||
and bfd_print_symbol.
|
||||
|
||||
Wed Jan 16 21:38:09 PST 1991 steve@cygnus.com
|
||||
|
||||
* b.out.c removed prototype of sunos4_ennativate_symtab, lots of
|
||||
pointer lint. Added support for callj relocation. Fixed bug where
|
||||
the last 32 bytes of the text section were overwritten by data. Fixed bug
|
||||
where archives of b.out didn't work due bfd_slurp_extended_name_table
|
||||
returning false.
|
||||
|
||||
* sunos.c added support for n_other field. Braced the howto table so
|
||||
that it won't be affected by any lengthing of the howto struct typedef.
|
||||
Various lints
|
||||
|
||||
* bfd.h added support for n_other field, added special_function
|
||||
reloc type, modified bfd_perform_relocation prototype. Added bfd_h_get_x
|
||||
macros.
|
||||
|
||||
* bfd.c upgraded bfd_perform_relocation, various lints.
|
||||
|
||||
Wed Jan 16 01:55:53 1991 John Gilmore (gnu at rtl)
|
||||
|
||||
* ChangeLog: Started ChangeLog for BFD.
|
||||
* ToDo: Create file for suggestions.
|
||||
|
||||
* Makefile: Support easy loading into Saber C.
|
||||
Add dependencies for icoff.o and bcs88kcoff.o.
|
||||
Rename coff.c to coff-code.h. Change callers.
|
||||
|
||||
* bfd.c (bfd_check_format): Allow the check_format routines
|
||||
to return the desired target vector, rather than just a Boolean.
|
||||
bfd.h (bfd_check_format): Change function pointer return type.
|
||||
archive.c (bfd_generic_archive_p): change callee.
|
||||
b.out.c (b_out_little_object_p, b_out_big_object_p,
|
||||
b_out_real_object_p): change callee.
|
||||
libbfd.c (_bfd_dummy_target): Dummy routine replacing bfd_false
|
||||
in check_format transfer vectors that need a filler.
|
||||
libbfd.h (bfd_generic_archive_p, _bfd_dummy_target): Fix decls.
|
||||
bcs88kcoff.c: change callee.
|
||||
coff-code.h (coff_real_object_p, coff_big_object_p): change callee.
|
||||
icoff.c: change callee.
|
||||
sunos.c (sunos4_object_p, sunos4_core_file_p): change callee.
|
||||
|
||||
* libbfd.c (zalloc): It should actually zero the storage!
|
||||
This was commented out for some reason.
|
||||
|
||||
* libbfd.h: Add malloc, xmalloc, memcpy, and fatal decls.
|
||||
This is so callers can avoid <stdlib.h> which doesn't exist
|
||||
on older systems.
|
||||
|
||||
* bfd.c (map_over_sections): Add debugging code, since I
|
||||
noticed the section count for sunos core files was bad, but only
|
||||
GDB had detected the problem.
|
||||
(bfd_set_section_lineno_size, bfd_set_section_linenos,
|
||||
bfd_get_section_linenos): Remove obsolete functions.
|
||||
(bfd_apply_relocations): Use longs, not ints, for the math.
|
||||
|
||||
* bfd.h: Declare enum boolean and struct bfd_target as well
|
||||
as typedefs for them. Remove obsolete
|
||||
bfd_get_section_lineno_size.
|
||||
|
||||
* cache.c: Make the "fdopen" support work. Keep better track
|
||||
of how many files are open. Centralize the opening of files
|
||||
and be sure bfd_open[rw] actually try to open the file. Evade
|
||||
linked list initialization problems.
|
||||
|
||||
* b.out.c, coff-code.h, opncls.c, sunos.c: lint.
|
||||
|
||||
* coff-code.h (coff_slurp_symbol_table): Null-terminate symtab names.
|
||||
|
||||
* cplus-dem.c: Delete file, since it is not part of BFD.
|
||||
|
||||
* opncls.c (bfd_openr): Eliminate misplaced #if 0 code.
|
||||
(bfd_openr, bfd_openw): Actually open the file, give error now.
|
||||
|
||||
* sunos.c (sunos4_core_file_p): Set section count.
|
||||
(sunos4_set_section_linenos, stab_names, fprint_name): Eliminiate
|
||||
obsolete definitions.
|
||||
(_write_symbol_table): Initialize <idx> counter.
|
||||
(foop): Eliminate debugging code.
|
||||
|
||||
|
||||
|
||||
|
158
bfd/Makefile
Executable file
158
bfd/Makefile
Executable file
@ -0,0 +1,158 @@
|
||||
#
|
||||
# Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of BFD, the Binary File Diddler.
|
||||
#
|
||||
# BFD 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 1, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# BFD 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 BFD; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
# $Id$
|
||||
|
||||
srcdir=.
|
||||
|
||||
RANLIB = ranlib
|
||||
CSWITCHES = -g # -Wall
|
||||
#CDEFINES = # -DHOST_SYS=AIX_SYS # -DCOFF_TIMESTAMP -DANSI_LIBRARIES
|
||||
INCDIR = ${srcdir}/../../include-cygnus
|
||||
CSEARCH = -I$(INCDIR)
|
||||
|
||||
TARG = libbfd.a
|
||||
CFLAGS = $(CDEFINES) $(CSEARCH) $(CSWITCHES) -DINTEL960VERSION
|
||||
|
||||
|
||||
BFD_LIBS = libbfd.o opncls.o bfd.o archive.o targets.o cache.o archures.o
|
||||
|
||||
BFD_BACKENDS = sunos.o icoff.o b.out.o # srec.o # bcs88kcoff.o
|
||||
|
||||
BFD_H=$(INCDIR)/bfd.h
|
||||
SYSDEP_H=$(INCDIR)/sysdep.h
|
||||
|
||||
# C source files that correspond to .o's.
|
||||
CFILES = libbfd.c opncls.c bfd.c archive.c targets.c cache.c archures.c \
|
||||
sunos.c icoff.c b.out.c # srec.c # bcs88kcoff.c
|
||||
|
||||
all: $(TARG)
|
||||
|
||||
POINTOS = $(BFD_LIBS) $(BFD_BACKENDS)
|
||||
|
||||
$(TARG): $(POINTOS)
|
||||
rm -f $(TARG)
|
||||
ar clq $(TARG) $(BFD_LIBS) $(BFD_BACKENDS)
|
||||
ranlib $(TARG)
|
||||
|
||||
tags etags: TAGS
|
||||
|
||||
TAGS: .force
|
||||
etags $(INCDIR)/*.h *.h *.c
|
||||
|
||||
clean:
|
||||
rm -f $(BFD_LIBS) $(BFD_BACKENDS) *~ core libbfd.a
|
||||
|
||||
clobber realclean: clean
|
||||
rm -f libbfd.a TAGS
|
||||
|
||||
$(BFD_LIBS) $(BFD_BACKENDS): libbfd.h $(BFD_H)
|
||||
|
||||
saber:
|
||||
#suppress 65 on bfd_map_over_sections
|
||||
#suppress 66 on bfd_map_over_sections
|
||||
#suppress 67 on bfd_map_over_sections
|
||||
#suppress 68 on bfd_map_over_sections
|
||||
#suppress 69 on bfd_map_over_sections
|
||||
#suppress 70 on bfd_map_over_sections
|
||||
#suppress 110 in bfd_map_over_sections
|
||||
#suppress 112 in bfd_map_over_sections
|
||||
#suppress 530
|
||||
#suppress 590 in swap_exec_header
|
||||
#suppress 590 in _bfd_dummy_core_file_matches_executable_p
|
||||
#suppress 590 in bfd_dont_truncate_arname
|
||||
#suppress 590 on ignore
|
||||
#suppress 590 on abfd
|
||||
#setopt load_flags $(CFLAGS)
|
||||
#load $(CFILES)
|
||||
|
||||
archive.o : archive.c libbfd.h $(BFD_H) $(SYSDEP_H)
|
||||
archures.o : archures.c $(BFD_H) $(SYSDEP_H) archures.h
|
||||
b.out.o : b.out.c libbfd.h $(BFD_H) $(SYSDEP_H) liba.out.h archures.h
|
||||
bcs88kcoff.o : bcs88kcoff.c libbfd.h $(BFD_H) $(SYSDEP_H) libcoff.h coff-code.h archures.h
|
||||
bfd.o : bfd.c libbfd.h $(BFD_H) $(SYSDEP_H)
|
||||
cache.o : cache.c libbfd.h $(BFD_H) $(SYSDEP_H)
|
||||
coff.o : coff.c
|
||||
cplus-dem.o : cplus-dem.c
|
||||
filemode.o : filemode.c
|
||||
icoff.o : icoff.c libbfd.h $(BFD_H) $(SYSDEP_H) libcoff.h coff-code.h archures.h
|
||||
libbfd.o : libbfd.c libbfd.h $(BFD_H) $(SYSDEP_H)
|
||||
misc.o : misc.c
|
||||
opncls.o : opncls.c libbfd.h $(BFD_H) $(SYSDEP_H)
|
||||
sunos.o : sunos.c libbfd.h $(BFD_H) $(SYSDEP_H) liba.out.h
|
||||
targets.o : targets.c libbfd.h $(BFD_H) $(SYSDEP_H)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
|
||||
#
|
||||
# 'VERSION' file must be present and contain a string of the form "x.y"
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
ver960.c: FORCE
|
||||
rm -f ver960.c
|
||||
echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
|
||||
|
||||
|
||||
# This target should be invoked before building a new release.
|
||||
# 'VERSION' file must be present and contain a string of the form "x.y"
|
||||
#
|
||||
roll:
|
||||
@V=`cat VERSION` ; \
|
||||
MAJ=`sed 's/\..*//' VERSION` ; \
|
||||
MIN=`sed 's/.*\.//' VERSION` ; \
|
||||
V=$$MAJ.`expr $$MIN + 1` ; \
|
||||
rm -f VERSION ; \
|
||||
echo $$V >VERSION ; \
|
||||
echo Version $$V
|
||||
|
||||
# Dummy target to force execution of dependent targets.
|
||||
#
|
||||
.force:
|
||||
FORCE:
|
||||
|
||||
# 'G960BASE' will be defined at invocation
|
||||
install:
|
||||
make ${TARG} OPT=-O
|
||||
|
||||
# Target to uncomment host-specific lines in this makefile. Such lines must
|
||||
# have the following string beginning in column 1: #__<hostname>__#
|
||||
# Original Makefile is backed up as 'Makefile.old'.
|
||||
#
|
||||
# Invoke with: make make HOST=xxx
|
||||
#
|
||||
make:
|
||||
-@if test $(HOST)x = x ; then \
|
||||
echo 'Specify "make make HOST=???"'; \
|
||||
exit 1; \
|
||||
fi ; \
|
||||
grep -s "^#The next line was generated by 'make make'" Makefile; \
|
||||
if test $$? = 0 ; then \
|
||||
echo "Makefile has already been processed with 'make make'";\
|
||||
exit 1; \
|
||||
fi ; \
|
||||
mv -f Makefile Makefile.old; \
|
||||
echo "#The next line was generated by 'make make'" >Makefile ; \
|
||||
echo "HOST=$(HOST)" >>Makefile ; \
|
||||
echo >>Makefile ; \
|
||||
sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile
|
||||
|
||||
Makefile: ../common/Makefile
|
||||
mv Makefile Makefile.backup
|
||||
cp ../common/Makefile .
|
||||
$(MAKE) "HOST=$(HOST)" make
|
49
bfd/TODO
Normal file
49
bfd/TODO
Normal file
@ -0,0 +1,49 @@
|
||||
Things that still need to be handled: -*- Text -*-
|
||||
|
||||
o - check all the swapping code.
|
||||
o - change the memory usage to reflect the message which follows the
|
||||
page break.
|
||||
o - implement bfd_abort, which should close the bfd but not alter the
|
||||
filesystem.
|
||||
o - remove the following obsolete functions:
|
||||
bfd_symbol_value
|
||||
bfd_symbol_name
|
||||
bfd_get_first_symbol
|
||||
bfd_get_next_symbol
|
||||
bfd_classify_symbol
|
||||
bfd_symbol_hasclass
|
||||
o - update the bfd doc; write a how-to-write-a-backend doc.
|
||||
o - change reloc handling as per Steve's suggestion.
|
||||
|
||||
|
||||
Changing the way bfd uses memory. The new convention is simple:
|
||||
|
||||
o - bfd will never write into user-supplied memory, nor attempt to
|
||||
free it.
|
||||
o - closing a bfd may reclaim all bfd-allocated memory associated
|
||||
with that bfd.
|
||||
- - bfd_target_list will be the one exception; you must reclaim the
|
||||
returned vector yourself.
|
||||
|
||||
Interface implications are minor (get_symcount_upper_bound will go
|
||||
away; bfd_cannicalize_symtab will allocate its own memory, etc).
|
||||
|
||||
Certain operations consume a lot of memory; for them manual
|
||||
reclaimation is available:
|
||||
|
||||
o - bfd_canonicalize_symtab will return a pointer to a
|
||||
null-terminated vector of symbols. Subsequent calls may or may
|
||||
not return the same pointer.
|
||||
bfd_canonicalize_relocs will do the same; returning a pointer to
|
||||
an array of arelocs. Calling this function will read symbols in
|
||||
too.
|
||||
|
||||
o - bfd_reclaim_relocs will free the memory used by these relocs.
|
||||
the symbols will be untouched.
|
||||
bfd_reclaim_symtab (ne bfd_reclaim_symbol_table) will free the
|
||||
memory allocated by canonialize_symtab.
|
||||
Since relocations point to symbols, any relocations obtained by a
|
||||
call to bfd_canonicalize_relocs will be reclaimed as well.
|
||||
|
||||
o - if you don't call the reclaim_ functions, the memory will be
|
||||
reclaimed at bfd_close time.
|
1904
bfd/aout.c
Executable file
1904
bfd/aout.c
Executable file
File diff suppressed because it is too large
Load Diff
1223
bfd/archive.c
Normal file
1223
bfd/archive.c
Normal file
File diff suppressed because it is too large
Load Diff
368
bfd/archures.c
Normal file
368
bfd/archures.c
Normal file
@ -0,0 +1,368 @@
|
||||
/* BFD library support routines for architectures. */
|
||||
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "archures.h"
|
||||
|
||||
static char *prt_num_mach ();
|
||||
static boolean scan_num_mach ();
|
||||
static char *prt_960_mach ();
|
||||
static boolean scan_960_mach ();
|
||||
|
||||
struct arch_print {
|
||||
enum bfd_architecture arch;
|
||||
char *astr;
|
||||
char *(*mach_print)();
|
||||
boolean (*mach_scan)();
|
||||
} arch_print[] = {
|
||||
|
||||
{bfd_arch_unknown, "unknown", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_obscure, "obscure", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_m68k, "m68k", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_vax, "vax", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_i960, "i960", prt_960_mach, scan_960_mach},
|
||||
{bfd_arch_a29k, "a29k", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_sparc, "sparc", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_mips, "mips", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_i386, "i386", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_ns32k, "ns32k", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_tahoe, "tahoe", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_i860, "i860", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_romp, "romp", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_alliant, "alliant", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_convex, "convex", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_m88k, "m88k", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_pyramid, "pyramid", prt_num_mach, scan_num_mach},
|
||||
{bfd_arch_unknown, (char *)0, prt_num_mach, scan_num_mach},
|
||||
};
|
||||
|
||||
/* Return a printable string representing the architecture and machine
|
||||
type. The result is only good until the next call to
|
||||
bfd_printable_arch_mach. */
|
||||
|
||||
char *
|
||||
bfd_printable_arch_mach (arch, machine)
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
struct arch_print *ap;
|
||||
|
||||
for (ap = arch_print; ap->astr; ap++) {
|
||||
if (ap->arch == arch) {
|
||||
if (machine == 0)
|
||||
return ap->astr;
|
||||
return (*ap->mach_print)(ap, machine);
|
||||
}
|
||||
}
|
||||
return "UNKNOWN!";
|
||||
}
|
||||
|
||||
static char *
|
||||
prt_num_mach (ap, machine)
|
||||
struct arch_print *ap;
|
||||
unsigned long machine;
|
||||
{
|
||||
static char result[20];
|
||||
|
||||
sprintf(result, "%s:%ld", ap->astr, (long) machine);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Scan a string and attempt to turn it into an archive and machine type
|
||||
combination. */
|
||||
|
||||
boolean
|
||||
bfd_scan_arch_mach (string, archp, machinep)
|
||||
char *string;
|
||||
enum bfd_architecture *archp;
|
||||
unsigned long *machinep;
|
||||
{
|
||||
struct arch_print *ap;
|
||||
int len;
|
||||
|
||||
/* First look for an architecture, possibly followed by machtype. */
|
||||
for (ap = arch_print; ap->astr; ap++) {
|
||||
if (ap->astr[0] != string[0])
|
||||
continue;
|
||||
len = strlen (ap->astr);
|
||||
if (!strncmp (ap->astr, string, len)) {
|
||||
/* We found the architecture, now see about the machine type */
|
||||
if (archp)
|
||||
*archp = ap->arch;
|
||||
if (string[len] != '\0') {
|
||||
if (ap->mach_scan (string+len, ap, archp, machinep, 1))
|
||||
return true;
|
||||
}
|
||||
if (machinep)
|
||||
*machinep = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Couldn't find an architecture -- try for just a machine type */
|
||||
for (ap = arch_print; ap->astr; ap++) {
|
||||
if (ap->mach_scan (string, ap, archp, machinep, 0))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean
|
||||
scan_num_mach (string, ap, archp, machinep, archspec)
|
||||
char *string;
|
||||
struct arch_print *ap;
|
||||
enum bfd_architecture *archp;
|
||||
unsigned long *machinep;
|
||||
int archspec;
|
||||
{
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
char achar;
|
||||
|
||||
if (archspec) {
|
||||
|
||||
/* Architecture already specified, now go for machine type. */
|
||||
if (string[0] != ':')
|
||||
return false;
|
||||
/* We'll take any valid number that occupies the entire string */
|
||||
if (1 != sscanf (string+1, "%lu%c", &machine, &achar))
|
||||
return false;
|
||||
arch = ap->arch;
|
||||
|
||||
} else {
|
||||
|
||||
/* We couldn't identify an architecture prefix. Perhaps the entire
|
||||
thing is a machine type. Be a lot picker. */
|
||||
if (1 != sscanf (string, "%lu%c", &machine, &achar))
|
||||
return false;
|
||||
switch (machine) {
|
||||
case 68010:
|
||||
case 68020:
|
||||
case 68030:
|
||||
case 68040:
|
||||
case 68332:
|
||||
case 68050: arch = bfd_arch_m68k; break;
|
||||
case 68000: arch = bfd_arch_m68k; machine = 0; break;
|
||||
|
||||
case 80960:
|
||||
case 960: arch = bfd_arch_i960; machine = 0; break;
|
||||
|
||||
case 386:
|
||||
case 80386: arch = bfd_arch_i386; machine = 0; break;
|
||||
case 486: arch = bfd_arch_i386; break;
|
||||
|
||||
case 29000: arch = bfd_arch_a29k; machine = 0; break;
|
||||
|
||||
case 32016:
|
||||
case 32032:
|
||||
case 32132:
|
||||
case 32232:
|
||||
case 32332:
|
||||
case 32432:
|
||||
case 32532: arch = bfd_arch_ns32k; break;
|
||||
case 32000: arch = bfd_arch_ns32k; machine = 0; break;
|
||||
|
||||
case 860:
|
||||
case 80860: arch = bfd_arch_i860; machine = 0; break;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (archp)
|
||||
*archp = arch;
|
||||
if (machinep)
|
||||
*machinep = machine;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Intel 960 machine variants. */
|
||||
|
||||
static char *
|
||||
prt_960_mach (ap, machine)
|
||||
struct arch_print *ap;
|
||||
unsigned long machine;
|
||||
{
|
||||
static char result[20];
|
||||
char *str;
|
||||
|
||||
switch (machine) {
|
||||
case bfd_mach_i960_core: str = "core"; break;
|
||||
case bfd_mach_i960_kb_sb: str = "kb"; break;
|
||||
case bfd_mach_i960_mc: str = "mc"; break;
|
||||
case bfd_mach_i960_xa: str = "xa"; break;
|
||||
case bfd_mach_i960_ca: str = "ca"; break;
|
||||
case bfd_mach_i960_ka_sa: str = "ka"; break;
|
||||
default:
|
||||
return prt_num_mach (ap, machine);
|
||||
}
|
||||
sprintf (result, "%s:%s", ap->astr, str);
|
||||
return result;
|
||||
}
|
||||
|
||||
static boolean
|
||||
scan_960_mach (string, ap, archp, machinep, archspec)
|
||||
char *string;
|
||||
struct arch_print *ap;
|
||||
enum bfd_architecture *archp;
|
||||
unsigned long *machinep;
|
||||
int archspec;
|
||||
{
|
||||
unsigned long machine;
|
||||
|
||||
if (!archspec)
|
||||
return false;
|
||||
if (string[0] != ':')
|
||||
return false;
|
||||
string++;
|
||||
if (string[0] == '\0')
|
||||
return false;
|
||||
if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' &&
|
||||
string[3] == 'e' && string[4] == '\0')
|
||||
machine = bfd_mach_i960_core;
|
||||
else if (string[1] == '\0' || string[2] != '\0') /* rest are 2-char */
|
||||
return false;
|
||||
else if (string[0] == 'k' && string[1] == 'b')
|
||||
machine = bfd_mach_i960_kb_sb;
|
||||
else if (string[0] == 's' && string[1] == 'b')
|
||||
machine = bfd_mach_i960_kb_sb;
|
||||
else if (string[0] == 'm' && string[1] == 'c')
|
||||
machine = bfd_mach_i960_mc;
|
||||
else if (string[0] == 'x' && string[1] == 'a')
|
||||
machine = bfd_mach_i960_xa;
|
||||
else if (string[0] == 'c' && string[1] == 'a')
|
||||
machine = bfd_mach_i960_ca;
|
||||
else if (string[0] == 'k' && string[1] == 'a')
|
||||
machine = bfd_mach_i960_ka_sa;
|
||||
else if (string[0] == 's' && string[1] == 'a')
|
||||
machine = bfd_mach_i960_ka_sa;
|
||||
else
|
||||
return false;
|
||||
|
||||
if (archp)
|
||||
*archp = ap->arch;
|
||||
if (machinep)
|
||||
*machinep = machine;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Determine whether two BFDs' architectures and machine types are
|
||||
compatible. Return merged architecture and machine type if nonnull
|
||||
pointers. */
|
||||
|
||||
boolean
|
||||
bfd_arch_compatible (abfd, bbfd, archp, machinep)
|
||||
bfd *abfd;
|
||||
bfd *bbfd;
|
||||
enum bfd_architecture *archp;
|
||||
unsigned long *machinep;
|
||||
{
|
||||
enum bfd_architecture archa, archb;
|
||||
unsigned long macha, machb;
|
||||
int pick_a;
|
||||
|
||||
archa = bfd_get_architecture (abfd);
|
||||
archb = bfd_get_architecture (bbfd);
|
||||
macha = bfd_get_machine (abfd);
|
||||
machb = bfd_get_machine (bbfd);
|
||||
|
||||
if (archb == bfd_arch_unknown)
|
||||
pick_a = 1;
|
||||
else if (archa == bfd_arch_unknown)
|
||||
pick_a = 0;
|
||||
else if (archa != archb)
|
||||
return false; /* Not compatible */
|
||||
else {
|
||||
/* Architectures are the same. Check machine types. */
|
||||
if (macha == machb) /* Same machine type */
|
||||
pick_a = 1;
|
||||
else if (machb == 0) /* B is default */
|
||||
pick_a = 1;
|
||||
else if (macha == 0) /* A is default */
|
||||
pick_a = 0;
|
||||
else switch (archa) {
|
||||
/* If particular machine types of one architecture are not
|
||||
compatible with each other, this is the place to put those tests
|
||||
(returning false if incompatible). */
|
||||
case bfd_arch_i960:
|
||||
/* The i960 has to distinct subspecies which may not interbreed:
|
||||
CORE CA
|
||||
CORE KA KB MC
|
||||
Any architecture on the same line is compatible, the one on
|
||||
the right is the least restrictive.
|
||||
*/
|
||||
/* So, if either is a ca then the other must be a be core or ca */
|
||||
if (macha == bfd_mach_i960_ca) {
|
||||
if (machb != bfd_mach_i960_ca &&
|
||||
machb != bfd_mach_i960_core) {
|
||||
return false;
|
||||
}
|
||||
pick_a = 1;
|
||||
}
|
||||
else if (machb == bfd_mach_i960_ca) {
|
||||
if (macha != bfd_mach_i960_ca &&
|
||||
macha != bfd_mach_i960_core) {
|
||||
return false;
|
||||
}
|
||||
pick_a = 0;
|
||||
}
|
||||
else {
|
||||
/* This must be from the bottom row, so take the higest */
|
||||
pick_a = (macha > machb);
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
/* For these chips, as far as we care, "lower" numbers are included
|
||||
by "higher" numbers, e.g. merge 68010 and 68020 into 68020,
|
||||
386 and 486 into 486, etc. This will need to change
|
||||
if&when we care about things like 68332. */
|
||||
case bfd_arch_m68k:
|
||||
case bfd_arch_ns32k:
|
||||
case bfd_arch_i386:
|
||||
pick_a = (macha > machb);
|
||||
break;
|
||||
|
||||
/* By default, pick first file's type, for lack of something better. */
|
||||
default:
|
||||
pick_a = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set result based on our pick */
|
||||
if (!pick_a) {
|
||||
archa = archb;
|
||||
macha = machb;
|
||||
}
|
||||
if (archp)
|
||||
*archp = archa;
|
||||
if (machinep)
|
||||
*machinep = macha;
|
||||
|
||||
return true;
|
||||
}
|
41
bfd/archures.h
Executable file
41
bfd/archures.h
Executable file
@ -0,0 +1,41 @@
|
||||
/* Intel 960 machine types */
|
||||
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/*
|
||||
Machine architecture and type definitions for BFD.
|
||||
|
||||
These definitions are only used inside the BFD package. External programs
|
||||
access them by calling bfd_scan_arch_mach() and bfd_arch_mach_string().
|
||||
|
||||
The architectures themselves are defined in bfd.h since they are an
|
||||
enum needed for BFD structs. Numeric machine types are simply used
|
||||
as-is, e.g. 68020. Non-numeric machine types like "i960CA" have
|
||||
names in this file. */
|
||||
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#define bfd_mach_i960_core 1
|
||||
#define bfd_mach_i960_kb_sb 2
|
||||
#define bfd_mach_i960_mc 3
|
||||
#define bfd_mach_i960_xa 4
|
||||
#define bfd_mach_i960_ca 5
|
||||
#define bfd_mach_i960_ka_sa 6
|
||||
|
882
bfd/bfd.c
Normal file
882
bfd/bfd.c
Normal file
@ -0,0 +1,882 @@
|
||||
/* -*- C -*- */
|
||||
|
||||
/*** bfd -- binary file diddling routines by Gumby Wallace of Cygnus Support.
|
||||
Every definition in this file should be exported and declared
|
||||
in bfd.c. If you don't want it to be user-visible, put it in
|
||||
libbfd.c!
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
short _bfd_host_big_endian = 0x0100;
|
||||
/* Accessing the above as (*(char*)&_bfd_host_big_endian), will
|
||||
* return 1 if the host is big-endian, 0 otherwise.
|
||||
* (See HOST_IS_BIG_ENDIAN_P in bfd.h.)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/** Error handling
|
||||
o - Most functions return nonzero on success (check doc for
|
||||
precise semantics); 0 or NULL on error.
|
||||
o - Internal errors are documented by the value of bfd_error.
|
||||
If that is system_call_error then check errno.
|
||||
o - The easiest way to report this to the user is to use bfd_perror.
|
||||
*/
|
||||
|
||||
bfd_ec bfd_error = no_error;
|
||||
|
||||
char *bfd_errmsgs[] = {"No error",
|
||||
"System call error",
|
||||
"Invalid target",
|
||||
"File in wrong format",
|
||||
"Invalid operation",
|
||||
"Memory exhausted",
|
||||
"No symbols",
|
||||
"No relocation info",
|
||||
"No more archived files",
|
||||
"Malformed archive",
|
||||
"Symbol not found",
|
||||
"File format not recognized",
|
||||
"File format is ambiguous",
|
||||
"Section has no contents",
|
||||
"#<Invalid error code>"
|
||||
};
|
||||
|
||||
#if !defined(ANSI_LIBRARIES)
|
||||
char *
|
||||
strerror (code)
|
||||
int code;
|
||||
{
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
|
||||
return (((code < 0) || (code >= sys_nerr)) ? "(unknown error)" :
|
||||
sys_errlist [code]);
|
||||
}
|
||||
#endif /* not ANSI_LIBRARIES */
|
||||
|
||||
char *
|
||||
bfd_errmsg (error_tag)
|
||||
bfd_ec error_tag;
|
||||
{
|
||||
extern int errno;
|
||||
|
||||
if (error_tag == system_call_error)
|
||||
return strerror (errno);
|
||||
|
||||
if ((((int)error_tag <(int) no_error) ||
|
||||
((int)error_tag > (int)invalid_error_code)))
|
||||
error_tag = invalid_error_code;/* sanity check */
|
||||
|
||||
return bfd_errmsgs [(int)error_tag];
|
||||
}
|
||||
|
||||
void
|
||||
bfd_perror (message)
|
||||
char *message;
|
||||
{
|
||||
if (bfd_error == system_call_error)
|
||||
perror(message); /* must be system error then... */
|
||||
else {
|
||||
if (message == NULL || *message == '\0')
|
||||
fprintf (stderr, "%s\n", bfd_errmsg (bfd_error));
|
||||
else
|
||||
fprintf (stderr, "%s: %s\n", message, bfd_errmsg (bfd_error));
|
||||
}
|
||||
}
|
||||
|
||||
/* for error messages */
|
||||
char *
|
||||
bfd_format_string (format)
|
||||
bfd_format format;
|
||||
{
|
||||
if (((int)format <(int) bfd_unknown) || ((int)format >=(int) bfd_type_end)) return "invalid";
|
||||
|
||||
switch (format) {
|
||||
case bfd_object: return "object"; /* linker/assember/compiler output */
|
||||
case bfd_archive: return "archive"; /* object archive file */
|
||||
case bfd_core: return "core"; /* core dump */
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/** Target configurations */
|
||||
|
||||
extern bfd_target *target_vector[];
|
||||
|
||||
/* Returns a pointer to the transfer vector for the object target
|
||||
named target_name. If target_name is NULL, chooses the one in the
|
||||
environment variable GNUTARGET; if that is null or not defined then
|
||||
the first entry in the target list is chosen. Passing in the
|
||||
string "default" or setting the environment variable to "default"
|
||||
will cause the first entry in the target list to be returned. */
|
||||
|
||||
bfd_target *
|
||||
bfd_find_target (target_name)
|
||||
char *target_name;
|
||||
{
|
||||
bfd_target **target;
|
||||
extern char *getenv ();
|
||||
char *targname = (target_name ? target_name : getenv ("GNUTARGET"));
|
||||
|
||||
/* This is safe; the vector cannot be null */
|
||||
if (targname == NULL || !strcmp (targname, "default"))
|
||||
return target_vector[0];
|
||||
|
||||
for (target = &target_vector[0]; *target != NULL; target++) {
|
||||
if (!strcmp (targname, (*target)->name))
|
||||
return *target;
|
||||
}
|
||||
|
||||
bfd_error = invalid_target;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Returns a freshly-consed, NULL-terminated vector of the names of all the
|
||||
valid bfd targets. Do not modify the names */
|
||||
|
||||
char **
|
||||
bfd_target_list ()
|
||||
{
|
||||
int vec_length= 0;
|
||||
bfd_target **target;
|
||||
char **name_list, **name_ptr;
|
||||
|
||||
for (target = &target_vector[0]; *target != NULL; target++)
|
||||
vec_length++;
|
||||
|
||||
name_ptr = name_list = (char **) zalloc ((vec_length + 1) * sizeof (char **));
|
||||
|
||||
if (name_list == NULL) {
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (target = &target_vector[0]; *target != NULL; target++)
|
||||
*(name_ptr++) = (*target)->name;
|
||||
|
||||
return name_list;
|
||||
}
|
||||
|
||||
/** Init a bfd for read of the proper format.
|
||||
*/
|
||||
|
||||
/* We should be able to find out if the target was defaulted or user-specified.
|
||||
If the user specified the target explicitly then we should do no search.
|
||||
I guess the best way to do this is to pass an extra argument which specifies
|
||||
the DWIM. */
|
||||
|
||||
/* I have chanegd this always to set the filepos to the origin before
|
||||
guessing. -- Gumby, 14 Februar 1991*/
|
||||
|
||||
boolean
|
||||
bfd_check_format (abfd, format)
|
||||
bfd *abfd;
|
||||
bfd_format format;
|
||||
{
|
||||
#if obsolete
|
||||
file_ptr filepos;
|
||||
#endif
|
||||
bfd_target **target, *save_targ, *right_targ;
|
||||
int match_count;
|
||||
|
||||
if (!bfd_read_p (abfd) ||
|
||||
((int)(abfd->format) < (int)bfd_unknown) ||
|
||||
((int)(abfd->format) >= (int)bfd_type_end)) {
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abfd->format != bfd_unknown) return (abfd->format == format) ? true:false;
|
||||
|
||||
/* presume the answer is yes */
|
||||
abfd->format = format;
|
||||
|
||||
#if obsolete
|
||||
filepos = bfd_tell (abfd);
|
||||
#endif
|
||||
bfd_seek (abfd, (file_ptr)0, SEEK_SET); /* instead, rewind! */
|
||||
|
||||
|
||||
right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
|
||||
if (right_targ) {
|
||||
abfd->xvec = right_targ; /* Set the target as returned */
|
||||
return true; /* File position has moved, BTW */
|
||||
}
|
||||
|
||||
/* This isn't a <format> file in the specified or defaulted target type.
|
||||
See if we recognize it for any other target type. (We check them
|
||||
all to make sure it's uniquely recognized.) */
|
||||
|
||||
save_targ = abfd->xvec;
|
||||
match_count = 0;
|
||||
right_targ = 0;
|
||||
|
||||
for (target = target_vector; *target != NULL; target++) {
|
||||
bfd_target *temp;
|
||||
|
||||
abfd->xvec = *target; /* Change BFD's target temporarily */
|
||||
#if obsolete
|
||||
bfd_seek (abfd, filepos, SEEK_SET); /* Restore original file position */
|
||||
#endif
|
||||
bfd_seek (abfd, (file_ptr)0, SEEK_SET);
|
||||
temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
|
||||
if (temp) { /* This format checks out as ok! */
|
||||
right_targ = temp;
|
||||
match_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (match_count == 1) {
|
||||
abfd->xvec = right_targ; /* Change BFD's target permanently */
|
||||
return true; /* File position has moved, BTW */
|
||||
}
|
||||
|
||||
abfd->xvec = save_targ; /* Restore original target type */
|
||||
abfd->format = bfd_unknown; /* Restore original format */
|
||||
bfd_error = ((match_count == 0) ? file_not_recognized :
|
||||
file_ambiguously_recognized);
|
||||
#if obsolete
|
||||
bfd_seek (abfd, filepos, SEEK_SET); /* Restore original file position */
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean
|
||||
bfd_set_format (abfd, format)
|
||||
bfd *abfd;
|
||||
bfd_format format;
|
||||
{
|
||||
file_ptr filepos;
|
||||
|
||||
if (bfd_read_p (abfd) ||
|
||||
((int)abfd->format < (int)bfd_unknown) ||
|
||||
((int)abfd->format >= (int)bfd_type_end)) {
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abfd->format != bfd_unknown) return (abfd->format == format) ? true:false;
|
||||
|
||||
/* presume the answer is yes */
|
||||
abfd->format = format;
|
||||
|
||||
filepos = bfd_tell (abfd);
|
||||
|
||||
if (!BFD_SEND_FMT (abfd, _bfd_set_format, (abfd))) {
|
||||
abfd->format = bfd_unknown;
|
||||
bfd_seek (abfd, filepos, SEEK_SET);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Hack object and core file sections */
|
||||
|
||||
sec_ptr
|
||||
bfd_get_section_by_name (abfd, name)
|
||||
bfd *abfd;
|
||||
char *name;
|
||||
{
|
||||
asection *sect;
|
||||
|
||||
for (sect = abfd->sections; sect != NULL; sect = sect->next)
|
||||
if (!strcmp (sect->name, name)) return sect;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If you try to create a section with a name which is already in use,
|
||||
returns the old section by that name instead. */
|
||||
sec_ptr
|
||||
bfd_make_section (abfd, name)
|
||||
bfd *abfd;
|
||||
char *name;
|
||||
{
|
||||
asection *newsect;
|
||||
asection ** prev = &abfd->sections;
|
||||
asection * sect = abfd->sections;
|
||||
|
||||
if (abfd->output_has_begun) {
|
||||
bfd_error = invalid_operation;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (sect) {
|
||||
if (!strcmp(sect->name, name)) return sect;
|
||||
prev = §->next;
|
||||
sect = sect->next;
|
||||
}
|
||||
|
||||
newsect = (asection *) zalloc (sizeof (asection));
|
||||
if (newsect == NULL) {
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newsect->name = name;
|
||||
newsect->index = abfd->section_count++;
|
||||
newsect->flags = SEC_NO_FLAGS;
|
||||
|
||||
#if ignore /* the compiler doesn't know that zalloc clears the storage */
|
||||
newsect->userdata = 0;
|
||||
newsect->next = (asection *)NULL;
|
||||
newsect->relocation = (arelent *)NULL;
|
||||
newsect->reloc_count = 0;
|
||||
newsect->line_filepos =0;
|
||||
#endif
|
||||
if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true) {
|
||||
free (newsect);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*prev = newsect;
|
||||
return newsect;
|
||||
}
|
||||
|
||||
/* Call operation on each section. Operation gets three args: the bfd,
|
||||
the section, and a void * pointer (whatever the user supplied). */
|
||||
|
||||
/* This is attractive except that without lexical closures its use is hard
|
||||
to make reentrant. */
|
||||
/*VARARGS2*/
|
||||
void
|
||||
bfd_map_over_sections (abfd, operation, user_storage)
|
||||
bfd *abfd;
|
||||
void (*operation)();
|
||||
void *user_storage;
|
||||
{
|
||||
asection *sect;
|
||||
int i = 0;
|
||||
|
||||
for (sect = abfd->sections; sect != NULL; i++, sect = sect->next)
|
||||
(*operation) (abfd, sect, user_storage);
|
||||
|
||||
if (i != abfd->section_count) /* Debugging */
|
||||
abort();
|
||||
}
|
||||
|
||||
boolean
|
||||
bfd_set_section_flags (abfd, section, flags)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
flagword flags;
|
||||
{
|
||||
if ((flags & bfd_applicable_section_flags (abfd)) != flags) {
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
section->flags = flags;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
boolean
|
||||
bfd_set_section_size (abfd, ptr, val)
|
||||
bfd *abfd;
|
||||
sec_ptr ptr;
|
||||
unsigned long val;
|
||||
{
|
||||
/* Once you've started writing to any section you cannot create or change
|
||||
the size of any others. */
|
||||
|
||||
if (abfd->output_has_begun) {
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
ptr->size = val;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean
|
||||
bfd_set_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
void *location;
|
||||
file_ptr offset;
|
||||
int count;
|
||||
{
|
||||
if (!(bfd_get_section_flags(abfd, section) &
|
||||
SEC_HAS_CONTENTS)) {
|
||||
bfd_error = no_contents;
|
||||
return(false);
|
||||
} /* if section has no contents */
|
||||
|
||||
if (BFD_SEND (abfd, _bfd_set_section_contents,
|
||||
(abfd, section, location, offset, count))) {
|
||||
abfd->output_has_begun = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean
|
||||
bfd_get_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
void *location;
|
||||
file_ptr offset;
|
||||
int count;
|
||||
{
|
||||
if (section->flags & SEC_CONSTRUCTOR) {
|
||||
memset(location, 0, count);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return (BFD_SEND (abfd, _bfd_get_section_contents,
|
||||
(abfd, section, location, offset, count)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Some core file info commands */
|
||||
|
||||
/* Returns a read-only string explaining what program was running when
|
||||
it failed. */
|
||||
|
||||
char *
|
||||
bfd_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (abfd->format != bfd_core) {
|
||||
bfd_error = invalid_operation;
|
||||
return NULL;
|
||||
}
|
||||
return BFD_SEND (abfd, _core_file_failing_command, (abfd));
|
||||
}
|
||||
|
||||
int
|
||||
bfd_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (abfd->format != bfd_core) {
|
||||
bfd_error = invalid_operation;
|
||||
return NULL;
|
||||
}
|
||||
return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
|
||||
}
|
||||
|
||||
boolean
|
||||
core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd, *exec_bfd;
|
||||
{
|
||||
if ((core_bfd->format != bfd_core) || (exec_bfd->format != bfd_object)) {
|
||||
bfd_error = wrong_format;
|
||||
return false;
|
||||
}
|
||||
|
||||
return BFD_SEND (core_bfd, _core_file_matches_executable_p, (core_bfd, exec_bfd));
|
||||
}
|
||||
|
||||
/** Symbols */
|
||||
|
||||
boolean
|
||||
bfd_set_symtab (abfd, location, symcount)
|
||||
bfd *abfd;
|
||||
asymbol **location;
|
||||
unsigned int symcount;
|
||||
{
|
||||
if ((abfd->format != bfd_object) || (bfd_read_p (abfd))) {
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
bfd_get_outsymbols (abfd) = location;
|
||||
bfd_get_symcount (abfd) = symcount;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* returns the number of octets of storage required */
|
||||
unsigned int
|
||||
get_reloc_upper_bound (abfd, asect)
|
||||
bfd *abfd;
|
||||
sec_ptr asect;
|
||||
{
|
||||
if (abfd->format != bfd_object) {
|
||||
bfd_error = invalid_operation;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return BFD_SEND (abfd, _get_reloc_upper_bound, (abfd, asect));
|
||||
}
|
||||
|
||||
unsigned int
|
||||
bfd_canonicalize_reloc (abfd, asect, location, symbols)
|
||||
bfd *abfd;
|
||||
sec_ptr asect;
|
||||
arelent **location;
|
||||
asymbol **symbols;
|
||||
{
|
||||
if (abfd->format != bfd_object) {
|
||||
bfd_error = invalid_operation;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return BFD_SEND (abfd, _bfd_canonicalize_reloc, (abfd, asect, location, symbols));
|
||||
}
|
||||
|
||||
void
|
||||
bfd_print_symbol_vandf(file, symbol)
|
||||
void *file;
|
||||
asymbol *symbol;
|
||||
{
|
||||
flagword type = symbol->flags;
|
||||
if (symbol->section != (asection *)NULL)
|
||||
{
|
||||
fprintf(file,"%08lx ", symbol->value+symbol->section->vma);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(file,"%08lx ", symbol->value);
|
||||
}
|
||||
fprintf(file,"%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_DEBUGGING) ? 'd' :' ');
|
||||
|
||||
}
|
||||
|
||||
|
||||
boolean
|
||||
bfd_set_file_flags (abfd, flags)
|
||||
bfd *abfd;
|
||||
flagword flags;
|
||||
{
|
||||
if (abfd->format != bfd_object) {
|
||||
bfd_error = wrong_format;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bfd_read_p (abfd)) {
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((flags & bfd_applicable_file_flags (abfd)) != flags) {
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
bfd_get_file_flags (abfd) = flags;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bfd_set_reloc (ignore_abfd, asect, location, count)
|
||||
bfd *ignore_abfd;
|
||||
sec_ptr asect;
|
||||
arelent **location;
|
||||
unsigned int count;
|
||||
{
|
||||
asect->orelocation = location;
|
||||
asect->reloc_count = count;
|
||||
}
|
||||
/*
|
||||
If an output_bfd is supplied to this function the generated image
|
||||
will be relocatable, the relocations are copied to the output file
|
||||
after they have been changed to reflect the new state of the world.
|
||||
There are two ways of reflecting the results of partial linkage in an
|
||||
output file; by modifying the output data in place, and by modifying
|
||||
the relocation record. Some native formats (eg basic a.out and basic
|
||||
coff) have no way of specifying an addend in the relocation type, so
|
||||
the addend has to go in the output data. This is no big deal since in
|
||||
these formats the output data slot will always be big enough for the
|
||||
addend. Complex reloc types with addends were invented to solve just
|
||||
this problem.
|
||||
*/
|
||||
|
||||
bfd_reloc_status_enum_type
|
||||
bfd_perform_relocation(abfd,
|
||||
reloc_entry,
|
||||
data,
|
||||
input_section,
|
||||
output_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
void *data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
bfd_reloc_status_enum_type flag = bfd_reloc_ok;
|
||||
bfd_vma relocation_before;
|
||||
bfd_vma mask;
|
||||
bfd_vma target_mask;
|
||||
bfd_vma addr = reloc_entry->address ;
|
||||
bfd_vma output_base = 0;
|
||||
struct rint_struct *howto = reloc_entry->howto;
|
||||
asection *reloc_target_output_section;
|
||||
asection *reloc_target_input_section;
|
||||
asymbol *symbol;
|
||||
|
||||
if (reloc_entry->sym_ptr_ptr) {
|
||||
symbol = *( reloc_entry->sym_ptr_ptr);
|
||||
if ((symbol->flags & BSF_UNDEFINED) && output_bfd == (bfd *)NULL) {
|
||||
flag = bfd_reloc_undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
symbol = (asymbol*)NULL;
|
||||
}
|
||||
|
||||
if (howto->special_function) {
|
||||
bfd_reloc_status_enum_type cont;
|
||||
cont = howto->special_function(abfd,
|
||||
reloc_entry,
|
||||
symbol,
|
||||
data,
|
||||
input_section);
|
||||
if (cont != bfd_reloc_continue) return cont;
|
||||
}
|
||||
|
||||
/*
|
||||
Work out which section the relocation is targetted at and the
|
||||
initial relocation command value.
|
||||
*/
|
||||
|
||||
|
||||
if (symbol != (asymbol *)NULL){
|
||||
if (symbol->flags & BSF_FORT_COMM) {
|
||||
relocation = 0;
|
||||
}
|
||||
else {
|
||||
relocation = symbol->value;
|
||||
}
|
||||
if (symbol->section != (asection *)NULL)
|
||||
{
|
||||
reloc_target_input_section = symbol->section;
|
||||
}
|
||||
else {
|
||||
reloc_target_input_section = (asection *)NULL;
|
||||
}
|
||||
}
|
||||
else if (reloc_entry->section != (asection *)NULL)
|
||||
{
|
||||
relocation = 0;
|
||||
reloc_target_input_section = reloc_entry->section;
|
||||
}
|
||||
else {
|
||||
relocation = 0;
|
||||
reloc_target_input_section = (asection *)NULL;
|
||||
}
|
||||
|
||||
|
||||
if (reloc_target_input_section != (asection *)NULL) {
|
||||
|
||||
reloc_target_output_section =
|
||||
reloc_target_input_section->output_section;
|
||||
|
||||
if (output_bfd && howto->partial_inplace==false) {
|
||||
output_base = 0;
|
||||
}
|
||||
else {
|
||||
output_base = reloc_target_output_section->vma;
|
||||
|
||||
}
|
||||
|
||||
relocation += output_base + reloc_target_input_section->output_offset;
|
||||
}
|
||||
|
||||
relocation += reloc_entry->addend ;
|
||||
|
||||
|
||||
if(reloc_entry->address > (bfd_vma)(input_section->size))
|
||||
{
|
||||
return bfd_reloc_outofrange;
|
||||
}
|
||||
|
||||
|
||||
if (howto->pc_relative == true)
|
||||
{
|
||||
/*
|
||||
Anything which started out as pc relative should end up that
|
||||
way too
|
||||
*/
|
||||
|
||||
relocation -=
|
||||
output_base + input_section->output_offset;
|
||||
|
||||
}
|
||||
|
||||
if (output_bfd!= (bfd *)NULL && howto->partial_inplace == false) {
|
||||
/*
|
||||
This is a partial relocation, and we want to apply the relocation
|
||||
to the reloc entry rather than the raw data. Modify the reloc
|
||||
inplace to reflect what we now know.
|
||||
*/
|
||||
reloc_entry->addend = relocation ;
|
||||
reloc_entry->section = reloc_target_input_section;
|
||||
if (reloc_target_input_section != (asection *)NULL) {
|
||||
/* If we know the output section we can forget the symbol */
|
||||
reloc_entry->sym_ptr_ptr = (asymbol**)NULL;
|
||||
}
|
||||
reloc_entry->address +=
|
||||
input_section->output_offset;
|
||||
}
|
||||
else {
|
||||
reloc_entry->addend = 0;
|
||||
|
||||
|
||||
/*
|
||||
Either we are relocating all the way, or we don't want to apply
|
||||
the relocation to the reloc entry (probably because there isn't
|
||||
any room in the output format to describe addends to relocs)
|
||||
*/
|
||||
relocation >>= howto->rightshift;
|
||||
if (howto->bitsize == 32) {
|
||||
mask = ~0;
|
||||
}
|
||||
else {
|
||||
mask = (1L << howto->bitsize) - 1 ;
|
||||
mask |= mask - 1; /* FIXME, what is this? */
|
||||
}
|
||||
|
||||
relocation &= mask;
|
||||
|
||||
/* Shift everything up to where it's going to be used */
|
||||
|
||||
relocation <<= howto->bitpos;
|
||||
mask <<= howto->bitpos;
|
||||
target_mask = ~mask;
|
||||
|
||||
/* Wait for the day when all have the mask in them */
|
||||
|
||||
BFD_ASSERT(howto->mask == mask);
|
||||
|
||||
|
||||
|
||||
relocation_before = relocation;
|
||||
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_getchar(abfd, (char *)data + addr);
|
||||
relocation += x & mask;
|
||||
bfd_putchar(abfd,
|
||||
( x & target_mask) | ( relocation & mask),
|
||||
(unsigned char *) data + addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_getshort(abfd, (bfd_byte *)data + addr);
|
||||
relocation += x & mask;
|
||||
bfd_putshort(abfd, ( x & target_mask) | (relocation & mask),
|
||||
(unsigned char *)data + addr);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_getlong(abfd, (bfd_byte *) data + addr);
|
||||
relocation += x & mask;
|
||||
bfd_putlong(abfd, ( x & target_mask) | (relocation & mask),
|
||||
(bfd_byte *)data + addr);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* Do nothing */
|
||||
break;
|
||||
default:
|
||||
return bfd_reloc_other;
|
||||
}
|
||||
|
||||
/* See if important parts of the relocation were chopped to make
|
||||
it fit into the relocation field. (ie are there any significant
|
||||
bits left over after the masking ? */
|
||||
if ((relocation_before & target_mask) != 0 &&
|
||||
howto->complain_on_overflow == true)
|
||||
{
|
||||
/* Its ok if the bit which fell off is */
|
||||
return bfd_reloc_overflow;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
void
|
||||
bfd_assert(file, line)
|
||||
char *file;
|
||||
int line;
|
||||
{
|
||||
printf("bfd assertion fail %s:%d\n",file,line);
|
||||
}
|
||||
|
||||
|
||||
boolean
|
||||
bfd_set_start_address(abfd, vma)
|
||||
bfd *abfd;
|
||||
bfd_vma vma;
|
||||
{
|
||||
abfd->start_address = vma;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bfd_vma bfd_log2(x)
|
||||
bfd_vma x;
|
||||
{
|
||||
bfd_vma result = 0;
|
||||
while ( (bfd_vma)(1<< result) < x)
|
||||
result++;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* bfd_get_mtime: 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. */
|
||||
|
||||
long
|
||||
bfd_get_mtime (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
FILE *fp;
|
||||
struct stat buf;
|
||||
|
||||
if (abfd->mtime_set)
|
||||
return abfd->mtime;
|
||||
|
||||
fp = bfd_cache_lookup (abfd);
|
||||
if (0 != fstat (fileno (fp), &buf))
|
||||
return 0;
|
||||
|
||||
abfd->mtime_set = true;
|
||||
abfd->mtime = buf.st_mtime;
|
||||
return abfd->mtime;
|
||||
}
|
200
bfd/cache.c
Normal file
200
bfd/cache.c
Normal file
@ -0,0 +1,200 @@
|
||||
/*** cache.c -- Allows you to have more bfds open than your system has fds. */
|
||||
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/* These declarations should not be needed; libbfd.h's inclusion should
|
||||
have handled it.
|
||||
int fclose();
|
||||
int fseek();
|
||||
*/
|
||||
|
||||
|
||||
/* The maximum number of FDs opened by bfd */
|
||||
#define BFD_CACHE_MAX_OPEN 10
|
||||
|
||||
/* when this exceeds BFD_CACHE_MAX_OPEN, we get to work */
|
||||
static int open_files;
|
||||
|
||||
static bfd *cache_sentinel; /* Chain of bfds with active fds we've
|
||||
opened */
|
||||
static void
|
||||
bfd_cache_delete();
|
||||
|
||||
bfd *bfd_last_cache;
|
||||
|
||||
|
||||
static void
|
||||
close_one()
|
||||
{
|
||||
bfd *kill = cache_sentinel;
|
||||
if (kill == 0) /* Nothing in the cache */
|
||||
return ;
|
||||
|
||||
/* We can only close files that want to play this game. */
|
||||
while (!kill->cacheable) {
|
||||
kill = kill->lru_prev;
|
||||
if (kill == cache_sentinel) /* Nobody wants to play */
|
||||
return ;
|
||||
}
|
||||
|
||||
kill->where = ftell((FILE *)(kill->iostream));
|
||||
bfd_cache_delete(kill);
|
||||
|
||||
}
|
||||
/* Cuts the bfd abfd out of the chain in the cache */
|
||||
static void
|
||||
snip (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
abfd->lru_prev->lru_next = abfd->lru_next;
|
||||
abfd->lru_next->lru_prev = abfd->lru_prev;
|
||||
if (cache_sentinel == abfd) cache_sentinel = (bfd *)NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
bfd_cache_delete (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
fclose ((FILE *)(abfd->iostream));
|
||||
snip (abfd);
|
||||
abfd->iostream = NULL;
|
||||
open_files--;
|
||||
}
|
||||
|
||||
static bfd *
|
||||
insert(x,y)
|
||||
bfd *x;
|
||||
bfd *y;
|
||||
{
|
||||
if (y) {
|
||||
x->lru_next = y;
|
||||
x->lru_prev = y->lru_prev;
|
||||
y->lru_prev->lru_next = x;
|
||||
y->lru_prev = x;
|
||||
|
||||
}
|
||||
else {
|
||||
x->lru_prev = x;
|
||||
x->lru_next = x;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize a BFD by putting it on the cache LRU. */
|
||||
void
|
||||
bfd_cache_init(abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
cache_sentinel = insert(abfd, cache_sentinel);
|
||||
}
|
||||
|
||||
void
|
||||
bfd_cache_close(abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
/* If this file is open then remove from the chain */
|
||||
if (abfd->iostream)
|
||||
{
|
||||
bfd_cache_delete(abfd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Call the OS to open a file for this BFD. Returns the FILE *
|
||||
(possibly null) that results from this operation. Sets up the
|
||||
BFD so that future accesses know the file is open. */
|
||||
|
||||
FILE *
|
||||
bfd_open_file (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
abfd->cacheable = true; /* Allow it to be closed later. */
|
||||
if(open_files >= BFD_CACHE_MAX_OPEN) {
|
||||
close_one();
|
||||
}
|
||||
switch (abfd->direction) {
|
||||
case read_direction:
|
||||
case no_direction:
|
||||
abfd->iostream = (char *) fopen(abfd->filename, "r");
|
||||
break;
|
||||
case both_direction:
|
||||
case write_direction:
|
||||
if (abfd->opened_once == true) {
|
||||
abfd->iostream = (char *) fopen(abfd->filename, "r+");
|
||||
if (!abfd->iostream) {
|
||||
abfd->iostream = (char *) fopen(abfd->filename, "w+");
|
||||
}
|
||||
} else {
|
||||
/*open for creat */
|
||||
abfd->iostream = (char *) fopen(abfd->filename, "w");
|
||||
abfd->opened_once = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (abfd->iostream) {
|
||||
open_files++;
|
||||
bfd_cache_init (abfd);
|
||||
}
|
||||
|
||||
return (FILE *)(abfd->iostream);
|
||||
}
|
||||
|
||||
/* Find a file descriptor for this BFD. If necessary, open it.
|
||||
If there are already more than BFD_CACHE_MAX_OPEN files open, try to close
|
||||
one first, to avoid running out of file descriptors. */
|
||||
|
||||
FILE *
|
||||
bfd_cache_lookup_worker (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (abfd->my_archive)
|
||||
{
|
||||
abfd = abfd->my_archive;
|
||||
}
|
||||
/* Is this file already open .. if so then quick exit */
|
||||
if (abfd->iostream)
|
||||
{
|
||||
if (abfd != cache_sentinel) {
|
||||
/* Place onto head of lru chain */
|
||||
snip (abfd);
|
||||
cache_sentinel = insert(abfd, cache_sentinel);
|
||||
}
|
||||
}
|
||||
/* This is a bfd without a stream -
|
||||
so it must have been closed or never opened.
|
||||
find an empty cache entry and use it. */
|
||||
else
|
||||
{
|
||||
|
||||
if (open_files >= BFD_CACHE_MAX_OPEN)
|
||||
{
|
||||
close_one();
|
||||
}
|
||||
|
||||
BFD_ASSERT(bfd_open_file (abfd) != (FILE *)NULL) ;
|
||||
fseek((FILE *)(abfd->iostream), abfd->where, false);
|
||||
}
|
||||
bfd_last_cache = abfd;
|
||||
return (FILE *)(abfd->iostream);
|
||||
}
|
2561
bfd/coff-code.h
Executable file
2561
bfd/coff-code.h
Executable file
File diff suppressed because it is too large
Load Diff
270
bfd/coff-i960.c
Normal file
270
bfd/coff-i960.c
Normal file
@ -0,0 +1,270 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#define I960 1
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "libcoff.h" /* to allow easier abstraction-breaking */
|
||||
|
||||
|
||||
|
||||
#include "intel-coff.h"
|
||||
|
||||
#define CALLS 0x66003800 /* Template for 'calls' instruction */
|
||||
#define BAL 0x0b000000 /* Template for 'bal' instruction */
|
||||
#define BAL_MASK 0x00ffffff
|
||||
|
||||
static bfd_reloc_status_enum_type
|
||||
optcall_callback(abfd, reloc_entry, symbol_in, data, ignore_input_section)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol_in;
|
||||
unsigned char *data;
|
||||
asection *ignore_input_section;
|
||||
{
|
||||
/* This item has already been relocated correctly, but we may be
|
||||
* able to patch in yet better code - done by digging out the
|
||||
* correct info on this symbol */
|
||||
bfd_reloc_status_enum_type result;
|
||||
coff_symbol_type *cs = coffsymbol(symbol_in);
|
||||
|
||||
/* So the target symbol has to be off coff type, and the symbol
|
||||
has to have the correct native information within it
|
||||
*/
|
||||
if ((cs->symbol.the_bfd->xvec->flavour != bfd_target_coff_flavour_enum)
|
||||
|| (cs->native == (struct syment *)NULL)) {
|
||||
/* This is interesting, consider the case where we're outputting */
|
||||
/* coff from a mix n match input, linking from coff to a symbol */
|
||||
/* defined in a bout file will cause this match to be true. Should */
|
||||
/* I complain ? - This will only work if the bout symbol is non */
|
||||
/* leaf. */
|
||||
result = bfd_reloc_dangerous;
|
||||
|
||||
}
|
||||
else {
|
||||
switch (cs->native->n_sclass)
|
||||
{
|
||||
case C_LEAFSTAT:
|
||||
case C_LEAFEXT:
|
||||
/* This is a call to a leaf procedure, replace instruction with a bal
|
||||
to the correct location */
|
||||
{
|
||||
union auxent *aux = (union auxent *)(cs->native+2);
|
||||
int word = bfd_getlong(abfd, data + reloc_entry->address);
|
||||
BFD_ASSERT(cs->native->n_numaux==2);
|
||||
/* We replace the original call instruction with a bal to */
|
||||
/* the bal entry point - the offset of which is described in the */
|
||||
/* 2nd auxent of the original symbol. We keep the native sym and */
|
||||
/* auxents untouched, so the delta between the two is the */
|
||||
/* offset of the bal entry point */
|
||||
word = ((word + (aux->x_bal.x_balntry - cs->native->n_value))
|
||||
& BAL_MASK) | BAL;
|
||||
bfd_putlong(abfd, word, data+reloc_entry->address);
|
||||
}
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
case C_SCALL:
|
||||
{
|
||||
/* This is a call to a system call, replace with a calls to # */
|
||||
BFD_ASSERT(0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{0},
|
||||
{1},
|
||||
{2},
|
||||
{3},
|
||||
{4},
|
||||
{5},
|
||||
{6},
|
||||
{7},
|
||||
{8},
|
||||
{9},
|
||||
{10},
|
||||
{11},
|
||||
{12},
|
||||
{13},
|
||||
{14},
|
||||
{15},
|
||||
{16},
|
||||
|
||||
{ (unsigned int) R_RELLONG, 0, 2, 32,false, 0, true, true, 0,"rellong", true, 0xffffffff},
|
||||
{18},
|
||||
{19},
|
||||
{20},
|
||||
{21},
|
||||
{22},
|
||||
{23},
|
||||
{24},
|
||||
|
||||
{ R_IPRMED, 0, 2, 24,true,0, true, true,0,"iprmed ", true, 0x00ffffff},
|
||||
{26},
|
||||
|
||||
{ R_OPTCALL, 0,2,24,true,0, true, true, optcall_callback, "optcall", true, 0x00ffffff},
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define BADMAG(x) I960BADMAG(x)
|
||||
#include "coff-code.h"
|
||||
|
||||
|
||||
|
||||
bfd_target icoff_big_vec =
|
||||
{
|
||||
"coff-Intel-big", /* name */
|
||||
bfd_target_coff_flavour_enum,
|
||||
false, /* data byte order is little */
|
||||
true, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* valid reloc types */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
coff_close_and_cleanup, /* _close_and_cleanup */
|
||||
coff_set_section_contents, /* bfd_set_section_contents */
|
||||
coff_get_section_contents, /* bfd_get_section_contents */
|
||||
coff_new_section_hook, /* new_section_hook */
|
||||
_bfd_dummy_core_file_failing_command, /* _core_file_failing_command */
|
||||
_bfd_dummy_core_file_failing_signal, /* _core_file_failing_signal */
|
||||
_bfd_dummy_core_file_matches_executable_p, /* _core_file_matches_ex...p */
|
||||
|
||||
bfd_slurp_coff_armap, /* bfd_slurp_armap */
|
||||
_bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
|
||||
#if 0 /* */
|
||||
bfd_dont_truncate_arname, /* bfd_truncate_arname */
|
||||
#else
|
||||
bfd_bsd_truncate_arname,
|
||||
#endif
|
||||
|
||||
coff_get_symtab_upper_bound, /* get_symtab_upper_bound */
|
||||
coff_get_symtab, /* canonicalize_symtab */
|
||||
(void (*)())bfd_false, /* bfd_reclaim_symbol_table */
|
||||
coff_get_reloc_upper_bound, /* get_reloc_upper_bound */
|
||||
coff_canonicalize_reloc, /* bfd_canonicalize_reloc */
|
||||
(void (*)())bfd_false, /* bfd_reclaim_reloc */
|
||||
|
||||
coff_get_symcount_upper_bound, /* bfd_get_symcount_upper_bound */
|
||||
coff_get_first_symbol, /* bfd_get_first_symbol */
|
||||
coff_get_next_symbol, /* bfd_get_next_symbol */
|
||||
coff_classify_symbol, /* bfd_classify_symbol */
|
||||
coff_symbol_hasclass, /* bfd_symbol_hasclass */
|
||||
coff_symbol_name, /* bfd_symbol_name */
|
||||
coff_symbol_value, /* bfd_symbol_value */
|
||||
|
||||
_do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
|
||||
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
coff_make_empty_symbol,
|
||||
coff_print_symbol,
|
||||
coff_get_lineno,
|
||||
coff_set_arch_mach,
|
||||
coff_write_armap,
|
||||
bfd_generic_openr_next_archived_file,
|
||||
coff_find_nearest_line,
|
||||
bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */
|
||||
};
|
||||
|
||||
|
||||
|
||||
bfd_target icoff_little_vec =
|
||||
{
|
||||
"coff-Intel-little", /* name */
|
||||
bfd_target_coff_flavour_enum,
|
||||
false, /* data byte order is little */
|
||||
false, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* valid reloc types */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
coff_close_and_cleanup, /* _close_and_cleanup */
|
||||
coff_set_section_contents, /* bfd_set_section_contents */
|
||||
coff_get_section_contents, /* bfd_get_section_contents */
|
||||
coff_new_section_hook, /* new_section_hook */
|
||||
_bfd_dummy_core_file_failing_command, /* _core_file_failing_command */
|
||||
_bfd_dummy_core_file_failing_signal, /* _core_file_failing_signal */
|
||||
_bfd_dummy_core_file_matches_executable_p, /* _core_file_matches_ex...p */
|
||||
|
||||
bfd_slurp_coff_armap, /* bfd_slurp_armap */
|
||||
_bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
|
||||
#if 0 /* */
|
||||
bfd_dont_truncate_arname, /* bfd_truncate_arname */
|
||||
#else
|
||||
bfd_bsd_truncate_arname,
|
||||
#endif
|
||||
coff_get_symtab_upper_bound, /* get_symtab_upper_bound */
|
||||
coff_get_symtab, /* canonicalize_symtab */
|
||||
(void (*)())bfd_false, /* bfd_reclaim_symbol_table */
|
||||
coff_get_reloc_upper_bound, /* get_reloc_upper_bound */
|
||||
coff_canonicalize_reloc, /* bfd_canonicalize_reloc */
|
||||
(void (*)())bfd_false, /* bfd_reclaim_reloc */
|
||||
|
||||
coff_get_symcount_upper_bound, /* bfd_get_symcount_upper_bound */
|
||||
coff_get_first_symbol, /* bfd_get_first_symbol */
|
||||
coff_get_next_symbol, /* bfd_get_next_symbol */
|
||||
coff_classify_symbol, /* bfd_classify_symbol */
|
||||
coff_symbol_hasclass, /* bfd_symbol_hasclass */
|
||||
coff_symbol_name, /* bfd_symbol_name */
|
||||
coff_symbol_value, /* bfd_symbol_value */
|
||||
|
||||
_do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
|
||||
_do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
coff_make_empty_symbol,
|
||||
coff_print_symbol,
|
||||
coff_get_lineno,
|
||||
coff_set_arch_mach,
|
||||
coff_write_armap,
|
||||
bfd_generic_openr_next_archived_file,
|
||||
coff_find_nearest_line,
|
||||
bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */
|
||||
};
|
||||
|
||||
|
80
bfd/libaout.h
Normal file
80
bfd/libaout.h
Normal file
@ -0,0 +1,80 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* BFD back-end data structures for a.out (and similar) files.
|
||||
|
||||
We try to encapsulate the differences in a few routines, and otherwise
|
||||
share large masses of code. This means we only have to fix bugs in
|
||||
one place, most of the time. */
|
||||
|
||||
/** a.out files */
|
||||
|
||||
#define exec_hdr(bfd) (((struct sunexdata *) ((bfd)->tdata))->hdr)
|
||||
/*#define obj_symbols(bfd) ((((struct sunexdata *) ((bfd)->tdata))->symbols))*/
|
||||
#define obj_textsec(bfd) (((struct sunexdata *) ((bfd)->tdata))->textsec)
|
||||
#define obj_datasec(bfd) (((struct sunexdata *) ((bfd)->tdata))->datasec)
|
||||
#define obj_bsssec(bfd) (((struct sunexdata *) ((bfd)->tdata))->bsssec)
|
||||
#define obj_sym_filepos(bfd) (((struct sunexdata *) ((bfd)->tdata))->sym_filepos)
|
||||
#define obj_str_filepos(bfd) (((struct sunexdata *) ((bfd)->tdata))->str_filepos)
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
asymbol symbol;
|
||||
short desc;
|
||||
char other;
|
||||
unsigned char type;
|
||||
} aout_symbol_type;
|
||||
|
||||
|
||||
struct sunexdata {
|
||||
struct exec *hdr; /* exec file header */
|
||||
aout_symbol_type *symbols; /* symtab for input bfd */
|
||||
|
||||
|
||||
/* For ease, we do this */
|
||||
asection *textsec;
|
||||
asection *datasec;
|
||||
asection *bsssec;
|
||||
|
||||
/* We remember these offsets so that after check_file_format, we have
|
||||
no dependencies on the particular format of the exec_hdr. */
|
||||
file_ptr sym_filepos;
|
||||
file_ptr str_filepos;
|
||||
};
|
||||
|
||||
|
||||
#define obj_outsymbols(bfd) ((void *)(((struct sunexdata *) ((bfd)->tdata))->outsymbols))
|
||||
|
||||
|
||||
|
||||
/* We case the address of the first element of a asymbol to ensure that the
|
||||
* macro is only every applied to an asymbol
|
||||
*/
|
||||
#define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd))
|
||||
|
||||
/*#define obj_symbols(bfd) ((((struct sunexdata *) ((bfd)->tdata))->symbols))*/
|
||||
#define obj_aout_symbols(bfd) ((((struct sunexdata *) (bfd)->tdata))->symbols)
|
||||
#define obj_arch_flags(bfd) ((((struct sunexdata *) (bfd)->tdata))->arch_flags)
|
||||
|
||||
#define get_tdata(x) ((struct sunexdata *)((x)->tdata))
|
||||
#define set_tdata(x,y) ((x)->tdata = (void *) (y))
|
||||
|
||||
|
332
bfd/libbfd.c
Normal file
332
bfd/libbfd.c
Normal file
@ -0,0 +1,332 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/*** libbfd.c -- random bfd support routines used internally only. */
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
|
||||
/** Dummies for targets that don't want or need to implement
|
||||
certain operations */
|
||||
|
||||
boolean
|
||||
_bfd_dummy_new_section_hook (ignore, ignore_newsect)
|
||||
bfd *ignore;
|
||||
asection *ignore_newsect;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean
|
||||
bfd_false (ignore)
|
||||
bfd *ignore;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean
|
||||
bfd_true (ignore)
|
||||
bfd *ignore;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void *
|
||||
bfd_nullvoidptr(ignore)
|
||||
bfd *ignore;
|
||||
{
|
||||
return (void *)NULL;
|
||||
}
|
||||
int
|
||||
bfd_0(ignore)
|
||||
bfd *ignore;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
unsigned int
|
||||
bfd_0u(ignore)
|
||||
bfd *ignore;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
bfd_void(ignore)
|
||||
bfd *ignore;
|
||||
{
|
||||
}
|
||||
|
||||
boolean
|
||||
_bfd_dummy_core_file_matches_executable_p (ignore_core_bfd, ignore_exec_bfd)
|
||||
bfd *ignore_core_bfd;
|
||||
bfd *ignore_exec_bfd;
|
||||
{
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* of course you can't initialize a function to be the same as another, grr */
|
||||
|
||||
char *
|
||||
_bfd_dummy_core_file_failing_command (ignore_abfd)
|
||||
bfd *ignore_abfd;
|
||||
{
|
||||
return (char *)NULL;
|
||||
}
|
||||
|
||||
int
|
||||
_bfd_dummy_core_file_failing_signal (ignore_abfd)
|
||||
bfd *ignore_abfd;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bfd_target *
|
||||
_bfd_dummy_target (ignore_abfd)
|
||||
bfd *ignore_abfd;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** zalloc -- allocate and clear storage */
|
||||
|
||||
|
||||
#ifndef zalloc
|
||||
char *
|
||||
zalloc (size)
|
||||
size_t size;
|
||||
{
|
||||
char *ptr = malloc (size);
|
||||
|
||||
if ((ptr != NULL) && (size != 0))
|
||||
bzero (ptr, size);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Some IO code */
|
||||
|
||||
|
||||
/* Note that archive entries don't have streams; they share their parent's.
|
||||
This allows someone to play with the iostream behind bfd's back.
|
||||
|
||||
Also, note that the origin pointer points to the beginning of a file's
|
||||
contents (0 for non-archive elements). For archive entries this is the
|
||||
first octet in the file, NOT the beginning of the archive header. */
|
||||
|
||||
size_t
|
||||
bfd_read (ptr, size, nitems, abfd)
|
||||
void *ptr;
|
||||
size_t size;
|
||||
size_t nitems;
|
||||
bfd *abfd;
|
||||
{
|
||||
return fread (ptr, 1, size*nitems, bfd_cache_lookup(abfd));
|
||||
}
|
||||
|
||||
size_t
|
||||
bfd_write (ptr, size, nitems, abfd)
|
||||
void *ptr;
|
||||
size_t size;
|
||||
size_t nitems;
|
||||
bfd *abfd;
|
||||
{
|
||||
return fwrite (ptr, 1, size*nitems, bfd_cache_lookup(abfd));
|
||||
}
|
||||
|
||||
int
|
||||
bfd_seek (abfd, position, direction)
|
||||
bfd *abfd;
|
||||
file_ptr position;
|
||||
int direction;
|
||||
{
|
||||
/* For the time being, a bfd may not seek to it's end. The
|
||||
problem is that we don't easily have a way to recognize
|
||||
the end of an element in an archive. */
|
||||
|
||||
BFD_ASSERT(direction == SEEK_SET
|
||||
|| direction == SEEK_CUR);
|
||||
|
||||
if (direction == SEEK_SET && abfd->my_archive != NULL)
|
||||
{
|
||||
/* This is a set within an archive, so we need to
|
||||
add the base of the object within the archive */
|
||||
return(fseek(bfd_cache_lookup(abfd),
|
||||
position + abfd->origin,
|
||||
direction));
|
||||
}
|
||||
else
|
||||
{
|
||||
return(fseek(bfd_cache_lookup(abfd), position, direction));
|
||||
}
|
||||
}
|
||||
|
||||
long
|
||||
bfd_tell (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
file_ptr ptr;
|
||||
|
||||
ptr = ftell (bfd_cache_lookup(abfd));
|
||||
|
||||
if (abfd->my_archive)
|
||||
ptr -= abfd->origin;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/** Make a string table */
|
||||
|
||||
/* Add string to table pointed to by table, at location starting with free_ptr.
|
||||
resizes the table if necessary (if it's NULL, creates it, ignoring
|
||||
table_length). Updates free_ptr, table, table_length */
|
||||
|
||||
boolean
|
||||
bfd_add_to_string_table (table, new_string, table_length, free_ptr)
|
||||
char **table, **free_ptr;
|
||||
char *new_string;
|
||||
unsigned int *table_length;
|
||||
{
|
||||
size_t string_length = strlen (new_string) + 1; /* include null here */
|
||||
char *base = *table;
|
||||
size_t space_length = *table_length;
|
||||
unsigned int offset = (base ? *free_ptr - base : 0);
|
||||
|
||||
if (base == NULL) {
|
||||
/* Avoid a useless regrow if we can (but of course we still
|
||||
take it next time */
|
||||
space_length = (string_length < DEFAULT_STRING_SPACE_SIZE ?
|
||||
DEFAULT_STRING_SPACE_SIZE : string_length+1);
|
||||
base = zalloc (space_length);
|
||||
|
||||
if (base == NULL) {
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((size_t)(offset + string_length) >= space_length) {
|
||||
/* Make sure we will have enough space */
|
||||
while ((size_t)(offset + string_length) >= space_length)
|
||||
space_length += space_length/2; /* grow by 50% */
|
||||
|
||||
base = (char *) realloc (base, space_length);
|
||||
if (base == NULL) {
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
memcpy (base + offset, new_string, string_length);
|
||||
*table = base;
|
||||
*table_length = space_length;
|
||||
*free_ptr = base + offset + string_length;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** The do-it-yourself (byte) sex-change kit */
|
||||
|
||||
/* The middle letter e.g. get<b>short indicates Big or Little endian
|
||||
target machine. It doesn't matter what the byte order of the host
|
||||
machine is; these routines work for either. */
|
||||
|
||||
/* FIXME: Should these take a count argument?
|
||||
Answer (gnu@cygnus.com): No, but perhaps they should be inline
|
||||
functions in swap.h #ifdef __GNUC__.
|
||||
Gprof them later and find out. */
|
||||
|
||||
short
|
||||
_do_getbshort (addr)
|
||||
register bfd_byte *addr;
|
||||
{
|
||||
return (addr[0] << 8) | addr[1];
|
||||
}
|
||||
|
||||
short
|
||||
_do_getlshort (addr)
|
||||
register bfd_byte *addr;
|
||||
{
|
||||
return (addr[1] << 8) | addr[0];
|
||||
}
|
||||
|
||||
void
|
||||
_do_putbshort (data, addr)
|
||||
int data; /* Actually short, but ansi C sucks */
|
||||
register bfd_byte *addr;
|
||||
{
|
||||
addr[0] = (bfd_byte)(data >> 8);
|
||||
addr[1] = (bfd_byte )data;
|
||||
}
|
||||
|
||||
void
|
||||
_do_putlshort (data, addr)
|
||||
int data; /* Actually short, but ansi C sucks */
|
||||
register bfd_byte *addr;
|
||||
{
|
||||
addr[0] = (bfd_byte )data;
|
||||
addr[1] = (bfd_byte)(data >> 8);
|
||||
}
|
||||
|
||||
long
|
||||
_do_getblong (addr)
|
||||
register bfd_byte *addr;
|
||||
{
|
||||
return ((((addr[0] << 8) | addr[1]) << 8) | addr[2]) << 8 | addr[3];
|
||||
}
|
||||
|
||||
long
|
||||
_do_getllong (addr)
|
||||
register bfd_byte *addr;
|
||||
{
|
||||
return ((((addr[3] << 8) | addr[2]) << 8) | addr[1]) << 8 | addr[0];
|
||||
}
|
||||
|
||||
void
|
||||
_do_putblong (data, addr)
|
||||
unsigned long data;
|
||||
register bfd_byte *addr;
|
||||
{
|
||||
addr[0] = (bfd_byte)(data >> 24);
|
||||
addr[1] = (bfd_byte)(data >> 16);
|
||||
addr[2] = (bfd_byte)(data >> 8);
|
||||
addr[3] = (bfd_byte)data;
|
||||
}
|
||||
|
||||
void
|
||||
_do_putllong (data, addr)
|
||||
unsigned long data;
|
||||
register bfd_byte *addr;
|
||||
{
|
||||
addr[0] = (bfd_byte)data;
|
||||
addr[1] = (bfd_byte)(data >> 8);
|
||||
addr[2] = (bfd_byte)(data >> 16);
|
||||
addr[3] = (bfd_byte)(data >> 24);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
160
bfd/libbfd.h
Normal file
160
bfd/libbfd.h
Normal file
@ -0,0 +1,160 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/*** libbfd.h -- Declarations used by bfd library implementation.
|
||||
This include file is not for users of the library */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* If you want to read and write large blocks, you might want to do it
|
||||
in quanta of this amount */
|
||||
#define DEFAULT_BUFFERSIZE 8192
|
||||
|
||||
/* tdata for an archive. For an input archive cache
|
||||
needs to be free()'d. For an output archive, symdefs do.
|
||||
*/
|
||||
|
||||
struct artdata {
|
||||
file_ptr first_file_filepos;
|
||||
/* Speed up searching the armap */
|
||||
struct ar_cache *cache;
|
||||
bfd *archive_head; /* Only interesting in output routines */
|
||||
carsym *symdefs; /* the symdef entries */
|
||||
symindex symdef_count; /* how many there are */
|
||||
char *extended_names; /* clever intel extension */
|
||||
};
|
||||
|
||||
#define bfd_ardata(bfd) ((struct artdata *) ((bfd)->tdata))
|
||||
#define bfd_set_ardata(bfd, v) ((bfd)->tdata = (void *) (v))
|
||||
|
||||
/* Goes in bfd's arelt_data slot */
|
||||
struct areltdata {
|
||||
char * arch_header; /* it's actually a string */
|
||||
unsigned int parsed_size; /* octets of filesize not including ar_hdr */
|
||||
char *filename; /* null-terminated */
|
||||
};
|
||||
|
||||
#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
|
||||
|
||||
/* FIXME -- a lot of my code allocates a large block and subdivides it.
|
||||
This can't always work, because of alignment restrictions. We should change
|
||||
it before it becomes a problem -- Gumby */
|
||||
|
||||
PROTO (char *, zalloc, (size_t size));
|
||||
PROTO (char *, realloc, (char * ptr, size_t size));
|
||||
PROTO (bfd_target *, bfd_find_target, (char *target_name));
|
||||
PROTO (size_t, bfd_read, (void *ptr, size_t size, size_t nitems, bfd *abfd));
|
||||
PROTO (size_t, bfd_write, (void *ptr, size_t size, size_t nitems, bfd *abfd));
|
||||
|
||||
|
||||
|
||||
PROTO (FILE *, bfd_cache_lookup, (bfd *));
|
||||
PROTO (void, bfd_cache_close, (bfd *));
|
||||
PROTO (int, bfd_seek,(bfd*, file_ptr, int direction));
|
||||
PROTO (long, bfd_tell, (bfd *abfd));
|
||||
PROTO (bfd *, _bfd_create_empty_archive_element_shell, (bfd *obfd));
|
||||
PROTO (bfd *, look_for_bfd_in_cache, (bfd *arch_bfd, file_ptr index));
|
||||
PROTO (boolean, _bfd_generic_mkarchive, (bfd *abfd));
|
||||
PROTO (struct areltdata *, snarf_ar_hdr, (bfd *abfd));
|
||||
PROTO (bfd_target *, bfd_generic_archive_p, (bfd *abfd));
|
||||
PROTO (boolean, bfd_slurp_bsd_armap, (bfd *abfd));
|
||||
PROTO (boolean, bfd_slurp_coff_armap, (bfd *abfd));
|
||||
PROTO (boolean, _bfd_slurp_extended_name_table, (bfd *abfd));
|
||||
PROTO (boolean, _bfd_write_archive_contents, (bfd *abfd));
|
||||
PROTO (bfd *, new_bfd, ());
|
||||
|
||||
#define DEFAULT_STRING_SPACE_SIZE 0x2000
|
||||
PROTO (boolean, bfd_add_to_string_table, (char **table, char *new_string,
|
||||
unsigned int *table_length,
|
||||
char **free_ptr));
|
||||
|
||||
PROTO (long, _do_getblong, (unsigned char *addr));
|
||||
PROTO (long, _do_getllong, (unsigned char *addr));
|
||||
PROTO (short, _do_getbshort, (unsigned char *addr));
|
||||
PROTO (short, _do_getlshort, (unsigned char *addr));
|
||||
PROTO (void, _do_putblong, (unsigned long data, unsigned char *addr));
|
||||
PROTO (void, _do_putllong, (unsigned long data, unsigned char *addr));
|
||||
PROTO (void, _do_putbshort, (int data, unsigned char *addr));
|
||||
PROTO (void, _do_putlshort, (int data, unsigned char *addr));
|
||||
|
||||
PROTO (boolean, bfd_false, (bfd *ignore));
|
||||
PROTO (boolean, bfd_true, (bfd *ignore));
|
||||
PROTO (void *, bfd_nullvoidptr, (bfd *ignore));
|
||||
PROTO (int, bfd_0, (bfd *ignore));
|
||||
PROTO (unsigned int, bfd_0u, (bfd *ignore));
|
||||
PROTO (void, bfd_void, (bfd *ignore));
|
||||
|
||||
|
||||
PROTO (bfd *,new_bfd_contained_in,(bfd *));
|
||||
PROTO (boolean, _bfd_dummy_new_section_hook, (bfd *ignore, asection *newsect));
|
||||
PROTO (char *, _bfd_dummy_core_file_failing_command, (bfd *abfd));
|
||||
PROTO (int, _bfd_dummy_core_file_failing_signal, (bfd *abfd));
|
||||
PROTO (boolean, _bfd_dummy_core_file_matches_executable_p, (bfd *core_bfd,
|
||||
bfd *exec_bfd));
|
||||
PROTO (bfd_target *, _bfd_dummy_target, (bfd *abfd));
|
||||
|
||||
PROTO (void, bfd_dont_truncate_arname, (bfd *abfd, char *filename, char *hdr));
|
||||
PROTO (void, bfd_bsd_truncate_arname, (bfd *abfd, char *filename, char *hdr));
|
||||
PROTO (void, bfd_gnu_truncate_arname, (bfd *abfd, char *filename, char *hdr));
|
||||
|
||||
PROTO (boolean, bsd_write_armap, (bfd *arch, unsigned int elength,
|
||||
struct orl *map, int orl_count, int stridx));
|
||||
|
||||
PROTO (boolean, coff_write_armap, (bfd *arch, unsigned int elength,
|
||||
struct orl *map, int orl_count, int stridx));
|
||||
|
||||
PROTO ( bfd *,bfd_generic_openr_next_archived_file, (bfd *archive, bfd *last_file));
|
||||
|
||||
PROTO(int, bfd_generic_stat_arch_elt, (bfd *, struct stat *));
|
||||
/* Macros to tell if bfds are read or write enabled.
|
||||
|
||||
Note that bfds open for read may be scribbled into if the fd passed
|
||||
to bfd_fdopenr is actually open both for read and write
|
||||
simultaneously. However an output bfd will never be open for
|
||||
read. Therefore sometimes you want to check bfd_read_p or
|
||||
!bfd_read_p, and only sometimes bfd_write_p.
|
||||
*/
|
||||
|
||||
#define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
|
||||
#define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
|
||||
|
||||
PROTO (void, bfd_assert,(char*,int));
|
||||
#define BFD_ASSERT(x) \
|
||||
{ if (!(x)) bfd_assert(__FILE__,__LINE__); }
|
||||
|
||||
#define BFD_FAIL() \
|
||||
{ bfd_assert(__FILE__,__LINE__); }
|
||||
|
||||
PROTO (FILE *, bfd_cache_lookup_worker, (bfd *));
|
||||
|
||||
extern bfd *bfd_last_cache;
|
||||
#define bfd_cache_lookup(x) \
|
||||
(x==bfd_last_cache?(FILE*)(bfd_last_cache->iostream):bfd_cache_lookup_worker(x))
|
||||
|
||||
/* Now Steve, what's the story here? */
|
||||
#ifdef lint
|
||||
#define itos(x) "l"
|
||||
#define stoi(x) 1
|
||||
#else
|
||||
#define itos(x) ((char*)(x))
|
||||
#define stoi(x) ((int)(x))
|
||||
#endif
|
62
bfd/libcoff.h
Normal file
62
bfd/libcoff.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* BFD COFF object file private structure. */
|
||||
|
||||
/* Object file tdata; access macros */
|
||||
|
||||
#define obj_icof(bfd) ((struct icofdata *) ((bfd)->tdata))
|
||||
#define exec_hdr(bfd) (obj_icof(bfd)->hdr)
|
||||
#define obj_symbols(bfd) (obj_icof(bfd)->symbols)
|
||||
#define obj_sym_filepos(bfd) (obj_icof(bfd)->sym_filepos)
|
||||
|
||||
#define obj_relocbase(bfd) (obj_icof(bfd)->relocbase)
|
||||
#define obj_raw_syments(bfd) (obj_icof(bfd)->raw_syments)
|
||||
#define obj_convert(bfd) (obj_icof(bfd)->conversion_table)
|
||||
#define obj_symbol_slew(bfd) (obj_icof(bfd)->symbol_index_slew)
|
||||
#define obj_string_table(bfd) (obj_icof(bfd)->string_table)
|
||||
|
||||
typedef struct {
|
||||
asymbol symbol;
|
||||
struct syment *native;
|
||||
struct lineno_cache_entry *lineno;
|
||||
} coff_symbol_type;
|
||||
|
||||
struct icofdata {
|
||||
struct aouthdr *hdr; /* exec file header */
|
||||
coff_symbol_type *symbols; /* symtab for input bfd */
|
||||
unsigned int *conversion_table;
|
||||
file_ptr sym_filepos;
|
||||
|
||||
long symbol_index_slew; /* used during read to mark whether a
|
||||
C_FILE symbol as been added. */
|
||||
|
||||
struct syment *raw_syments;
|
||||
struct lineno *raw_linenos;
|
||||
unsigned int raw_syment_count;
|
||||
char *string_table;
|
||||
/* These are only valid once writing has begun */
|
||||
long int relocbase;
|
||||
|
||||
};
|
||||
|
||||
/* We cast the address of the first element of a asymbol to ensure that the
|
||||
* macro is only ever applied to an asymbol. */
|
||||
#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
|
98
bfd/misc.c
Executable file
98
bfd/misc.c
Executable file
@ -0,0 +1,98 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#if 0
|
||||
/* xoxorich. coelesced from other binutils. */
|
||||
/* This crap should all be bundled with the binutils, or else be in its
|
||||
own library, but for expediency we are doing it this way right now. */
|
||||
|
||||
/*
|
||||
* Last Mod Mon Feb 18 14:49:39 PST 1991, by rich@cygint.cygnus.com
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "misc.h"
|
||||
#if __STDC__
|
||||
extern char *realloc (char * ptr, int size);
|
||||
extern char *malloc (int size);
|
||||
#else
|
||||
extern char *realloc ();
|
||||
extern char *malloc ();
|
||||
#endif
|
||||
|
||||
/* Print the filename of the current file on 'outfile' (a stdio stream). */
|
||||
|
||||
/* Current file's name */
|
||||
|
||||
char *input_name;
|
||||
|
||||
/* Current member's name, or 0 if processing a non-library file. */
|
||||
|
||||
char *input_member;
|
||||
|
||||
void print_file_name (outfile)
|
||||
FILE *outfile;
|
||||
{
|
||||
fprintf (outfile, "%s", input_name);
|
||||
if (input_member)
|
||||
fprintf (outfile, "(%s)", input_member);
|
||||
}
|
||||
|
||||
/* process one input file */
|
||||
void scan_library ();
|
||||
|
||||
char *program_name;
|
||||
|
||||
/* Report a nonfatal error.
|
||||
STRING is a format for printf, and ARG1 ... ARG3 are args for it. */
|
||||
/*VARARGS*/
|
||||
void
|
||||
error (string, arg1, arg2, arg3)
|
||||
char *string, *arg1, *arg2, *arg3;
|
||||
{
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
fprintf (stderr, string, arg1, arg2, arg3);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Report a nonfatal error.
|
||||
STRING is printed, followed by the current file name. */
|
||||
|
||||
void
|
||||
error_with_file (string)
|
||||
char *string;
|
||||
{
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
print_file_name (stderr);
|
||||
fprintf (stderr, ": ");
|
||||
fprintf (stderr, string);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
/* Like malloc but get fatal error if memory is exhausted. */
|
||||
|
||||
|
||||
/* Like realloc but get fatal error if memory is exhausted. */
|
||||
|
||||
|
||||
/* end of misc.c */
|
||||
#endif
|
93
bfd/misc.h
Executable file
93
bfd/misc.h
Executable file
@ -0,0 +1,93 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* xoxorich. coelesced from binutils.
|
||||
*
|
||||
* Last Mod Mon Feb 18 14:49:51 PST 1991, by rich@cygint.cygnus.com
|
||||
*/
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H 1
|
||||
|
||||
#include "ranlib.h"
|
||||
|
||||
#ifdef USG
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif /* USG */
|
||||
|
||||
#ifdef never
|
||||
#ifdef LOCKS
|
||||
#undef LOCKS
|
||||
#endif /* LOCKS */
|
||||
#endif /* never */
|
||||
|
||||
/* used for masking system io calls into stdio. */
|
||||
|
||||
/* the name, ie, argv[0], of this program. */
|
||||
|
||||
extern char *program_name;
|
||||
|
||||
/* Current file's name */
|
||||
|
||||
extern char *input_name;
|
||||
|
||||
/* Current member's name, or 0 if processing a non-library file. */
|
||||
|
||||
extern char *input_member;
|
||||
|
||||
/* Report an error using the message for the last failed system call,
|
||||
followed by the string NAME. */
|
||||
|
||||
#define perror_name(name) perror(concat(program_name, ": error on ", name))
|
||||
#define pfatal_with_name(name) {perror_name(name);exit(-1);}
|
||||
|
||||
#ifdef __STDC__
|
||||
|
||||
extern char *concat(char *a, char *b, char *c);
|
||||
extern void *xmalloc(unsigned int size);
|
||||
extern void * xrealloc(char *ptr, int size);
|
||||
extern void error(char *string, char *arg1, char *arg2, char *arg3);
|
||||
extern void error_with_file(char *string);
|
||||
extern void fatal(char *string, char*a1, char*a2, char*a3);
|
||||
extern void print_file_name(FILE *outfile);
|
||||
extern void swap_symdef_table(struct symdef *sym, int count);
|
||||
#else
|
||||
extern char *alloca();
|
||||
extern char *concat();
|
||||
extern void * xmalloc();
|
||||
extern void *xrealloc();
|
||||
extern void error();
|
||||
extern void error_with_file();
|
||||
extern void fatal();
|
||||
extern void print_file_name();
|
||||
extern void swap_symdef_table();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#endif /* MISC_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* comment-column: 0
|
||||
* End:
|
||||
*/
|
||||
|
||||
/* end of misc.h */
|
281
bfd/opncls.c
Normal file
281
bfd/opncls.c
Normal file
@ -0,0 +1,281 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/*** opncls.c -- open and close a bfd. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
extern void bfd_cache_init();
|
||||
FILE *bfd_open_file();
|
||||
|
||||
/* fdopen is a loser -- we should use stdio exclusively. Unfortunately
|
||||
if we do that we can't use fcntl. */
|
||||
|
||||
/** Locking
|
||||
|
||||
Locking is loosely controlled by the preprocessor variable
|
||||
BFD_LOCKS. I say loosely because Unix barely understands locking
|
||||
-- at least in BSD it doesn't affect programs which don't
|
||||
explicitly use it! That is to say it's practically useless, though
|
||||
if everyone uses this library you'll be OK.
|
||||
|
||||
From among the many and varied lock facilities available, (none of
|
||||
which, of course, knows about any other) we use the fcntl locks,
|
||||
because they're Posix.
|
||||
|
||||
The reason that bfd_openr and bfd_fdopenr exist, yet only bfd_openw
|
||||
exists is because of locking. When we do output, we lock the
|
||||
filename file for output, then open a temporary file which does not
|
||||
actually get its correct filename until closing time. This is
|
||||
safest, but requires the asymmetry in read and write entry points.
|
||||
|
||||
Perhaps, since unix has so many different kinds of locking anyway,
|
||||
we should use the emacs lock scheme?... */
|
||||
|
||||
|
||||
bfd *new_bfd()
|
||||
{
|
||||
bfd *nbfd = (bfd *)zalloc(sizeof(bfd));
|
||||
|
||||
nbfd->direction = no_direction;
|
||||
nbfd->iostream = NULL;
|
||||
nbfd->where = 0;
|
||||
nbfd->sections = (asection *)NULL;
|
||||
nbfd->format = bfd_unknown;
|
||||
nbfd->my_archive = (bfd *)NULL;
|
||||
nbfd->origin = 0;
|
||||
nbfd->opened_once = false;
|
||||
nbfd->output_has_begun = false;
|
||||
nbfd->section_count = 0;
|
||||
nbfd->usrdata = (void *)NULL;
|
||||
nbfd->sections = (asection *)NULL;
|
||||
nbfd->cacheable = false;
|
||||
nbfd->flags = NO_FLAGS;
|
||||
return nbfd;
|
||||
}
|
||||
bfd *new_bfd_contained_in(obfd)
|
||||
bfd *obfd;
|
||||
{
|
||||
bfd *nbfd = new_bfd(obfd);
|
||||
nbfd->xvec = obfd->xvec;
|
||||
nbfd->my_archive = obfd;
|
||||
nbfd->direction = read_direction;
|
||||
return nbfd;
|
||||
}
|
||||
|
||||
/** bfd_openr, bfd_fdopenr -- open for reading.
|
||||
Returns a pointer to a freshly-allocated bfd on success, or NULL. */
|
||||
|
||||
bfd *
|
||||
bfd_openr (filename, target)
|
||||
char *filename;
|
||||
char *target;
|
||||
{
|
||||
bfd *nbfd;
|
||||
bfd_target *target_vec;
|
||||
|
||||
target_vec = bfd_find_target (target);
|
||||
if (target_vec == NULL) {
|
||||
bfd_error = invalid_target;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bfd_error = system_call_error;
|
||||
nbfd = new_bfd();
|
||||
if (nbfd == NULL) {
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nbfd->filename = filename;
|
||||
nbfd->xvec = target_vec;
|
||||
nbfd->direction = read_direction;
|
||||
|
||||
if (bfd_open_file (nbfd) == NULL) {
|
||||
bfd_error = system_call_error; /* File didn't exist, or some such */
|
||||
free (nbfd);
|
||||
return NULL;
|
||||
}
|
||||
return nbfd;
|
||||
}
|
||||
|
||||
|
||||
/* Don't try to `optimize' this function:
|
||||
|
||||
o - We lock using stack space so that interrupting the locking
|
||||
won't cause a storage leak.
|
||||
o - We open the file stream last, since we don't want to have to
|
||||
close it if anything goes wrong. Closing the stream means closing
|
||||
the file descriptor too, even though we didn't open it.
|
||||
*/
|
||||
|
||||
bfd *
|
||||
bfd_fdopenr (filename, target, fd)
|
||||
char *filename;
|
||||
char *target;
|
||||
int fd;
|
||||
{
|
||||
bfd *nbfd;
|
||||
bfd_target *target_vec;
|
||||
int fdflags;
|
||||
#ifdef BFD_LOCKS
|
||||
struct flock lock, *lockp = &lock;
|
||||
#endif
|
||||
|
||||
target_vec = bfd_find_target (target);
|
||||
if (target_vec == NULL) {
|
||||
bfd_error = invalid_target;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bfd_error = system_call_error;
|
||||
|
||||
fdflags = fcntl (fd, F_GETFL);
|
||||
if (fdflags == -1) return NULL;
|
||||
|
||||
#ifdef BFD_LOCKS
|
||||
lockp->l_type = F_RDLCK;
|
||||
if (fcntl (fd, F_SETLKW, lockp) == -1) return NULL;
|
||||
#endif
|
||||
|
||||
nbfd = new_bfd();
|
||||
|
||||
if (nbfd == NULL) {
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
#ifdef BFD_LOCKS
|
||||
nbfd->lock = (struct flock *) (nbfd + 1);
|
||||
#endif
|
||||
/* if the fd were open for read only, this still would not hurt: */
|
||||
nbfd->iostream = (char *) fdopen (fd, "r+");
|
||||
if (nbfd->iostream == NULL) {
|
||||
free (nbfd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* OK, put everything where it belongs */
|
||||
|
||||
nbfd->filename = filename;
|
||||
nbfd->xvec = target_vec;
|
||||
|
||||
/* As a special case we allow a FD open for read/write to
|
||||
be written through, although doing so requires that we end
|
||||
the previous clause with a preposition. */
|
||||
switch (fdflags & O_ACCMODE) {
|
||||
case O_RDONLY: nbfd->direction = read_direction; break;
|
||||
case O_WRONLY: nbfd->direction = write_direction; break;
|
||||
case O_RDWR: nbfd->direction = both_direction; break;
|
||||
default: abort ();
|
||||
}
|
||||
|
||||
#ifdef BFD_LOCKS
|
||||
memcpy (nbfd->lock, lockp, sizeof (struct flock))
|
||||
#endif
|
||||
|
||||
bfd_cache_init (nbfd);
|
||||
|
||||
return nbfd;
|
||||
}
|
||||
|
||||
/** bfd_openw -- open for writing.
|
||||
Returns a pointer to a freshly-allocated bfd on success, or NULL.
|
||||
|
||||
See comment by bfd_fdopenr before you try to modify this function. */
|
||||
|
||||
bfd *
|
||||
bfd_openw (filename, target)
|
||||
char *filename;
|
||||
char *target;
|
||||
{
|
||||
bfd *nbfd;
|
||||
bfd_target *target_vec;
|
||||
|
||||
target_vec = bfd_find_target (target);
|
||||
if (target_vec == NULL) return NULL;
|
||||
|
||||
bfd_error = system_call_error;
|
||||
|
||||
/* nbfd has to point to head of malloc'ed block so that bfd_close may
|
||||
reclaim it correctly. */
|
||||
|
||||
nbfd = new_bfd();
|
||||
if (nbfd == NULL) {
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nbfd->filename = filename;
|
||||
nbfd->xvec = target_vec;
|
||||
nbfd->direction = write_direction;
|
||||
|
||||
if (bfd_open_file (nbfd) == NULL) {
|
||||
bfd_error = system_call_error; /* File not writeable, etc */
|
||||
free (nbfd);
|
||||
return NULL;
|
||||
}
|
||||
return nbfd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Close up shop, get your deposit back. */
|
||||
boolean
|
||||
bfd_close (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (BFD_SEND (abfd, _close_and_cleanup, (abfd)) != true) return false;
|
||||
|
||||
bfd_cache_close(abfd);
|
||||
/* If the file was open for writing and is now executable
|
||||
make it so */
|
||||
if (abfd->direction == write_direction
|
||||
&& abfd->flags & EXEC_P) {
|
||||
struct stat buf;
|
||||
stat(abfd->filename, &buf);
|
||||
chmod(abfd->filename,buf.st_mode | S_IXUSR | S_IXGRP | S_IXOTH);
|
||||
}
|
||||
free (abfd);
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
called to create a bfd with no ascociated file or target
|
||||
*/
|
||||
bfd *
|
||||
bfd_create(filename, template)
|
||||
char *filename;
|
||||
bfd *template;
|
||||
{
|
||||
bfd *nbfd = new_bfd();
|
||||
if (nbfd == (bfd *)NULL) {
|
||||
bfd_error = no_memory;
|
||||
return (bfd *)NULL;
|
||||
}
|
||||
nbfd->filename = filename;
|
||||
nbfd->xvec = template->xvec;
|
||||
nbfd->direction = no_direction;
|
||||
return nbfd;
|
||||
|
||||
|
||||
|
||||
}
|
464
bfd/srec.c
Normal file
464
bfd/srec.c
Normal file
@ -0,0 +1,464 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/*
|
||||
|
||||
bfd backend for srecord objects.
|
||||
|
||||
Srecords cannot hold anything but addresses and data, so that's all
|
||||
that we impliment.
|
||||
|
||||
The only interesting thing is that srecords may come out of order and
|
||||
there is no header, so an initial scan is required to discover the
|
||||
minimum and maximum addresses used to create the vma and size of the
|
||||
only section we create. We arbitarily call this section ".text".
|
||||
|
||||
When bfd_get_section_contents is called the file is read again, and
|
||||
this time the data is placed into a malloced area.
|
||||
|
||||
Any number of sections may be created for output, we just output them
|
||||
in the order provided to bfd_set_section_contents.
|
||||
|
||||
|
||||
Steve Chamberlain steve@cygnus.com
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* $Id$
|
||||
* $Log$
|
||||
* Revision 1.1 1991/03/21 21:11:20 gumby
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.1 1991/03/13 00:22:29 chrisb
|
||||
* Initial revision
|
||||
*
|
||||
* Revision 1.3 1991/03/10 19:11:40 rich
|
||||
* Modified Files:
|
||||
* bfd.c coff-code.h libbfd.c libbfd.h srec.c sunos.c
|
||||
*
|
||||
* Working bugs out of coff support.
|
||||
*
|
||||
* Revision 1.2 1991/03/07 02:26:18 sac
|
||||
* Tidied up xfer table
|
||||
*
|
||||
* Revision 1.1 1991/03/05 16:28:12 sac
|
||||
* Initial revision
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
static char digs[] = "0123456789ABCDEF";
|
||||
|
||||
/* Macros for converting between hex and binary */
|
||||
|
||||
#define NIBBLE(x) ((x >= '0' && x <= '9') ? (x - '0') : (x - 'A' + 10))
|
||||
#define HEX(buffer) ((NIBBLE((buffer)->high) <<4) + NIBBLE((buffer)->low))
|
||||
#define TOHEX(d,x) \
|
||||
((d)->low = digs[(x) & 0xf], (d)->high = digs[((x)>>4)&0xf], x)
|
||||
|
||||
typedef struct {
|
||||
char high;
|
||||
char low;
|
||||
} byte_as_two_char_type;
|
||||
|
||||
/* The maximum number of bytes on a line is FF */
|
||||
#define MAXCHUNK 0xff
|
||||
/* The number of bytes we fit onto a line on output */
|
||||
#define CHUNK 16
|
||||
|
||||
/* The shape of an srecord .. */
|
||||
typedef struct
|
||||
{
|
||||
char S;
|
||||
char type;
|
||||
byte_as_two_char_type size;
|
||||
union {
|
||||
struct {
|
||||
byte_as_two_char_type address[4];
|
||||
byte_as_two_char_type data[MAXCHUNK];
|
||||
/* If there isn't MAXCHUNK bytes of data then the checksum will
|
||||
appear earlier */
|
||||
byte_as_two_char_type checksum;
|
||||
char nl;
|
||||
} type_3;
|
||||
struct {
|
||||
byte_as_two_char_type address[4];
|
||||
byte_as_two_char_type data[MAXCHUNK];
|
||||
byte_as_two_char_type checksum;
|
||||
char nl;
|
||||
} type_6;
|
||||
|
||||
struct {
|
||||
byte_as_two_char_type address[3];
|
||||
byte_as_two_char_type data[MAXCHUNK];
|
||||
byte_as_two_char_type checksum;
|
||||
char nl;
|
||||
} type_2;
|
||||
|
||||
struct {
|
||||
byte_as_two_char_type address[2];
|
||||
byte_as_two_char_type data[MAXCHUNK];
|
||||
byte_as_two_char_type checksum;
|
||||
char nl;
|
||||
} type_1;
|
||||
byte_as_two_char_type data[MAXCHUNK];
|
||||
} u;
|
||||
} srec_type;
|
||||
|
||||
|
||||
/*
|
||||
called once per input srecord, used to work out vma and size of data.
|
||||
*/
|
||||
|
||||
static void
|
||||
size_srec(abfd, section, address, raw, length)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
bfd_vma address;
|
||||
byte_as_two_char_type *raw;
|
||||
unsigned int length;
|
||||
{
|
||||
if (address < section->vma)
|
||||
section->vma = address;
|
||||
|
||||
if (address + length > section->vma + section->size)
|
||||
section->size = (address+length) - section->vma;
|
||||
}
|
||||
|
||||
/*
|
||||
called once per input srecord, copies data from input into malloced area
|
||||
*/
|
||||
|
||||
static void
|
||||
fillup(abfd, section, address, raw, length)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
bfd_vma address;
|
||||
byte_as_two_char_type *raw;
|
||||
unsigned int length;
|
||||
{
|
||||
unsigned int i;
|
||||
bfd_byte *dst = (bfd_byte *)(section->used_by_bfd) + address - section->vma;
|
||||
for (i = 0; i < length; i++) {
|
||||
*dst = HEX(raw);
|
||||
dst++;
|
||||
raw++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
pass over an srecord file calling one of the above functions on each
|
||||
record
|
||||
*/
|
||||
static void
|
||||
pass_over(abfd, func, section)
|
||||
bfd *abfd;
|
||||
void (*func)();
|
||||
asection *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)
|
||||
{
|
||||
srec_type buffer;
|
||||
|
||||
/* Find first 'S' */
|
||||
eof = bfd_read(&buffer.S, 1, 1, abfd) != 1;
|
||||
while (buffer.S != 'S' && !eof) {
|
||||
eof = bfd_read(&buffer.S, 1, 1, abfd) != 1;
|
||||
}
|
||||
if (eof) break;
|
||||
|
||||
bfd_read(&buffer.type, 1, 3, abfd);
|
||||
|
||||
bytes_on_line = HEX(&buffer.size);
|
||||
|
||||
bfd_read(buffer.u.data, 1 , bytes_on_line * 2, abfd);
|
||||
|
||||
switch (buffer.type) {
|
||||
case '6':
|
||||
/* Prologue - ignore */
|
||||
break;
|
||||
case '3':
|
||||
address = (HEX(buffer.u.type_3.address+0) << 24)
|
||||
+ (HEX(buffer.u.type_3.address+1) << 16)
|
||||
+ (HEX(buffer.u.type_3.address+2) << 8)
|
||||
+ (HEX(buffer.u.type_3.address+3));
|
||||
func(abfd,section, address, buffer.u.type_2.data, bytes_on_line -1);
|
||||
|
||||
break;
|
||||
|
||||
case '2':
|
||||
address = (HEX(buffer.u.type_2.address+0) << 16)+
|
||||
(HEX(buffer.u.type_2.address+1) << 8) +
|
||||
(HEX(buffer.u.type_2.address+2));
|
||||
func(abfd,section, address, buffer.u.type_2.data, bytes_on_line -1);
|
||||
|
||||
break;
|
||||
case '1':
|
||||
address =
|
||||
(HEX(buffer.u.type_1.address+0) << 8)
|
||||
+ (HEX(buffer.u.type_1.address+1));
|
||||
func(abfd, section, address, buffer.u.type_1.data, bytes_on_line -1);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bfd_target *
|
||||
srec_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
char b;
|
||||
asection *section;
|
||||
bfd_seek(abfd, (file_ptr)0, SEEK_SET);
|
||||
bfd_read(&b, 1,1,abfd);
|
||||
if (b != 'S') return (bfd_target*)NULL;
|
||||
|
||||
/*
|
||||
We create one section called data for all the contents,
|
||||
and allocate enough room for the entire file
|
||||
*/
|
||||
|
||||
|
||||
section = bfd_make_section(abfd, ".text");
|
||||
section->size = 0;
|
||||
section->vma = 0xffffffff;
|
||||
pass_over(abfd, size_srec, section);
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static boolean
|
||||
srec_get_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
void *location;
|
||||
file_ptr offset;
|
||||
unsigned int count;
|
||||
{
|
||||
if (section->used_by_bfd == (bfd_byte *)NULL) {
|
||||
section->used_by_bfd = (bfd_byte *)malloc(section->size);
|
||||
pass_over(abfd, fillup, section);
|
||||
}
|
||||
(void) memcpy(location, (bfd_byte *)(section->used_by_bfd) + offset, count);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean
|
||||
srec_set_arch_mach (abfd, arch, machine)
|
||||
bfd *abfd;
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
abfd->obj_arch = arch;
|
||||
abfd->obj_machine = machine;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean
|
||||
srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
unsigned char *location;
|
||||
file_ptr offset;
|
||||
int bytes_to_do;
|
||||
{
|
||||
bfd_vma address;
|
||||
int bytes_written;
|
||||
|
||||
int type;
|
||||
unsigned int i;
|
||||
srec_type buffer;
|
||||
bytes_written = 0;
|
||||
if (section->size <= 0xffff)
|
||||
type = 1;
|
||||
else if (section->size <= 0xffffff)
|
||||
type = 2;
|
||||
else
|
||||
type = 3;
|
||||
|
||||
buffer.S = 'S';
|
||||
buffer.type = '0' + type;
|
||||
|
||||
while (bytes_written < bytes_to_do) {
|
||||
unsigned int size;
|
||||
unsigned int check_sum;
|
||||
byte_as_two_char_type *data;
|
||||
int bytes_this_chunk = bytes_to_do - bytes_written;
|
||||
|
||||
if (bytes_this_chunk > CHUNK) {
|
||||
bytes_this_chunk = CHUNK;
|
||||
}
|
||||
|
||||
address = section->vma + offset + bytes_written;
|
||||
|
||||
switch (type) {
|
||||
case 3:
|
||||
check_sum = TOHEX(buffer.u.type_3.address, address >> 24);
|
||||
check_sum += TOHEX(buffer.u.type_3.address+1, address >> 16);
|
||||
check_sum += TOHEX(buffer.u.type_3.address+2, address >> 8);
|
||||
check_sum += TOHEX(buffer.u.type_3.address+3, address >> 0);
|
||||
size = bytes_this_chunk + 5;
|
||||
data = buffer.u.type_3.data;
|
||||
|
||||
case 2:
|
||||
check_sum = TOHEX(buffer.u.type_3.address, address >> 16);
|
||||
check_sum += TOHEX(buffer.u.type_3.address+1, address >> 8);
|
||||
check_sum += TOHEX(buffer.u.type_3.address+2, address >> 0);
|
||||
size = bytes_this_chunk + 4;
|
||||
data = buffer.u.type_2.data;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
check_sum = TOHEX(buffer.u.type_3.address+0, address >> 8);
|
||||
check_sum += TOHEX(buffer.u.type_3.address+1, address >> 0);
|
||||
size = bytes_this_chunk + 3;
|
||||
data = buffer.u.type_1.data;
|
||||
}
|
||||
|
||||
for (i = 0; i < bytes_this_chunk; i++) {
|
||||
check_sum += TOHEX(data, (location[i]));
|
||||
data++;
|
||||
}
|
||||
|
||||
check_sum += TOHEX(&(buffer.size), size );
|
||||
(void) TOHEX(data, ~check_sum);
|
||||
data++;
|
||||
|
||||
* ( (char *)(data)) = '\n';
|
||||
bfd_write(&buffer, 1, (char *)data - (char *)&buffer + 1 , abfd);
|
||||
|
||||
bytes_written += bytes_this_chunk;
|
||||
location += bytes_this_chunk;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
boolean
|
||||
srec_close_and_cleanup (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
asection *s;
|
||||
if (bfd_read_p (abfd) == false) {
|
||||
switch (abfd->format) {
|
||||
case bfd_archive:
|
||||
if (!_bfd_write_archive_contents (abfd)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case bfd_object:
|
||||
bfd_write("S9030000FC\n", 1,11,abfd);
|
||||
break;
|
||||
default:
|
||||
bfd_error = invalid_operation;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (s = abfd->sections; s != (asection *)NULL;s = s->next) {
|
||||
if (s->used_by_bfd != (void *)NULL) {
|
||||
free(s->used_by_bfd);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*SUPPRESS 460 */
|
||||
bfd_target srec_vec =
|
||||
{
|
||||
"srec", /* name */
|
||||
bfd_target_srec_flavour_enum,
|
||||
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_CODE|SEC_DATA|SEC_ROM
|
||||
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* valid reloc types */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
srec_close_and_cleanup, /* _close_and_cleanup */
|
||||
srec_set_section_contents, /* bfd_set_section_contents */
|
||||
srec_get_section_contents,
|
||||
bfd_true, /* new_section_hook */
|
||||
0, /* _core_file_failing_command */
|
||||
0, /* _core_file_failing_signal */
|
||||
0, /* _core_file_matches_ex...p */
|
||||
|
||||
bfd_false, /* bfd_slurp_armap */
|
||||
bfd_false, /* bfd_slurp_extended_name_table */
|
||||
bfd_void, /* bfd_truncate_arname */
|
||||
bfd_0u, /* get_symtab_upper_bound */
|
||||
bfd_0u, /* canonicalize_symtab */
|
||||
bfd_void, /* bfd_reclaim_symbol_table */
|
||||
bfd_0u, /* get_reloc_upper_bound */
|
||||
bfd_0u, /* bfd_canonicalize_reloc */
|
||||
bfd_void, /* bfd_reclaim_reloc */
|
||||
bfd_0, /* bfd_get_symcount_upper_bound */
|
||||
(symindex (*)())bfd_0, /* bfd_get_first_symbol */
|
||||
(symindex (*)())bfd_0, /* bfd_get_next_symbol */
|
||||
bfd_false, /* bfd_classify_symbol */
|
||||
bfd_false, /* bfd_symbol_hasclass */
|
||||
(char* (*)())bfd_0, /* bfd_symbol_name */
|
||||
bfd_0, /* bfd_symbol_value */
|
||||
|
||||
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
|
||||
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target,
|
||||
srec_object_p, /* bfd_check_format */
|
||||
(struct bfd_target *(*)()) bfd_nullvoidptr,
|
||||
(struct bfd_target *(*)()) bfd_nullvoidptr,
|
||||
},
|
||||
{
|
||||
bfd_false,
|
||||
bfd_true, /* mkobject */
|
||||
_bfd_generic_mkarchive,
|
||||
bfd_false,
|
||||
},
|
||||
(asymbol * (*)()) bfd_nullvoidptr, /* bfd_make_empty_symbol */
|
||||
bfd_void, /* bfd_prit_symbol */
|
||||
(alent *(*)())bfd_nullvoidptr, /* srec_get_lineno,*/
|
||||
srec_set_arch_mach, /* bfd_set_arch_mach,*/
|
||||
bfd_false, /* write_armap*/
|
||||
(bfd *(*)())bfd_nullvoidptr, /* openr_next_archived_file */
|
||||
bfd_false, /* bfd_find_nearest_line */
|
||||
};
|
1904
bfd/sunos.c
Normal file
1904
bfd/sunos.c
Normal file
File diff suppressed because it is too large
Load Diff
50
bfd/targets.c
Normal file
50
bfd/targets.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Diddler.
|
||||
|
||||
BFD 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 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
BFD 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 BFD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
/* This -*- C -*- source file will someday be machine-generated */
|
||||
|
||||
/*** Defines the target vector through which operations dispatch */
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
extern bfd_target aoutvec;
|
||||
extern bfd_target srec_vec;
|
||||
extern bfd_target b_out_vec_little_host;
|
||||
extern bfd_target b_out_vec_big_host;
|
||||
extern bfd_target icoff_little_vec;
|
||||
extern bfd_target icoff_big_vec;
|
||||
|
||||
|
||||
bfd_target *target_vector[] =
|
||||
{
|
||||
#ifndef INTEL960VERSION
|
||||
&aoutvec,
|
||||
&srec_vec,
|
||||
|
||||
#endif /* INTEL960VERSION */
|
||||
&icoff_big_vec,
|
||||
&icoff_little_vec,
|
||||
&b_out_vec_big_host,
|
||||
&b_out_vec_little_host,
|
||||
|
||||
NULL
|
||||
};
|
Loading…
Reference in New Issue
Block a user