* ecoff.c, ecofflink.c, ecoffswap.h, srec.c: Likewise.
* elf32-i386.c: Likewise.
* elfcode.h (bfd_section_from_shdr): Make i unsigned; remove old
#if 0 code.
(elf_write_phdrs): Make i unsigned.
(map_program_segments): Make i and n_left unsigned.
(assign_file_positions_except_relocs): Make i unsigned.
(write_shdrs_and_ehdr): Make count unsigned.
(assign_file_positions_for_relocs): Make i unsigned.
(NAME(bfd,elf_write_object_contents)): Make count unsigned.
(section_from_elf_index): Make index argument unsigned.
+Sat Feb 26 10:00:45 1994 Ian Lance Taylor (ian@cygnus.com)
+
+ * reloc.c (_bfd_relocate_contents): Adjust handling of overflow to
+ avoid depending upon right shifts of signed numbers, and to
+ correct handling of src_mask with lower bits zero.
+
+ * aoutx.h, archive.c: Add casts to avoid warnings from SVR4 cc.
+ * ecoff.c, ecofflink.c, ecoffswap.h, srec.c: Likewise.
+ * elf32-i386.c: Likewise.
+ * elfcode.h (bfd_section_from_shdr): Make i unsigned; remove old
+ #if 0 code.
+ (elf_write_phdrs): Make i unsigned.
+ (map_program_segments): Make i and n_left unsigned.
+ (assign_file_positions_except_relocs): Make i unsigned.
+ (write_shdrs_and_ehdr): Make count unsigned.
+ (assign_file_positions_for_relocs): Make i unsigned.
+ (NAME(bfd,elf_write_object_contents)): Make count unsigned.
+ (section_from_elf_index): Make index argument unsigned.
+
Fri Feb 25 21:34:58 1994 Ian Lance Taylor (ian@cygnus.com)
* elfcode.h: Don't include assert.h.
configuration (IE for i960), so ensure that all such uninitialized
fields are zero'd out. There are places where two of these structs
are memcmp'd, and thus the contents do matter. */
- memset (execp, 0, sizeof (struct internal_exec));
+ memset ((PTR) execp, 0, sizeof (struct internal_exec));
/* Now fill in fields in the execp, from the bytes in the raw data. */
execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
execp->a_text = GET_WORD (abfd, bytes->e_text);
rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
if (rawptr == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return 0;
}
{
struct aout_data_struct *rawptr;
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
/* Use an intermediate variable for clarity */
rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
if (rawptr == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL))
{
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return false;
}
if (adata(abfd).magic != undecided_magic) return true;
if (!copy || !reloc)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
cache_ptr->type = N_BSS;
break;
default:
- bfd_error = bad_value;
+ bfd_set_error (bfd_error_bad_value);
return false;
}
else if (bfd_get_output_section(cache_ptr) == NULL) {
/* Protect the bfd_is_com_section call.
This case occurs, e.g., for the *DEBUG* section of a COFF file. */
- bfd_error = nonrepresentable_section;
+ bfd_set_error (bfd_error_nonrepresentable_section);
return false;
}
else if (bfd_is_com_section (bfd_get_output_section (cache_ptr))) {
sym_pointer->e_type[0] = (N_UNDF | N_EXT);
}
else {
- bfd_error = nonrepresentable_section;
+ bfd_set_error (bfd_error_nonrepresentable_section);
return false;
}
(aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
if (!new)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
new->symbol.the_bfd = abfd;
symbol_size = exec_hdr(abfd)->a_syms;
if (symbol_size == 0)
{
- bfd_error = no_symbols;
+ bfd_set_error (bfd_error_no_symbols);
return false;
}
syms = (struct external_nlist *) malloc(symbol_size);
if (!strings || !cached || !syms)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
bfd_alloc_by_size_t (abfd, sizeof (struct stringtab_entry));
if (!entry)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
abort(); /* FIXME */
}
reloc_size = exec_hdr(abfd)->a_trsize;
else
{
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return false;
}
if (!reloc_cache)
{
nomem:
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
{
bfd_release (abfd, relocs);
bfd_release (abfd, reloc_cache);
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return false;
}
natsize = each_size * count;
native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_size_type dynrel_count = 0;
if (bfd_get_format (abfd) != bfd_object) {
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return 0;
}
if (asect->flags & SEC_CONSTRUCTOR) {
((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd))
+ dynrel_count + 1));
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return 0;
}
bfd_hash_allocate (table, sizeof (struct aout_link_hash_entry)));
if (ret == (struct aout_link_hash_entry *) NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (struct bfd_hash_entry *) ret;
}
malloc (sizeof (struct aout_link_hash_table)));
if (ret == (struct aout_link_hash_table *) NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (struct bfd_link_hash_table *) NULL;
}
if (! _bfd_link_hash_table_init (&ret->root, abfd,
return _bfd_generic_link_add_archive_symbols
(abfd, info, aout_link_check_archive_element);
default:
- bfd_error = wrong_format;
+ bfd_set_error (bfd_error_wrong_format);
return false;
}
}
malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
if (syms == (struct external_nlist *) NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
strings = (char *) malloc ((size_t) stringsize);
if (strings == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
* sizeof (struct aout_link_hash_entry *))));
if (!sym_hash)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
obj_aout_sym_hashes (abfd) = sym_hash;
intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
>> RNDX_BITS1_INDEX_SH_LITTLE)
| (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
- | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
+ | ((unsigned int) ext->r_bits[3]
+ << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
}
#ifdef TEST
bfd_set_error (bfd_error_no_memory);
return (asymbol *) NULL;
}
- memset (new, 0, sizeof *new);
+ memset ((PTR) new, 0, sizeof *new);
new->symbol.section = (asection *) NULL;
new->fdr = (FDR *) NULL;
new->local = false;
asymbol *sym;
struct internal_reloc in;
- memset (&in, 0, sizeof in);
+ memset ((PTR) &in, 0, sizeof in);
reloc = *reloc_ptr_ptr;
sym = *reloc->sym_ptr_ptr;
ret->indx = -1;
ret->abfd = NULL;
}
- memset (&ret->esym, 0, sizeof ret->esym);
+ memset ((PTR) &ret->esym, 0, sizeof ret->esym);
return (struct bfd_hash_entry *) ret;
}
asymbol **sym_end;
PTR external_fdr;
- memset (&fdr, 0, sizeof fdr);
+ memset ((PTR) &fdr, 0, sizeof fdr);
sec = bfd_get_section_by_name (input_bfd, ".text");
if (sec != NULL)
if (((*sym_ptr)->flags & BSF_EXPORT) != 0)
continue;
- memset (&internal_sym, 0, sizeof internal_sym);
+ memset ((PTR) &internal_sym, 0, sizeof internal_sym);
internal_sym.iss = ecoff_add_string (ainfo, info, output_debug, &fdr,
(*sym_ptr)->name);
if (add != debug_align)
{
if (debug->line != (unsigned char *) NULL)
- memset (debug->line + symhdr->cbLine, 0, add);
+ memset ((PTR) (debug->line + symhdr->cbLine), 0, add);
symhdr->cbLine += add;
}
if (add != debug_align)
{
if (debug->ss != (char *) NULL)
- memset (debug->ss + symhdr->issMax, 0, add);
+ memset ((PTR) (debug->ss + symhdr->issMax), 0, add);
symhdr->issMax += add;
}
if (add != debug_align)
{
if (debug->ssext != (char *) NULL)
- memset (debug->ssext + symhdr->issExtMax, 0, add);
+ memset ((PTR) (debug->ssext + symhdr->issExtMax), 0, add);
symhdr->issExtMax += add;
}
if (add != aux_align)
{
if (debug->external_aux != (union aux_ext *) NULL)
- memset (debug->external_aux + symhdr->iauxMax, 0,
+ memset ((PTR) (debug->external_aux + symhdr->iauxMax), 0,
add * sizeof (union aux_ext));
symhdr->iauxMax += add;
}
if (add != rfd_align)
{
if (debug->external_rfd != (PTR) NULL)
- memset (((char *) debug->external_rfd
- + symhdr->crfd * swap->external_rfd_size),
+ memset ((PTR) ((char *) debug->external_rfd
+ + symhdr->crfd * swap->external_rfd_size),
0, add * swap->external_rfd_size);
symhdr->crfd += add;
}
where += swap->external_hdr_size;
+ symhdr->magic = swap->sym_magic;
+
/* Fill in the file offsets. */
#define SET(offset, count, size) \
if (symhdr->count == 0) \
i = swap->debug_align - (total & (swap->debug_align - 1));
s = (bfd_byte *) alloca (i);
- memset (s, 0, i);
+ memset ((PTR) s, 0, i);
if (bfd_write ((PTR) s, 1, i, abfd) != i)
return false;
}
i = swap->debug_align - (total & (swap->debug_align - 1));
s = (bfd_byte *) alloca (i);
- memset (s, 0, i);
+ memset ((PTR) s, 0, i);
if (bfd_write ((PTR) s, 1, i, abfd) != i)
return false;
}
i = (swap->debug_align
- (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
s = (bfd_byte *) alloca (i);
- memset (s, 0, i);
+ memset ((PTR) s, 0, i);
if (bfd_write ((PTR) s, 1, i, abfd) != i)
return false;
}
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
- * This file contains changes from the Open Software Foundation.
- */
-
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
enum reloc_type
{
R_386_NONE = 0,
- R_386_32, R_386_PC32,
- R_386_GOT32, R_386_PLT32,
+ R_386_32,
+ R_386_PC32,
+ R_386_GOT32,
+ R_386_PLT32,
R_386_COPY,
- R_386_GLOB_DAT, R_386_JUMP_SLOT,
+ R_386_GLOB_DAT,
+ R_386_JUMP_SLOT,
R_386_RELATIVE,
- R_386_GOTOFF, R_386_GOTPC,
+ R_386_GOTOFF,
+ R_386_GOTPC,
R_386_max
};
static CONST char *CONST reloc_type_names[] =
{
"R_386_NONE",
- "R_386_32", "R_386_PC32",
- "R_386_GOT32", "R_386_PLT32",
+ "R_386_32",
+ "R_386_PC32",
+ "R_386_GOT32",
+ "R_386_PLT32",
"R_386_COPY",
- "R_386_GLOB_DAT", "R_386_JUMP_SLOT",
+ "R_386_GLOB_DAT",
+ "R_386_JUMP_SLOT",
"R_386_RELATIVE",
- "R_386_GOTOFF", "R_386_GOTPC",
+ "R_386_GOTOFF",
+ "R_386_GOTPC",
};
#endif
-
static reloc_howto_type elf_howto_table[]=
{
- HOWTO(R_386_NONE, 0,0, 0,false,0, complain_overflow_dont, 0,"R_386_NONE", false,0x00000000,0x00000000,false),
- HOWTO(R_386_32, 0,2,32,false,0, complain_overflow_bitfield, 0,"R_386_32", false,0xffffffff,0xffffffff,false),
- HOWTO(R_386_PC32, 0,2,32,true, 0, complain_overflow_signed, 0,"R_386_PC32", false,0xffffffff,0xffffffff,false),
- HOWTO(R_386_GOT32, 0,2,32,false,0, complain_overflow_bitfield, 0,"R_386_GOT32",false,0xffffffff,0xffffffff,false)
+ HOWTO(R_386_NONE, 0,0, 0,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_NONE", true,0x00000000,0x00000000,false),
+ HOWTO(R_386_32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_32", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_PC32, 0,2,32,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC32", true,0xffffffff,0xffffffff,true),
+ HOWTO(R_386_GOT32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOT32", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_PLT32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PLT32", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_COPY, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_COPY", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_GLOB_DAT, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GLOB_DAT", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_JUMP_SLOT, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_JUMP_SLOT",true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_RELATIVE, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_RELATIVE", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_GOTOFF, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTOFF", true,0xffffffff,0xffffffff,false),
+ HOWTO(R_386_GOTPC, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTPC", true,0xffffffff,0xffffffff,false),
};
#ifdef DEBUG_GEN_RELOC
TRACE ("BFD_RELOC_PC32");
return &elf_howto_table[ (int)R_386_PC32 ];
+ case BFD_RELOC_386_GOT32:
+ TRACE ("BFD_RELOC_386_GOT32");
+ return &elf_howto_table[ (int)R_386_GOT32 ];
+
+ case BFD_RELOC_386_PLT32:
+ TRACE ("BFD_RELOC_386_PLT32");
+ return &elf_howto_table[ (int)R_386_PLT32 ];
+
+ case BFD_RELOC_386_COPY:
+ TRACE ("BFD_RELOC_386_COPY");
+ return &elf_howto_table[ (int)R_386_COPY ];
+
+ case BFD_RELOC_386_GLOB_DAT:
+ TRACE ("BFD_RELOC_386_GLOB_DAT");
+ return &elf_howto_table[ (int)R_386_GLOB_DAT ];
+
+ case BFD_RELOC_386_JUMP_SLOT:
+ TRACE ("BFD_RELOC_386_JUMP_SLOT");
+ return &elf_howto_table[ (int)R_386_JUMP_SLOT ];
+
+ case BFD_RELOC_386_RELATIVE:
+ TRACE ("BFD_RELOC_386_RELATIVE");
+ return &elf_howto_table[ (int)R_386_RELATIVE ];
+
+ case BFD_RELOC_386_GOTOFF:
+ TRACE ("BFD_RELOC_386_GOTOFF");
+ return &elf_howto_table[ (int)R_386_GOTOFF ];
+
+ case BFD_RELOC_386_GOTPC:
+ TRACE ("BFD_RELOC_386_GOTPC");
+ return &elf_howto_table[ (int)R_386_GOTPC ];
+
default:
- abort ();
+ break;
}
TRACE ("Unknown");
arelent *cache_ptr AND
Elf32_Internal_Rela *dst)
{
- BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < R_386_GOT32);
+ BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max);
cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
}
arelent *cache_ptr AND
Elf32_Internal_Rel *dst)
{
- BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < R_386_GOT32);
+ BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max);
cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
}
#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
#define TARGET_LITTLE_NAME "elf32-i386"
#define ELF_ARCH bfd_arch_i386
+#define ELF_MACHINE_CODE EM_386
#define elf_info_to_howto elf_i386_info_to_howto
#define elf_info_to_howto_rel elf_i386_info_to_howto_rel
#define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup
+#define ELF_MAXPAGESIZE 0x1000
#include "elf32-target.h"
/* Forward declarations of static functions */
-static struct sec * section_from_elf_index PARAMS ((bfd *, int));
+static struct sec * section_from_elf_index PARAMS ((bfd *, unsigned int));
static int elf_section_from_bfd_section PARAMS ((bfd *, struct sec *));
return true;
}
{
- int i;
+ unsigned int i;
for (i = 1; i < ehdr->e_shnum; i++)
{
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
Elf_External_Shdr x_shdr; /* Section header table entry, external form */
Elf_Internal_Shdr *i_shdrp; /* Section header table, internal form */
- int shindex;
+ unsigned int shindex;
char *shstrtab; /* Internal copy of section header stringtab */
struct elf_backend_data *ebd;
struct elf_obj_tdata *preserved_tdata = elf_tdata (abfd);
bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx);
}
-#if 0
- for (shindex = i_ehdrp->e_shnum - 1; shindex >= 0; shindex--)
- {
- if (!strcmp (elf_string_from_elf_strtab (abfd,
- i_shdrp[shindex].sh_name),
- ".strtab"))
- {
- elf_tdata(abfd)->strtab_hdr = i_shdrp[shindex];
- elf_elfsections(abfd)[shindex] = &elf_tdata(abfd)->strtab_hdr;
- }
- else if (!strcmp (elf_string_from_elf_strtab (abfd,
- i_shdrp[shindex].sh_name),
- ".symtab"))
- {
- elf_tdata(abfd)->symtab_hdr = i_shdrp[shindex];
- elf_elfsections(abfd)[shindex] = &elf_tdata(abfd)->symtab_hdr;
- elf_onesymtab (abfd) = shindex;
- }
- }
-#endif
-
/* Read in the string table containing the names of the sections. We
will need the base pointer to this table later. */
/* We read this inline now, so that we don't have to go through
{
/* first program header entry goes after the file header */
int outbase = i_ehdrp->e_phoff;
- int i;
+ unsigned int i;
Elf_External_Phdr x_phdr;
for (i = 0; i < phdr_cnt; i++)
Elf_Internal_Shdr *i_shdrp;
Elf_Internal_Phdr *phdr;
char *done;
- int i, n_left = 0;
+ unsigned int i, n_left = 0;
file_ptr lowest_offset = 0;
struct seg_info *seg = NULL;
struct elf_obj_tdata *t = elf_tdata (abfd);
file_ptr off;
- int i;
+ unsigned int i;
Elf_Internal_Shdr **i_shdrpp = elf_elfsections (abfd);
Elf_Internal_Shdr *i_shdrp;
Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
Elf_External_Shdr *x_shdrp; /* Section header table, external form */
Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
- int count;
+ unsigned int count;
struct strtab *shstrtab;
i_ehdrp = elf_elfheader (abfd);
bfd *abfd;
{
file_ptr off = elf_tdata(abfd)->next_file_pos;
- int i;
+ unsigned int i;
Elf_Internal_Shdr **shdrpp = elf_elfsections (abfd);
Elf_Internal_Shdr *shdrp;
for (i = 1; i < elf_elfheader(abfd)->e_shnum; i++)
struct elf_backend_data *bed = get_elf_backend_data (abfd);
Elf_Internal_Ehdr *i_ehdrp;
Elf_Internal_Shdr **i_shdrp;
- int count;
+ unsigned int count;
/* We don't know how to write dynamic objects. Specifically, we
don't know how to construct the program header. */
static struct sec *
DEFUN (section_from_elf_index, (abfd, index),
bfd * abfd AND
- int index)
+ unsigned int index)
{
/* @@ Is bfd_com_section really correct in all the places it could
be returned from this routine? */
bfd_set_error (bfd_error_no_memory);
return false;
}
- memcpy (data, location, bytes_to_do);
+ memcpy ((PTR) data, location, bytes_to_do);
if ((section->lma + offset + bytes_to_do) <= 0xffff)
{