1999-08-18 Donn Terry <donn@interix.com>

* coff-i386.c (coff_i386_reloc): Handle R_IMAGEBASE.
	(RTYPE2HOWTO): Return NULL if reloc type is out of range.
	(coff_i386_rtype_to_howto): Likewise.
	* coffcode.h (coff_slurp_symbol_table): Change a -2 to N_DEBUG.
	Completely ignore symbols which are all zero.
	(dummy_reloc16_estimate): Add return 0.
	* cofflink.c (_bfd_coff_link_input_bfd): Rename inner scope
	variable copy to name_copy to avoid shadowing outer scope
	variable.
	* libcoff-in.h (coff_data_type): Change raw_syment_count field
	from unsigned int to unsigned long.  Add timestamp field.
	* libcoff.h: Rebuild.

Also comment changes.
This commit is contained in:
Ian Lance Taylor 1999-08-18 06:00:13 +00:00
parent 7bb9db4d63
commit 00692651e0
6 changed files with 77 additions and 24 deletions

View File

@ -1,3 +1,18 @@
1999-08-18 Donn Terry <donn@interix.com>
* coff-i386.c (coff_i386_reloc): Handle R_IMAGEBASE.
(RTYPE2HOWTO): Return NULL if reloc type is out of range.
(coff_i386_rtype_to_howto): Likewise.
* coffcode.h (coff_slurp_symbol_table): Change a -2 to N_DEBUG.
Completely ignore symbols which are all zero.
(dummy_reloc16_estimate): Add return 0.
* cofflink.c (_bfd_coff_link_input_bfd): Rename inner scope
variable copy to name_copy to avoid shadowing outer scope
variable.
* libcoff-in.h (coff_data_type): Change raw_syment_count field
from unsigned int to unsigned long. Add timestamp field.
* libcoff.h: Rebuild.
1999-08-17 H.J. Lu <hjl@gnu.org> 1999-08-17 H.J. Lu <hjl@gnu.org>
* elf32-hppa.c (bfd_elf32_bfd_is_local_label_name): Fix typo in * elf32-hppa.c (bfd_elf32_bfd_is_local_label_name): Fix typo in

View File

@ -42,8 +42,10 @@ static bfd_reloc_status_type coff_i386_reloc
static reloc_howto_type *coff_i386_rtype_to_howto static reloc_howto_type *coff_i386_rtype_to_howto
PARAMS ((bfd *, asection *, struct internal_reloc *, PARAMS ((bfd *, asection *, struct internal_reloc *,
struct coff_link_hash_entry *, struct internal_syment *, struct coff_link_hash_entry *, struct internal_syment *,
bfd_vma *)); bfd_vma *));
static reloc_howto_type *coff_i386_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static const bfd_target *i3coff_object_p PARAMS ((bfd *));
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
/* The page size is a guess based on ELF. */ /* The page size is a guess based on ELF. */
@ -106,8 +108,8 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
#ifdef COFF_WITH_PE #ifdef COFF_WITH_PE
/* FIXME: How should this case be handled? */ /* FIXME: How should this case be handled? */
if (reloc_entry->howto->type == R_IMAGEBASE && diff != 0) if (reloc_entry->howto->type == R_IMAGEBASE)
abort (); diff -= pe_data (output_bfd)->pe_opthdr.ImageBase;
#endif #endif
#define DOIT(x) \ #define DOIT(x) \
@ -190,7 +192,7 @@ static reloc_howto_type howto_table[] =
0xffffffff, /* src_mask */ 0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */ 0xffffffff, /* dst_mask */
true), /* pcrel_offset */ true), /* pcrel_offset */
/* {7}, */ /* PE IMAGE_REL_I386_DIR32NB relocation (7). */
HOWTO (R_IMAGEBASE, /* type */ HOWTO (R_IMAGEBASE, /* type */
0, /* rightshift */ 0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */ 2, /* size (0 = byte, 1 = short, 2 = long) */
@ -211,7 +213,8 @@ static reloc_howto_type howto_table[] =
EMPTY_HOWTO (014), EMPTY_HOWTO (014),
EMPTY_HOWTO (015), EMPTY_HOWTO (015),
EMPTY_HOWTO (016), EMPTY_HOWTO (016),
HOWTO (R_RELBYTE, /* type */ /* Byte relocation (017). */
HOWTO (R_RELBYTE, /* type */
0, /* rightshift */ 0, /* rightshift */
0, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* size (0 = byte, 1 = short, 2 = long) */
8, /* bitsize */ 8, /* bitsize */
@ -224,6 +227,7 @@ static reloc_howto_type howto_table[] =
0x000000ff, /* src_mask */ 0x000000ff, /* src_mask */
0x000000ff, /* dst_mask */ 0x000000ff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */ PCRELOFFSET), /* pcrel_offset */
/* 16-bit word relocation (020). */
HOWTO (R_RELWORD, /* type */ HOWTO (R_RELWORD, /* type */
0, /* rightshift */ 0, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */ 1, /* size (0 = byte, 1 = short, 2 = long) */
@ -237,6 +241,7 @@ static reloc_howto_type howto_table[] =
0x0000ffff, /* src_mask */ 0x0000ffff, /* src_mask */
0x0000ffff, /* dst_mask */ 0x0000ffff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */ PCRELOFFSET), /* pcrel_offset */
/* 32-bit longword relocation (021). */
HOWTO (R_RELLONG, /* type */ HOWTO (R_RELLONG, /* type */
0, /* rightshift */ 0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */ 2, /* size (0 = byte, 1 = short, 2 = long) */
@ -250,6 +255,7 @@ static reloc_howto_type howto_table[] =
0xffffffff, /* src_mask */ 0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */ 0xffffffff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */ PCRELOFFSET), /* pcrel_offset */
/* Byte PC relative relocation (022). */
HOWTO (R_PCRBYTE, /* type */ HOWTO (R_PCRBYTE, /* type */
0, /* rightshift */ 0, /* rightshift */
0, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* size (0 = byte, 1 = short, 2 = long) */
@ -263,6 +269,7 @@ static reloc_howto_type howto_table[] =
0x000000ff, /* src_mask */ 0x000000ff, /* src_mask */
0x000000ff, /* dst_mask */ 0x000000ff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */ PCRELOFFSET), /* pcrel_offset */
/* 16-bit word PC relative relocation (023). */
HOWTO (R_PCRWORD, /* type */ HOWTO (R_PCRWORD, /* type */
0, /* rightshift */ 0, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */ 1, /* size (0 = byte, 1 = short, 2 = long) */
@ -276,6 +283,7 @@ static reloc_howto_type howto_table[] =
0x0000ffff, /* src_mask */ 0x0000ffff, /* src_mask */
0x0000ffff, /* dst_mask */ 0x0000ffff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */ PCRELOFFSET), /* pcrel_offset */
/* 32-bit longword PC relative relocation (024). */
HOWTO (R_PCRLONG, /* type */ HOWTO (R_PCRLONG, /* type */
0, /* rightshift */ 0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */ 2, /* size (0 = byte, 1 = short, 2 = long) */
@ -297,8 +305,11 @@ static reloc_howto_type howto_table[] =
#define BADMAG(x) I386BADMAG(x) #define BADMAG(x) I386BADMAG(x)
#define I386 1 /* Customize coffcode.h */ #define I386 1 /* Customize coffcode.h */
#define RTYPE2HOWTO(cache_ptr, dst) \ #define RTYPE2HOWTO(cache_ptr, dst) \
(cache_ptr)->howto = howto_table + (dst)->r_type; ((cache_ptr)->howto = \
((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \
? howto_table + (dst)->r_type \
: NULL))
/* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared /* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
library. On some other COFF targets STYP_BSS is normally library. On some other COFF targets STYP_BSS is normally
@ -392,12 +403,18 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
struct internal_syment *sym; struct internal_syment *sym;
bfd_vma *addendp; bfd_vma *addendp;
{ {
reloc_howto_type *howto; reloc_howto_type *howto;
if (rel->r_type > sizeof (howto_table) / sizeof (howto_table[0]))
{
bfd_set_error (bfd_error_bad_value);
return NULL;
}
howto = howto_table + rel->r_type; howto = howto_table + rel->r_type;
#ifdef COFF_WITH_PE #ifdef COFF_WITH_PE
/* Cancel out code in _bfd_coff_generic_relocate_section. */
*addendp = 0; *addendp = 0;
#endif #endif
@ -458,10 +475,8 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
return howto; return howto;
} }
#define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup #define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
static reloc_howto_type * static reloc_howto_type *
coff_i386_reloc_type_lookup (abfd, code) coff_i386_reloc_type_lookup (abfd, code)
bfd *abfd ATTRIBUTE_UNUSED; bfd *abfd ATTRIBUTE_UNUSED;

View File

@ -131,7 +131,7 @@ SUBSUBSECTION
moment. To port BFD, that person will have to add more @code{#defines}. moment. To port BFD, that person will have to add more @code{#defines}.
Three of the bit twiddling routines are exported to Three of the bit twiddling routines are exported to
@code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in} @code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in}
and @code{coff_swap_linno_in}. @code{GDB} reads the symbol and @code{coff_swap_lineno_in}. @code{GDB} reads the symbol
table on its own, but uses BFD to fix things up. More of the table on its own, but uses BFD to fix things up. More of the
bit twiddlers are exported for @code{gas}; bit twiddlers are exported for @code{gas};
@code{coff_swap_aux_out}, @code{coff_swap_sym_out}, @code{coff_swap_aux_out}, @code{coff_swap_sym_out},
@ -2749,7 +2749,7 @@ coff_write_object_contents (abfd)
#ifdef COFF_LONG_SECTION_NAMES #ifdef COFF_LONG_SECTION_NAMES
/* Handle long section names as in PE. This must be compatible /* Handle long section names as in PE. This must be compatible
with the code in coff_write_symbols. */ with the code in coff_write_symbols and _bfd_coff_final_link. */
{ {
size_t len; size_t len;
@ -2844,10 +2844,11 @@ coff_write_object_contents (abfd)
#endif #endif
#ifdef COFF_IMAGE_WITH_PE #ifdef COFF_IMAGE_WITH_PE
/* suppress output of the sections if they are null. ld includes /* Suppress output of the sections if they are null. ld
the bss and data sections even if there is no size assigned includes the bss and data sections even if there is no size
to them. NT loader doesn't like it if these section headers are assigned to them. NT loader doesn't like it if these section
included if the sections themselves are not needed */ headers are included if the sections themselves are not
needed. See also coff_compute_section_file_positions. */
if (section.s_size == 0) if (section.s_size == 0)
internal_f.f_nscns--; internal_f.f_nscns--;
else else
@ -3472,6 +3473,9 @@ SUBSUBSECTION
base of the line number information for the table is stored in base of the line number information for the table is stored in
the symbol associated with the function. the symbol associated with the function.
Note: The PE format uses line number 0 for a flag indicating a
new source file.
The information is copied from the external to the internal The information is copied from the external to the internal
table, and each symbol which marks a function is marked by table, and each symbol which marks a function is marked by
pointing its... pointing its...
@ -3561,6 +3565,10 @@ coff_slurp_line_table (abfd, asect)
return true; return true;
} }
/* Slurp in the symbol table, converting it to generic form. Note
that if coff_relocate_section is defined, the linker will read
symbols via coff_link_add_symbols, rather than via this routine. */
static boolean static boolean
coff_slurp_symbol_table (abfd) coff_slurp_symbol_table (abfd)
bfd * abfd; bfd * abfd;
@ -3726,7 +3734,7 @@ coff_slurp_symbol_table (abfd)
case C_THUMBSTATFUNC:/* Thumb static function */ case C_THUMBSTATFUNC:/* Thumb static function */
#endif #endif
case C_LABEL: /* label */ case C_LABEL: /* label */
if (src->u.syment.n_scnum == -2) if (src->u.syment.n_scnum == N_DEBUG)
dst->symbol.flags = BSF_DEBUGGING; dst->symbol.flags = BSF_DEBUGGING;
else else
dst->symbol.flags = BSF_LOCAL; dst->symbol.flags = BSF_LOCAL;
@ -3854,6 +3862,13 @@ coff_slurp_symbol_table (abfd)
break; break;
case C_NULL: case C_NULL:
/* PE DLLs sometimes have zeroed out symbols for some
reason. Just ignore them without a warning. */
if (src->u.syment.n_type == 0
&& src->u.syment.n_value == 0
&& src->u.syment.n_scnum == 0)
break;
/* Fall through. */
case C_EXTDEF: /* external definition */ case C_EXTDEF: /* external definition */
case C_ULABEL: /* undefined label */ case C_ULABEL: /* undefined label */
case C_USTATIC: /* undefined static */ case C_USTATIC: /* undefined static */
@ -4269,6 +4284,7 @@ dummy_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
struct bfd_link_info *link_info ATTRIBUTE_UNUSED; struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
{ {
abort (); abort ();
return 0;
} }
#endif #endif

View File

@ -1523,7 +1523,7 @@ _bfd_coff_link_input_bfd (finfo, input_bfd)
{ {
const char *elename; const char *elename;
char elebuf[SYMNMLEN + 1]; char elebuf[SYMNMLEN + 1];
char *copy; char *name_copy;
bfd_coff_swap_sym_in (input_bfd, (PTR) esl, (PTR) islp); bfd_coff_swap_sym_in (input_bfd, (PTR) esl, (PTR) islp);
@ -1538,12 +1538,13 @@ _bfd_coff_link_input_bfd (finfo, input_bfd)
if (elename == NULL) if (elename == NULL)
return false; return false;
copy = (char *) bfd_alloc (input_bfd, strlen (elename) + 1); name_copy = (char *) bfd_alloc (input_bfd,
if (copy == NULL) strlen (elename) + 1);
if (name_copy == NULL)
return false; return false;
strcpy (copy, elename); strcpy (name_copy, elename);
(*epp)->name = copy; (*epp)->name = name_copy;
(*epp)->type = islp->n_type; (*epp)->type = islp->n_type;
(*epp)->tagndx = 0; (*epp)->tagndx = 0;
if (islp->n_numaux >= 1 if (islp->n_numaux >= 1

View File

@ -56,7 +56,7 @@ typedef struct coff_tdata
file_ptr sym_filepos; file_ptr sym_filepos;
struct coff_ptr_struct *raw_syments; struct coff_ptr_struct *raw_syments;
unsigned int raw_syment_count; unsigned long raw_syment_count;
/* These are only valid once writing has begun */ /* These are only valid once writing has begun */
long int relocbase; long int relocbase;
@ -97,6 +97,9 @@ typedef struct coff_tdata
/* Used by coff_find_nearest_line. */ /* Used by coff_find_nearest_line. */
PTR line_info; PTR line_info;
/* The timestamp from the COFF file header. */
long timestamp;
/* Copy of some of the f_flags bits in the COFF filehdr structure, /* Copy of some of the f_flags bits in the COFF filehdr structure,
used by ARM code. */ used by ARM code. */
flagword flags; flagword flags;

View File

@ -56,7 +56,7 @@ typedef struct coff_tdata
file_ptr sym_filepos; file_ptr sym_filepos;
struct coff_ptr_struct *raw_syments; struct coff_ptr_struct *raw_syments;
unsigned int raw_syment_count; unsigned long raw_syment_count;
/* These are only valid once writing has begun */ /* These are only valid once writing has begun */
long int relocbase; long int relocbase;
@ -97,6 +97,9 @@ typedef struct coff_tdata
/* Used by coff_find_nearest_line. */ /* Used by coff_find_nearest_line. */
PTR line_info; PTR line_info;
/* The timestamp from the COFF file header. */
long timestamp;
/* Copy of some of the f_flags bits in the COFF filehdr structure, /* Copy of some of the f_flags bits in the COFF filehdr structure,
used by ARM code. */ used by ARM code. */
flagword flags; flagword flags;