diff options
author | Juan Manuel Guerrero <juan.guerrero@gmx.de> | 2020-04-14 17:30:01 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-04-14 17:30:01 +0100 |
commit | f717994fe84df26ec4e4fe4104e018ece8b5b9cf (patch) | |
tree | f0ce03676b17fac838ae086565b69b6be3f36b55 /bfd/coff-stgo32.c | |
parent | 06ca5dd49ac45e814ca167f441ac0b191b50bb37 (diff) | |
download | gdb-f717994fe84df26ec4e4fe4104e018ece8b5b9cf.zip gdb-f717994fe84df26ec4e4fe4104e018ece8b5b9cf.tar.gz gdb-f717994fe84df26ec4e4fe4104e018ece8b5b9cf.tar.bz2 |
[PATCH v2 2/2] coff-go32: support extended relocations
This patch extends the relocation and line number counters for
coff-go32 and coff-go32-exe to 32 bits. As I understand it works the
same as for PE-COFF:
If the number of relocations in an object file exceeds 65534, the
NRELOC field is set to 65535 and the actual number of relocations is
stored in the VADDR field of the first relocation entry.
Executable files have no relocations, and thus the NRELOC field is
repurposed to extend NLNNO to 32-bits.
bfd * coff-go32.c (COFF_GO32, IMAGE_SCN_LNK_NRELOC_OVFL)
(coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define.
(_bfd_go32_swap_scnhdr_in, _bfd_go32_swap_scnhdr_out)
(_bfd_go32_mkobject): New functions.
* coff-stgo32.c (IMAGE_SCN_LNK_NRELOC_OVFL)
(coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define.
(go32exe_mkobject): Call _bfd_go32_mkobject.
* coffcode.h (COFF_WITH_EXTENDED_RELOC_COUNTER): Define.
(coff_set_alignment_hook): Define function for COFF_GO32_EXE
and COFF_GO32.
(coff_write_relocs): Enable extended reloc counter code if
COFF_WITH_EXTENDED_RELOC_COUNTER is defined. Test for obj_go32.
(coff_write_object_contents): Likewise. Pad section headers
for COFF_GO32 and COFF_GO32EXE. Use bfd_coff_swap_scnhdr_out
instead of coff_swap_scnhdr_out.
* cofflink.c (_bfd_coff_final_link): Test also for obj_go32 to
enable extended reloc counter.
* coffswap.h: (coff_swap_scnhdr_in, coff_swap_scnhdr_out):
Declare with ATTRIBUTE_UNUSED.
* libcoff-in.h: (struct coff_tdata): New field go32.
(obj_go32): Define.
* libcoff.h: Regenerate.
Diffstat (limited to 'bfd/coff-stgo32.c')
-rw-r--r-- | bfd/coff-stgo32.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c index d1be578..0fea119 100644 --- a/bfd/coff-stgo32.c +++ b/bfd/coff-stgo32.c @@ -46,6 +46,9 @@ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } +/* Section contains extended relocations. */ +#define IMAGE_SCN_LNK_NRELOC_OVFL (0x01000000) + #include "sysdep.h" #include "bfd.h" #include "coff/msdos.h" @@ -55,10 +58,17 @@ static bfd_boolean go32exe_write_object_contents (bfd *); static bfd_boolean go32exe_mkobject (bfd *); static bfd_boolean go32exe_copy_private_bfd_data (bfd *, bfd *); +/* Defined in coff-go32.c. */ +bfd_boolean _bfd_go32_mkobject (bfd *); +void _bfd_go32_swap_scnhdr_in (bfd *, void *, void *); +unsigned int _bfd_go32_swap_scnhdr_out (bfd *, void *, void *); + #define COFF_CHECK_FORMAT go32exe_check_format #define COFF_WRITE_CONTENTS go32exe_write_object_contents #define coff_mkobject go32exe_mkobject #define coff_bfd_copy_private_bfd_data go32exe_copy_private_bfd_data +#define coff_SWAP_scnhdr_in _bfd_go32_swap_scnhdr_in +#define coff_SWAP_scnhdr_out _bfd_go32_swap_scnhdr_out #include "coff-i386.c" @@ -352,32 +362,20 @@ go32exe_write_object_contents (bfd *abfd) static bfd_boolean go32exe_mkobject (bfd *abfd) { - coff_data_type *coff = NULL; - const bfd_size_type amt = sizeof (coff_data_type); - /* Don't output to an archive. */ if (abfd->my_archive != NULL) return FALSE; - abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt); - if (abfd->tdata.coff_obj_data == NULL) + if (!_bfd_go32_mkobject (abfd)) return FALSE; - coff = coff_data (abfd); - coff->symbols = NULL; - coff->conversion_table = NULL; - coff->raw_syments = NULL; - coff->relocbase = 0; - coff->local_toc_sym_map = 0; go32exe_create_stub (abfd); - if (coff->stub == NULL) + if (coff_data (abfd)->stub == NULL) { - bfd_release (abfd, coff); + bfd_release (abfd, coff_data (abfd)); return FALSE; } - abfd->origin = coff->stub_size; - -/* make_abs_section(abfd);*/ /* ??? */ + abfd->origin = coff_data (abfd)->stub_size; return TRUE; } |