| 1 | /* Support for the generic parts of PE/PEI; common header information.
|
|---|
| 2 | Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
|---|
| 3 | Free Software Foundation, Inc.
|
|---|
| 4 | Written by Cygnus Solutions.
|
|---|
| 5 |
|
|---|
| 6 | This file is part of BFD, the Binary File Descriptor library.
|
|---|
| 7 |
|
|---|
| 8 | This program is free software; you can redistribute it and/or modify
|
|---|
| 9 | it under the terms of the GNU General Public License as published by
|
|---|
| 10 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 11 | (at your option) any later version.
|
|---|
| 12 |
|
|---|
| 13 | This program is distributed in the hope that it will be useful,
|
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 16 | GNU General Public License for more details.
|
|---|
| 17 |
|
|---|
| 18 | You should have received a copy of the GNU General Public License
|
|---|
| 19 | along with this program; if not, write to the Free Software
|
|---|
| 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 21 |
|
|---|
| 22 | /*
|
|---|
| 23 | Most of this hacked by Steve Chamberlain,
|
|---|
| 24 | [email protected]
|
|---|
| 25 |
|
|---|
| 26 | PE/PEI rearrangement (and code added): Donn Terry
|
|---|
| 27 | Softway Systems, Inc.
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | /* Hey look, some documentation [and in a place you expect to find it]!
|
|---|
| 31 |
|
|---|
| 32 | The main reference for the pei format is "Microsoft Portable Executable
|
|---|
| 33 | and Common Object File Format Specification 4.1". Get it if you need to
|
|---|
| 34 | do some serious hacking on this code.
|
|---|
| 35 |
|
|---|
| 36 | Another reference:
|
|---|
| 37 | "Peering Inside the PE: A Tour of the Win32 Portable Executable
|
|---|
| 38 | File Format", MSJ 1994, Volume 9.
|
|---|
| 39 |
|
|---|
| 40 | The *sole* difference between the pe format and the pei format is that the
|
|---|
| 41 | latter has an MSDOS 2.0 .exe header on the front that prints the message
|
|---|
| 42 | "This app must be run under Windows." (or some such).
|
|---|
| 43 | (FIXME: Whether that statement is *really* true or not is unknown.
|
|---|
| 44 | Are there more subtle differences between pe and pei formats?
|
|---|
| 45 | For now assume there aren't. If you find one, then for God sakes
|
|---|
| 46 | document it here!)
|
|---|
| 47 |
|
|---|
| 48 | The Microsoft docs use the word "image" instead of "executable" because
|
|---|
| 49 | the former can also refer to a DLL (shared library). Confusion can arise
|
|---|
| 50 | because the `i' in `pei' also refers to "image". The `pe' format can
|
|---|
| 51 | also create images (i.e. executables), it's just that to run on a win32
|
|---|
| 52 | system you need to use the pei format.
|
|---|
| 53 |
|
|---|
| 54 | FIXME: Please add more docs here so the next poor fool that has to hack
|
|---|
| 55 | on this code has a chance of getting something accomplished without
|
|---|
| 56 | wasting too much time.
|
|---|
| 57 | */
|
|---|
| 58 |
|
|---|
| 59 | #ifndef GET_FCN_LNNOPTR
|
|---|
| 60 | #define GET_FCN_LNNOPTR(abfd, ext) \
|
|---|
| 61 | bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
|
|---|
| 62 | #endif
|
|---|
| 63 |
|
|---|
| 64 | #ifndef GET_FCN_ENDNDX
|
|---|
| 65 | #define GET_FCN_ENDNDX(abfd, ext) \
|
|---|
| 66 | bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
|
|---|
| 67 | #endif
|
|---|
| 68 |
|
|---|
| 69 | #ifndef PUT_FCN_LNNOPTR
|
|---|
| 70 | #define PUT_FCN_LNNOPTR(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
|
|---|
| 71 | #endif
|
|---|
| 72 | #ifndef PUT_FCN_ENDNDX
|
|---|
| 73 | #define PUT_FCN_ENDNDX(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
|
|---|
| 74 | #endif
|
|---|
| 75 | #ifndef GET_LNSZ_LNNO
|
|---|
| 76 | #define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
|
|---|
| 77 | #endif
|
|---|
| 78 | #ifndef GET_LNSZ_SIZE
|
|---|
| 79 | #define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
|
|---|
| 80 | #endif
|
|---|
| 81 | #ifndef PUT_LNSZ_LNNO
|
|---|
|
|---|