aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1999-08-18 06:00:13 +0000
committerIan Lance Taylor <ian@airs.com>1999-08-18 06:00:13 +0000
commit00692651e0142d5a0d6213567ad234804d28fef4 (patch)
treef5e3f229b4f71cc22b94939a1ff085d24dcdc8c0 /bfd
parent7bb9db4d63c9a224fc40f967cfd957b61512e42f (diff)
downloadgdb-00692651e0142d5a0d6213567ad234804d28fef4.zip
gdb-00692651e0142d5a0d6213567ad234804d28fef4.tar.gz
gdb-00692651e0142d5a0d6213567ad234804d28fef4.tar.bz2
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog15
-rw-r--r--bfd/coff-i386.c35
-rw-r--r--bfd/coffcode.h30
-rw-r--r--bfd/cofflink.c11
-rw-r--r--bfd/libcoff-in.h5
-rw-r--r--bfd/libcoff.h5
6 files changed, 77 insertions, 24 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 945cfb1..ebdc802 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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>
* elf32-hppa.c (bfd_elf32_bfd_is_local_label_name): Fix typo in
diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c
index 0d10fe2..e686b7b 100644
--- a/bfd/coff-i386.c
+++ b/bfd/coff-i386.c
@@ -42,8 +42,10 @@ static bfd_reloc_status_type coff_i386_reloc
static reloc_howto_type *coff_i386_rtype_to_howto
PARAMS ((bfd *, asection *, struct internal_reloc *,
struct coff_link_hash_entry *, struct internal_syment *,
-
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)
/* 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
/* FIXME: How should this case be handled? */
- if (reloc_entry->howto->type == R_IMAGEBASE && diff != 0)
- abort ();
+ if (reloc_entry->howto->type == R_IMAGEBASE)
+ diff -= pe_data (output_bfd)->pe_opthdr.ImageBase;
#endif
#define DOIT(x) \
@@ -190,7 +192,7 @@ static reloc_howto_type howto_table[] =
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
true), /* pcrel_offset */
- /* {7}, */
+ /* PE IMAGE_REL_I386_DIR32NB relocation (7). */
HOWTO (R_IMAGEBASE, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
@@ -211,7 +213,8 @@ static reloc_howto_type howto_table[] =
EMPTY_HOWTO (014),
EMPTY_HOWTO (015),
EMPTY_HOWTO (016),
- HOWTO (R_RELBYTE, /* type */
+ /* Byte relocation (017). */
+ HOWTO (R_RELBYTE, /* type */
0, /* rightshift */
0, /* size (0 = byte, 1 = short, 2 = long) */
8, /* bitsize */
@@ -224,6 +227,7 @@ static reloc_howto_type howto_table[] =
0x000000ff, /* src_mask */
0x000000ff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */
+ /* 16-bit word relocation (020). */
HOWTO (R_RELWORD, /* type */
0, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
@@ -237,6 +241,7 @@ static reloc_howto_type howto_table[] =
0x0000ffff, /* src_mask */
0x0000ffff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */
+ /* 32-bit longword relocation (021). */
HOWTO (R_RELLONG, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
@@ -250,6 +255,7 @@ static reloc_howto_type howto_table[] =
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */
+ /* Byte PC relative relocation (022). */
HOWTO (R_PCRBYTE, /* type */
0, /* rightshift */
0, /* size (0 = byte, 1 = short, 2 = long) */
@@ -263,6 +269,7 @@ static reloc_howto_type howto_table[] =
0x000000ff, /* src_mask */
0x000000ff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */
+ /* 16-bit word PC relative relocation (023). */
HOWTO (R_PCRWORD, /* type */
0, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
@@ -276,6 +283,7 @@ static reloc_howto_type howto_table[] =
0x0000ffff, /* src_mask */
0x0000ffff, /* dst_mask */
PCRELOFFSET), /* pcrel_offset */
+ /* 32-bit longword PC relative relocation (024). */
HOWTO (R_PCRLONG, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
@@ -297,8 +305,11 @@ static reloc_howto_type howto_table[] =
#define BADMAG(x) I386BADMAG(x)
#define I386 1 /* Customize coffcode.h */
-#define RTYPE2HOWTO(cache_ptr, dst) \
- (cache_ptr)->howto = howto_table + (dst)->r_type;
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ ((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
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;
bfd_vma *addendp;
{
-
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;
#ifdef COFF_WITH_PE
+ /* Cancel out code in _bfd_coff_generic_relocate_section. */
*addendp = 0;
#endif
@@ -458,10 +475,8 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
return howto;
}
-
#define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
-
static reloc_howto_type *
coff_i386_reloc_type_lookup (abfd, code)
bfd *abfd ATTRIBUTE_UNUSED;
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 1f39394..b87e814 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -131,7 +131,7 @@ SUBSUBSECTION
moment. To port BFD, that person will have to add more @code{#defines}.
Three of the bit twiddling routines are exported to
@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
bit twiddlers are exported for @code{gas};
@code{coff_swap_aux_out}, @code{coff_swap_sym_out},
@@ -2749,7 +2749,7 @@ coff_write_object_contents (abfd)
#ifdef COFF_LONG_SECTION_NAMES
/* 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;
@@ -2844,10 +2844,11 @@ coff_write_object_contents (abfd)
#endif
#ifdef COFF_IMAGE_WITH_PE
- /* suppress output of the sections if they are null. ld includes
- the bss and data sections even if there is no size assigned
- to them. NT loader doesn't like it if these section headers are
- included if the sections themselves are not needed */
+ /* Suppress output of the sections if they are null. ld
+ includes the bss and data sections even if there is no size
+ assigned to them. NT loader doesn't like it if these section
+ headers are included if the sections themselves are not
+ needed. See also coff_compute_section_file_positions. */
if (section.s_size == 0)
internal_f.f_nscns--;
else
@@ -3472,6 +3473,9 @@ SUBSUBSECTION
base of the line number information for the table is stored in
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
table, and each symbol which marks a function is marked by
pointing its...
@@ -3561,6 +3565,10 @@ coff_slurp_line_table (abfd, asect)
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
coff_slurp_symbol_table (abfd)
bfd * abfd;
@@ -3726,7 +3734,7 @@ coff_slurp_symbol_table (abfd)
case C_THUMBSTATFUNC:/* Thumb static function */
#endif
case C_LABEL: /* label */
- if (src->u.syment.n_scnum == -2)
+ if (src->u.syment.n_scnum == N_DEBUG)
dst->symbol.flags = BSF_DEBUGGING;
else
dst->symbol.flags = BSF_LOCAL;
@@ -3854,6 +3862,13 @@ coff_slurp_symbol_table (abfd)
break;
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_ULABEL: /* undefined label */
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;
{
abort ();
+ return 0;
}
#endif
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index c9d23f2..3df9e23 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -1523,7 +1523,7 @@ _bfd_coff_link_input_bfd (finfo, input_bfd)
{
const char *elename;
char elebuf[SYMNMLEN + 1];
- char *copy;
+ char *name_copy;
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)
return false;
- copy = (char *) bfd_alloc (input_bfd, strlen (elename) + 1);
- if (copy == NULL)
+ name_copy = (char *) bfd_alloc (input_bfd,
+ strlen (elename) + 1);
+ if (name_copy == NULL)
return false;
- strcpy (copy, elename);
+ strcpy (name_copy, elename);
- (*epp)->name = copy;
+ (*epp)->name = name_copy;
(*epp)->type = islp->n_type;
(*epp)->tagndx = 0;
if (islp->n_numaux >= 1
diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h
index a0362ca..790eeb0 100644
--- a/bfd/libcoff-in.h
+++ b/bfd/libcoff-in.h
@@ -56,7 +56,7 @@ typedef struct coff_tdata
file_ptr sym_filepos;
struct coff_ptr_struct *raw_syments;
- unsigned int raw_syment_count;
+ unsigned long raw_syment_count;
/* These are only valid once writing has begun */
long int relocbase;
@@ -97,6 +97,9 @@ typedef struct coff_tdata
/* Used by coff_find_nearest_line. */
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,
used by ARM code. */
flagword flags;
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index fb3d5be..5b3d703 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -56,7 +56,7 @@ typedef struct coff_tdata
file_ptr sym_filepos;
struct coff_ptr_struct *raw_syments;
- unsigned int raw_syment_count;
+ unsigned long raw_syment_count;
/* These are only valid once writing has begun */
long int relocbase;
@@ -97,6 +97,9 @@ typedef struct coff_tdata
/* Used by coff_find_nearest_line. */
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,
used by ARM code. */
flagword flags;