summaryrefslogtreecommitdiffstats
path: root/bfd/som.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2001-09-18 09:57:26 +0000
committerAlan Modra <amodra@gmail.com>2001-09-18 09:57:26 +0000
commitdc810e3900d47ab2eea86d50231ff2e70b596847 (patch)
tree13fc3d267fb99c450380f08a0775b2dff076b8d7 /bfd/som.c
parent417412a27c87b0e738a21122a38d48aa35317eb8 (diff)
downloadppe42-binutils-dc810e3900d47ab2eea86d50231ff2e70b596847.tar.gz
ppe42-binutils-dc810e3900d47ab2eea86d50231ff2e70b596847.zip
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become bfd_bread and bfd_bwrite. o bfd_*alloc now all take a bfd_size_type arg, and will error if size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files or bugs in linker scripts etc. o file_ptr becomes a bfd_signed_vma. Besides matching sizes with various other types involved in handling sections, this should make it easier for bfd to support a 64 bit off_t on 32 bit hosts that provide it. o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*) generally available. They now cast their args to bfd_vma and bfd_byte * as appropriate, which removes a swag of casts from the source. o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and aout-encap.c. o Zillions of formatting and -Wconversion fixes.
Diffstat (limited to 'bfd/som.c')
-rw-r--r--bfd/som.c1079
1 files changed, 561 insertions, 518 deletions
diff --git a/bfd/som.c b/bfd/som.c
index 1b877d5f26..0ea1353254 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -102,7 +102,7 @@
/* Generic alignment macro. */
#define SOM_ALIGN(val, alignment) \
- (((val) + (alignment) - 1) & ~((alignment) - 1))
+ (((val) + (alignment) - 1) &~ ((unsigned long) (alignment) - 1))
/* SOM allows any one of the four previous relocations to be reused
with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP
@@ -190,8 +190,8 @@ static boolean som_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
unsigned long));
static boolean som_find_nearest_line PARAMS ((bfd *, asection *,
asymbol **, bfd_vma,
- CONST char **,
- CONST char **,
+ const char **,
+ const char **,
unsigned int *));
static void som_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
static asection * bfd_section_from_som_symbol PARAMS ((bfd *,
@@ -214,7 +214,8 @@ static unsigned char * try_prev_fixup PARAMS ((bfd *, int *, unsigned char *,
static unsigned char * som_reloc_skip PARAMS ((bfd *, unsigned int,
unsigned char *, unsigned int *,
struct reloc_queue *));
-static unsigned char * som_reloc_addend PARAMS ((bfd *, int, unsigned char *,
+static unsigned char * som_reloc_addend PARAMS ((bfd *, bfd_vma,
+ unsigned char *,
unsigned int *,
struct reloc_queue *));
static unsigned char * som_reloc_call PARAMS ((bfd *, unsigned char *,
@@ -383,315 +384,315 @@ struct fixup_format {
static const struct fixup_format som_fixup_formats[256] = {
/* R_NO_RELOCATION */
- 0, "LD1+4*=", /* 0x00 */
- 1, "LD1+4*=", /* 0x01 */
- 2, "LD1+4*=", /* 0x02 */
- 3, "LD1+4*=", /* 0x03 */
- 4, "LD1+4*=", /* 0x04 */
- 5, "LD1+4*=", /* 0x05 */
- 6, "LD1+4*=", /* 0x06 */
- 7, "LD1+4*=", /* 0x07 */
- 8, "LD1+4*=", /* 0x08 */
- 9, "LD1+4*=", /* 0x09 */
- 10, "LD1+4*=", /* 0x0a */
- 11, "LD1+4*=", /* 0x0b */
- 12, "LD1+4*=", /* 0x0c */
- 13, "LD1+4*=", /* 0x0d */
- 14, "LD1+4*=", /* 0x0e */
- 15, "LD1+4*=", /* 0x0f */
- 16, "LD1+4*=", /* 0x10 */
- 17, "LD1+4*=", /* 0x11 */
- 18, "LD1+4*=", /* 0x12 */
- 19, "LD1+4*=", /* 0x13 */
- 20, "LD1+4*=", /* 0x14 */
- 21, "LD1+4*=", /* 0x15 */
- 22, "LD1+4*=", /* 0x16 */
- 23, "LD1+4*=", /* 0x17 */
- 0, "LD8<b+1+4*=", /* 0x18 */
- 1, "LD8<b+1+4*=", /* 0x19 */
- 2, "LD8<b+1+4*=", /* 0x1a */
- 3, "LD8<b+1+4*=", /* 0x1b */
- 0, "LD16<c+1+4*=", /* 0x1c */
- 1, "LD16<c+1+4*=", /* 0x1d */
- 2, "LD16<c+1+4*=", /* 0x1e */
- 0, "Ld1+=", /* 0x1f */
+ { 0, "LD1+4*=" }, /* 0x00 */
+ { 1, "LD1+4*=" }, /* 0x01 */
+ { 2, "LD1+4*=" }, /* 0x02 */
+ { 3, "LD1+4*=" }, /* 0x03 */
+ { 4, "LD1+4*=" }, /* 0x04 */
+ { 5, "LD1+4*=" }, /* 0x05 */
+ { 6, "LD1+4*=" }, /* 0x06 */
+ { 7, "LD1+4*=" }, /* 0x07 */
+ { 8, "LD1+4*=" }, /* 0x08 */
+ { 9, "LD1+4*=" }, /* 0x09 */
+ { 10, "LD1+4*=" }, /* 0x0a */
+ { 11, "LD1+4*=" }, /* 0x0b */
+ { 12, "LD1+4*=" }, /* 0x0c */
+ { 13, "LD1+4*=" }, /* 0x0d */
+ { 14, "LD1+4*=" }, /* 0x0e */
+ { 15, "LD1+4*=" }, /* 0x0f */
+ { 16, "LD1+4*=" }, /* 0x10 */
+ { 17, "LD1+4*=" }, /* 0x11 */
+ { 18, "LD1+4*=" }, /* 0x12 */
+ { 19, "LD1+4*=" }, /* 0x13 */
+ { 20, "LD1+4*=" }, /* 0x14 */
+ { 21, "LD1+4*=" }, /* 0x15 */
+ { 22, "LD1+4*=" }, /* 0x16 */
+ { 23, "LD1+4*=" }, /* 0x17 */
+ { 0, "LD8<b+1+4*=" }, /* 0x18 */
+ { 1, "LD8<b+1+4*=" }, /* 0x19 */
+ { 2, "LD8<b+1+4*=" }, /* 0x1a */
+ { 3, "LD8<b+1+4*=" }, /* 0x1b */
+ { 0, "LD16<c+1+4*=" }, /* 0x1c */
+ { 1, "LD16<c+1+4*=" }, /* 0x1d */
+ { 2, "LD16<c+1+4*=" }, /* 0x1e */
+ { 0, "Ld1+=" }, /* 0x1f */
/* R_ZEROES */
- 0, "Lb1+4*=", /* 0x20 */
- 1, "Ld1+=", /* 0x21 */
+ { 0, "Lb1+4*=" }, /* 0x20 */
+ { 1, "Ld1+=" }, /* 0x21 */
/* R_UNINIT */
- 0, "Lb1+4*=", /* 0x22 */
- 1, "Ld1+=", /* 0x23 */
+ { 0, "Lb1+4*=" }, /* 0x22 */
+ { 1, "Ld1+=" }, /* 0x23 */
/* R_RELOCATION */
- 0, "L4=", /* 0x24 */
+ { 0, "L4=" }, /* 0x24 */
/* R_DATA_ONE_SYMBOL */
- 0, "L4=Sb=", /* 0x25 */
- 1, "L4=Sd=", /* 0x26 */
+ { 0, "L4=Sb=" }, /* 0x25 */
+ { 1, "L4=Sd=" }, /* 0x26 */
/* R_DATA_PLEBEL */
- 0, "L4=Sb=", /* 0x27 */
- 1, "L4=Sd=", /* 0x28 */
+ { 0, "L4=Sb=" }, /* 0x27 */
+ { 1, "L4=Sd=" }, /* 0x28 */
/* R_SPACE_REF */
- 0, "L4=", /* 0x29 */
+ { 0, "L4=" }, /* 0x29 */
/* R_REPEATED_INIT */
- 0, "L4=Mb1+4*=", /* 0x2a */
- 1, "Lb4*=Mb1+L*=", /* 0x2b */
- 2, "Lb4*=Md1+4*=", /* 0x2c */
- 3, "Ld1+=Me1+=", /* 0x2d */
- 0, "", /* 0x2e */
- 0, "", /* 0x2f */
+ { 0, "L4=Mb1+4*=" }, /* 0x2a */
+ { 1, "Lb4*=Mb1+L*=" }, /* 0x2b */
+ { 2, "Lb4*=Md1+4*=" }, /* 0x2c */
+ { 3, "Ld1+=Me1+=" }, /* 0x2d */
+ { 0, "" }, /* 0x2e */
+ { 0, "" }, /* 0x2f */
/* R_PCREL_CALL */
- 0, "L4=RD=Sb=", /* 0x30 */
- 1, "L4=RD=Sb=", /* 0x31 */
- 2, "L4=RD=Sb=", /* 0x32 */
- 3, "L4=RD=Sb=", /* 0x33 */
- 4, "L4=RD=Sb=", /* 0x34 */
- 5, "L4=RD=Sb=", /* 0x35 */
- 6, "L4=RD=Sb=", /* 0x36 */
- 7, "L4=RD=Sb=", /* 0x37 */
- 8, "L4=RD=Sb=", /* 0x38 */
- 9, "L4=RD=Sb=", /* 0x39 */
- 0, "L4=RD8<b+=Sb=",/* 0x3a */
- 1, "L4=RD8<b+=Sb=",/* 0x3b */
- 0, "L4=RD8<b+=Sd=",/* 0x3c */
- 1, "L4=RD8<b+=Sd=",/* 0x3d */
+ { 0, "L4=RD=Sb=" }, /* 0x30 */
+ { 1, "L4=RD=Sb=" }, /* 0x31 */
+ { 2, "L4=RD=Sb=" }, /* 0x32 */
+ { 3, "L4=RD=Sb=" }, /* 0x33 */
+ { 4, "L4=RD=Sb=" }, /* 0x34 */
+ { 5, "L4=RD=Sb=" }, /* 0x35 */
+ { 6, "L4=RD=Sb=" }, /* 0x36 */
+ { 7, "L4=RD=Sb=" }, /* 0x37 */
+ { 8, "L4=RD=Sb=" }, /* 0x38 */
+ { 9, "L4=RD=Sb=" }, /* 0x39 */
+ { 0, "L4=RD8<b+=Sb=" }, /* 0x3a */
+ { 1, "L4=RD8<b+=Sb=" }, /* 0x3b */
+ { 0, "L4=RD8<b+=Sd=" }, /* 0x3c */
+ { 1, "L4=RD8<b+=Sd=" }, /* 0x3d */
/* R_SHORT_PCREL_MODE */
- 0, "", /* 0x3e */
+ { 0, "" }, /* 0x3e */
/* R_LONG_PCREL_MODE */
- 0, "", /* 0x3f */
+ { 0, "" }, /* 0x3f */
/* R_ABS_CALL */
- 0, "L4=RD=Sb=", /* 0x40 */
- 1, "L4=RD=Sb=", /* 0x41 */
- 2, "L4=RD=Sb=", /* 0x42 */
- 3, "L4=RD=Sb=", /* 0x43 */
- 4, "L4=RD=Sb=", /* 0x44 */
- 5, "L4=RD=Sb=", /* 0x45 */
- 6, "L4=RD=Sb=", /* 0x46 */
- 7, "L4=RD=Sb=", /* 0x47 */
- 8, "L4=RD=Sb=", /* 0x48 */
- 9, "L4=RD=Sb=", /* 0x49 */
- 0, "L4=RD8<b+=Sb=",/* 0x4a */
- 1, "L4=RD8<b+=Sb=",/* 0x4b */
- 0, "L4=RD8<b+=Sd=",/* 0x4c */
- 1, "L4=RD8<b+=Sd=",/* 0x4d */
+ { 0, "L4=RD=Sb=" }, /* 0x40 */
+ { 1, "L4=RD=Sb=" }, /* 0x41 */
+ { 2, "L4=RD=Sb=" }, /* 0x42 */
+ { 3, "L4=RD=Sb=" }, /* 0x43 */
+ { 4, "L4=RD=Sb=" }, /* 0x44 */
+ { 5, "L4=RD=Sb=" }, /* 0x45 */
+ { 6, "L4=RD=Sb=" }, /* 0x46 */
+ { 7, "L4=RD=Sb=" }, /* 0x47 */
+ { 8, "L4=RD=Sb=" }, /* 0x48 */
+ { 9, "L4=RD=Sb=" }, /* 0x49 */
+ { 0, "L4=RD8<b+=Sb=" }, /* 0x4a */
+ { 1, "L4=RD8<b+=Sb=" }, /* 0x4b */
+ { 0, "L4=RD8<b+=Sd=" }, /* 0x4c */
+ { 1, "L4=RD8<b+=Sd=" }, /* 0x4d */
/* R_RESERVED */
- 0, "", /* 0x4e */
- 0, "", /* 0x4f */
+ { 0, "" }, /* 0x4e */
+ { 0, "" }, /* 0x4f */
/* R_DP_RELATIVE */
- 0, "L4=SD=", /* 0x50 */
- 1, "L4=SD=", /* 0x51 */
- 2, "L4=SD=", /* 0x52 */
- 3, "L4=SD=", /* 0x53 */
- 4, "L4=SD=", /* 0x54 */
- 5, "L4=SD=", /* 0x55 */
- 6, "L4=SD=", /* 0x56 */
- 7, "L4=SD=", /* 0x57 */
- 8, "L4=SD=", /* 0x58 */
- 9, "L4=SD=", /* 0x59 */
- 10, "L4=SD=", /* 0x5a */
- 11, "L4=SD=", /* 0x5b */
- 12, "L4=SD=", /* 0x5c */
- 13, "L4=SD=", /* 0x5d */
- 14, "L4=SD=", /* 0x5e */
- 15, "L4=SD=", /* 0x5f */
- 16, "L4=SD=", /* 0x60 */
- 17, "L4=SD=", /* 0x61 */
- 18, "L4=SD=", /* 0x62 */
- 19, "L4=SD=", /* 0x63 */
- 20, "L4=SD=", /* 0x64 */
- 21, "L4=SD=", /* 0x65 */
- 22, "L4=SD=", /* 0x66 */
- 23, "L4=SD=", /* 0x67 */
- 24, "L4=SD=", /* 0x68 */
- 25, "L4=SD=", /* 0x69 */
- 26, "L4=SD=", /* 0x6a */
- 27, "L4=SD=", /* 0x6b */
- 28, "L4=SD=", /* 0x6c */
- 29, "L4=SD=", /* 0x6d */
- 30, "L4=SD=", /* 0x6e */
- 31, "L4=SD=", /* 0x6f */
- 32, "L4=Sb=", /* 0x70 */
- 33, "L4=Sd=", /* 0x71 */
+ { 0, "L4=SD=" }, /* 0x50 */
+ { 1, "L4=SD=" }, /* 0x51 */
+ { 2, "L4=SD=" }, /* 0x52 */
+ { 3, "L4=SD=" }, /* 0x53 */
+ { 4, "L4=SD=" }, /* 0x54 */
+ { 5, "L4=SD=" }, /* 0x55 */
+ { 6, "L4=SD=" }, /* 0x56 */
+ { 7, "L4=SD=" }, /* 0x57 */
+ { 8, "L4=SD=" }, /* 0x58 */
+ { 9, "L4=SD=" }, /* 0x59 */
+ { 10, "L4=SD=" }, /* 0x5a */
+ { 11, "L4=SD=" }, /* 0x5b */
+ { 12, "L4=SD=" }, /* 0x5c */
+ { 13, "L4=SD=" }, /* 0x5d */
+ { 14, "L4=SD=" }, /* 0x5e */
+ { 15, "L4=SD=" }, /* 0x5f */
+ { 16, "L4=SD=" }, /* 0x60 */
+ { 17, "L4=SD=" }, /* 0x61 */
+ { 18, "L4=SD=" }, /* 0x62 */
+ { 19, "L4=SD=" }, /* 0x63 */
+ { 20, "L4=SD=" }, /* 0x64 */
+ { 21, "L4=SD=" }, /* 0x65 */
+ { 22, "L4=SD=" }, /* 0x66 */
+ { 23, "L4=SD=" }, /* 0x67 */
+ { 24, "L4=SD=" }, /* 0x68 */
+ { 25, "L4=SD=" }, /* 0x69 */
+ { 26, "L4=SD=" }, /* 0x6a */
+ { 27, "L4=SD=" }, /* 0x6b */
+ { 28, "L4=SD=" }, /* 0x6c */
+ { 29, "L4=SD=" }, /* 0x6d */
+ { 30, "L4=SD=" }, /* 0x6e */
+ { 31, "L4=SD=" }, /* 0x6f */
+ { 32, "L4=Sb=" }, /* 0x70 */
+ { 33, "L4=Sd=" }, /* 0x71 */
/* R_RESERVED */
- 0, "", /* 0x72 */
- 0, "", /* 0x73 */
- 0, "", /* 0x74 */
- 0, "", /* 0x75 */
- 0, "", /* 0x76 */
- 0, "", /* 0x77 */
+ { 0, "" }, /* 0x72 */
+ { 0, "" }, /* 0x73 */
+ { 0, "" }, /* 0x74 */
+ { 0, "" }, /* 0x75 */
+ { 0, "" }, /* 0x76 */
+ { 0, "" }, /* 0x77 */
/* R_DLT_REL */
- 0, "L4=Sb=", /* 0x78 */
- 1, "L4=Sd=", /* 0x79 */
+ { 0, "L4=Sb=" }, /* 0x78 */
+ { 1, "L4=Sd=" }, /* 0x79 */
/* R_RESERVED */
- 0, "", /* 0x7a */
- 0, "", /* 0x7b */
- 0, "", /* 0x7c */
- 0, "", /* 0x7d */
- 0, "", /* 0x7e */
- 0, "", /* 0x7f */
+ { 0, "" }, /* 0x7a */
+ { 0, "" }, /* 0x7b */
+ { 0, "" }, /* 0x7c */
+ { 0, "" }, /* 0x7d */
+ { 0, "" }, /* 0x7e */
+ { 0, "" }, /* 0x7f */
/* R_CODE_ONE_SYMBOL */
- 0, "L4=SD=", /* 0x80 */
- 1, "L4=SD=", /* 0x81 */
- 2, "L4=SD=", /* 0x82 */
- 3, "L4=SD=", /* 0x83 */
- 4, "L4=SD=", /* 0x84 */
- 5, "L4=SD=", /* 0x85 */
- 6, "L4=SD=", /* 0x86 */
- 7, "L4=SD=", /* 0x87 */
- 8, "L4=SD=", /* 0x88 */
- 9, "L4=SD=", /* 0x89 */
- 10, "L4=SD=", /* 0x8q */
- 11, "L4=SD=", /* 0x8b */
- 12, "L4=SD=", /* 0x8c */
- 13, "L4=SD=", /* 0x8d */
- 14, "L4=SD=", /* 0x8e */
- 15, "L4=SD=", /* 0x8f */
- 16, "L4=SD=", /* 0x90 */
- 17, "L4=SD=", /* 0x91 */
- 18, "L4=SD=", /* 0x92 */
- 19, "L4=SD=", /* 0x93 */
- 20, "L4=SD=", /* 0x94 */
- 21, "L4=SD=", /* 0x95 */
- 22, "L4=SD=", /* 0x96 */
- 23, "L4=SD=", /* 0x97 */
- 24, "L4=SD=", /* 0x98 */
- 25, "L4=SD=", /* 0x99 */
- 26, "L4=SD=", /* 0x9a */
- 27, "L4=SD=", /* 0x9b */
- 28, "L4=SD=", /* 0x9c */
- 29, "L4=SD=", /* 0x9d */
- 30, "L4=SD=", /* 0x9e */
- 31, "L4=SD=", /* 0x9f */
- 32, "L4=Sb=", /* 0xa0 */
- 33, "L4=Sd=", /* 0xa1 */
+ { 0, "L4=SD=" }, /* 0x80 */
+ { 1, "L4=SD=" }, /* 0x81 */
+ { 2, "L4=SD=" }, /* 0x82 */
+ { 3, "L4=SD=" }, /* 0x83 */
+ { 4, "L4=SD=" }, /* 0x84 */
+ { 5, "L4=SD=" }, /* 0x85 */
+ { 6, "L4=SD=" }, /* 0x86 */
+ { 7, "L4=SD=" }, /* 0x87 */
+ { 8, "L4=SD=" }, /* 0x88 */
+ { 9, "L4=SD=" }, /* 0x89 */
+ { 10, "L4=SD=" }, /* 0x8q */
+ { 11, "L4=SD=" }, /* 0x8b */
+ { 12, "L4=SD=" }, /* 0x8c */
+ { 13, "L4=SD=" }, /* 0x8d */
+ { 14, "L4=SD=" }, /* 0x8e */
+ { 15, "L4=SD=" }, /* 0x8f */
+ { 16, "L4=SD=" }, /* 0x90 */
+ { 17, "L4=SD=" }, /* 0x91 */
+ { 18, "L4=SD=" }, /* 0x92 */
+ { 19, "L4=SD=" }, /* 0x93 */
+ { 20, "L4=SD=" }, /* 0x94 */
+ { 21, "L4=SD=" }, /* 0x95 */
+ { 22, "L4=SD=" }, /* 0x96 */
+ { 23, "L4=SD=" }, /* 0x97 */
+ { 24, "L4=SD=" }, /* 0x98 */
+ { 25, "L4=SD=" }, /* 0x99 */
+ { 26, "L4=SD=" }, /* 0x9a */
+ { 27, "L4=SD=" }, /* 0x9b */
+ { 28, "L4=SD=" }, /* 0x9c */
+ { 29, "L4=SD=" }, /* 0x9d */
+ { 30, "L4=SD=" }, /* 0x9e */
+ { 31, "L4=SD=" }, /* 0x9f */
+ { 32, "L4=Sb=" }, /* 0xa0 */
+ { 33, "L4=Sd=" }, /* 0xa1 */
/* R_RESERVED */
- 0, "", /* 0xa2 */
- 0, "", /* 0xa3 */
- 0, "", /* 0xa4 */
- 0, "", /* 0xa5 */
- 0, "", /* 0xa6 */
- 0, "", /* 0xa7 */
- 0, "", /* 0xa8 */
- 0, "", /* 0xa9 */
- 0, "", /* 0xaa */
- 0, "", /* 0xab */
- 0, "", /* 0xac */
- 0, "", /* 0xad */
+ { 0, "" }, /* 0xa2 */
+ { 0, "" }, /* 0xa3 */
+ { 0, "" }, /* 0xa4 */
+ { 0, "" }, /* 0xa5 */
+ { 0, "" }, /* 0xa6 */
+ { 0, "" }, /* 0xa7 */
+ { 0, "" }, /* 0xa8 */
+ { 0, "" }, /* 0xa9 */
+ { 0, "" }, /* 0xaa */
+ { 0, "" }, /* 0xab */
+ { 0, "" }, /* 0xac */
+ { 0, "" }, /* 0xad */
/* R_MILLI_REL */
- 0, "L4=Sb=", /* 0xae */
- 1, "L4=Sd=", /* 0xaf */
+ { 0, "L4=Sb=" }, /* 0xae */
+ { 1, "L4=Sd=" }, /* 0xaf */
/* R_CODE_PLABEL */
- 0, "L4=Sb=", /* 0xb0 */
- 1, "L4=Sd=", /* 0xb1 */
+ { 0, "L4=Sb=" }, /* 0xb0 */
+ { 1, "L4=Sd=" }, /* 0xb1 */
/* R_BREAKPOINT */
- 0, "L4=", /* 0xb2 */
+ { 0, "L4=" }, /* 0xb2 */
/* R_ENTRY */
- 0, "Te=Ue=", /* 0xb3 */
- 1, "Uf=", /* 0xb4 */
+ { 0, "Te=Ue=" }, /* 0xb3 */
+ { 1, "Uf=" }, /* 0xb4 */
/* R_ALT_ENTRY */
- 0, "", /* 0xb5 */
+ { 0, "" }, /* 0xb5 */
/* R_EXIT */
- 0, "", /* 0xb6 */
+ { 0, "" }, /* 0xb6 */
/* R_BEGIN_TRY */
- 0, "", /* 0xb7 */
+ { 0, "" }, /* 0xb7 */
/* R_END_TRY */
- 0, "R0=", /* 0xb8 */
- 1, "Rb4*=", /* 0xb9 */
- 2, "Rd4*=", /* 0xba */
+ { 0, "R0=" }, /* 0xb8 */
+ { 1, "Rb4*=" }, /* 0xb9 */
+ { 2, "Rd4*=" }, /* 0xba */
/* R_BEGIN_BRTAB */
- 0, "", /* 0xbb */
+ { 0, "" }, /* 0xbb */
/* R_END_BRTAB */
- 0, "", /* 0xbc */
+ { 0, "" }, /* 0xbc */
/* R_STATEMENT */
- 0, "Nb=", /* 0xbd */
- 1, "Nc=", /* 0xbe */
- 2, "Nd=", /* 0xbf */
+ { 0, "Nb=" }, /* 0xbd */
+ { 1, "Nc=" }, /* 0xbe */
+ { 2, "Nd=" }, /* 0xbf */
/* R_DATA_EXPR */
- 0, "L4=", /* 0xc0 */
+ { 0, "L4=" }, /* 0xc0 */
/* R_CODE_EXPR */
- 0, "L4=", /* 0xc1 */
+ { 0, "L4=" }, /* 0xc1 */
/* R_FSEL */
- 0, "", /* 0xc2 */
+ { 0, "" }, /* 0xc2 */
/* R_LSEL */
- 0, "", /* 0xc3 */
+ { 0, "" }, /* 0xc3 */
/* R_RSEL */
- 0, "", /* 0xc4 */
+ { 0, "" }, /* 0xc4 */
/* R_N_MODE */
- 0, "", /* 0xc5 */
+ { 0, "" }, /* 0xc5 */
/* R_S_MODE */
- 0, "", /* 0xc6 */
+ { 0, "" }, /* 0xc6 */
/* R_D_MODE */
- 0, "", /* 0xc7 */
+ { 0, "" }, /* 0xc7 */
/* R_R_MODE */
- 0, "", /* 0xc8 */
+ { 0, "" }, /* 0xc8 */
/* R_DATA_OVERRIDE */
- 0, "V0=", /* 0xc9 */
- 1, "Vb=", /* 0xca */
- 2, "Vc=", /* 0xcb */
- 3, "Vd=", /* 0xcc */
- 4, "Ve=", /* 0xcd */
+ { 0, "V0=" }, /* 0xc9 */
+ { 1, "Vb=" }, /* 0xca */
+ { 2, "Vc=" }, /* 0xcb */
+ { 3, "Vd=" }, /* 0xcc */
+ { 4, "Ve=" }, /* 0xcd */
/* R_TRANSLATED */
- 0, "", /* 0xce */
+ { 0, "" }, /* 0xce */
/* R_AUX_UNWIND */
- 0, "Sd=Vf=Ef=", /* 0xcf */
+ { 0,"Sd=Vf=Ef=" }, /* 0xcf */
/* R_COMP1 */
- 0, "Ob=", /* 0xd0 */
+ { 0, "Ob=" }, /* 0xd0 */
/* R_COMP2 */
- 0, "Ob=Sd=", /* 0xd1 */
+ { 0, "Ob=Sd=" }, /* 0xd1 */
/* R_COMP3 */
- 0, "Ob=Ve=", /* 0xd2 */
+ { 0, "Ob=Ve=" }, /* 0xd2 */
/* R_PREV_FIXUP */
- 0, "P", /* 0xd3 */
- 1, "P", /* 0xd4 */
- 2, "P", /* 0xd5 */
- 3, "P", /* 0xd6 */
+ { 0, "P" }, /* 0xd3 */
+ { 1, "P" }, /* 0xd4 */
+ { 2, "P" }, /* 0xd5 */
+ { 3, "P" }, /* 0xd6 */
/* R_SEC_STMT */
- 0, "", /* 0xd7 */
+ { 0, "" }, /* 0xd7 */
/* R_N0SEL */
- 0, "", /* 0xd8 */
+ { 0, "" }, /* 0xd8 */
/* R_N1SEL */
- 0, "", /* 0xd9 */
+ { 0, "" }, /* 0xd9 */
/* R_LINETAB */
- 0, "Eb=Sd=Ve=", /* 0xda */
+ { 0, "Eb=Sd=Ve=" }, /* 0xda */
/* R_LINETAB_ESC */
- 0, "Eb=Mb=", /* 0xdb */
+ { 0, "Eb=Mb=" }, /* 0xdb */
/* R_LTP_OVERRIDE */
- 0, "", /* 0xdc */
+ { 0, "" }, /* 0xdc */
/* R_COMMENT */
- 0, "Ob=Ve=", /* 0xdd */
+ { 0, "Ob=Ve=" }, /* 0xdd */
/* R_RESERVED */
- 0, "", /* 0xde */
- 0, "", /* 0xdf */
- 0, "", /* 0xe0 */
- 0, "", /* 0xe1 */
- 0, "", /* 0xe2 */
- 0, "", /* 0xe3 */
- 0, "", /* 0xe4 */
- 0, "", /* 0xe5 */
- 0, "", /* 0xe6 */
- 0, "", /* 0xe7 */
- 0, "", /* 0xe8 */
- 0, "", /* 0xe9 */
- 0, "", /* 0xea */
- 0, "", /* 0xeb */
- 0, "", /* 0xec */
- 0, "", /* 0xed */
- 0, "", /* 0xee */
- 0, "", /* 0xef */
- 0, "", /* 0xf0 */
- 0, "", /* 0xf1 */
- 0, "", /* 0xf2 */
- 0, "", /* 0xf3 */
- 0, "", /* 0xf4 */
- 0, "", /* 0xf5 */
- 0, "", /* 0xf6 */
- 0, "", /* 0xf7 */
- 0, "", /* 0xf8 */
- 0, "", /* 0xf9 */
- 0, "", /* 0xfa */
- 0, "", /* 0xfb */
- 0, "", /* 0xfc */
- 0, "", /* 0xfd */
- 0, "", /* 0xfe */
- 0, "", /* 0xff */
+ { 0, "" }, /* 0xde */
+ { 0, "" }, /* 0xdf */
+ { 0, "" }, /* 0xe0 */
+ { 0, "" }, /* 0xe1 */
+ { 0, "" }, /* 0xe2 */
+ { 0, "" }, /* 0xe3 */
+ { 0, "" }, /* 0xe4 */
+ { 0, "" }, /* 0xe5 */
+ { 0, "" }, /* 0xe6 */
+ { 0, "" }, /* 0xe7 */
+ { 0, "" }, /* 0xe8 */
+ { 0, "" }, /* 0xe9 */
+ { 0, "" }, /* 0xea */
+ { 0, "" }, /* 0xeb */
+ { 0, "" }, /* 0xec */
+ { 0, "" }, /* 0xed */
+ { 0, "" }, /* 0xee */
+ { 0, "" }, /* 0xef */
+ { 0, "" }, /* 0xf0 */
+ { 0, "" }, /* 0xf1 */
+ { 0, "" }, /* 0xf2 */
+ { 0, "" }, /* 0xf3 */
+ { 0, "" }, /* 0xf4 */
+ { 0, "" }, /* 0xf5 */
+ { 0, "" }, /* 0xf6 */
+ { 0, "" }, /* 0xf7 */
+ { 0, "" }, /* 0xf8 */
+ { 0, "" }, /* 0xf9 */
+ { 0, "" }, /* 0xfa */
+ { 0, "" }, /* 0xfb */
+ { 0, "" }, /* 0xfc */
+ { 0, "" }, /* 0xfd */
+ { 0, "" }, /* 0xfe */
+ { 0, "" }, /* 0xff */
};
static const int comp1_opcodes[] = {
@@ -1198,7 +1199,7 @@ som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue)
skip -= 0x1000000;
bfd_put_8 (abfd, R_NO_RELOCATION + 31, p);
bfd_put_8 (abfd, 0xff, p + 1);
- bfd_put_16 (abfd, 0xffff, p + 2);
+ bfd_put_16 (abfd, (bfd_vma) 0xffff, p + 2);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
while (skip >= 0x1000000)
{
@@ -1234,7 +1235,7 @@ som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue)
else
{
bfd_put_8 (abfd, R_NO_RELOCATION + 28 + (((skip >> 2) - 1) >> 16), p);
- bfd_put_16 (abfd, (skip >> 2) - 1, p + 1);
+ bfd_put_16 (abfd, (bfd_vma) (skip >> 2) - 1, p + 1);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
}
}
@@ -1243,7 +1244,7 @@ som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue)
{
bfd_put_8 (abfd, R_NO_RELOCATION + 31, p);
bfd_put_8 (abfd, (skip - 1) >> 16, p + 1);
- bfd_put_16 (abfd, skip - 1, p + 2);
+ bfd_put_16 (abfd, (bfd_vma) skip - 1, p + 2);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
}
return p;
@@ -1257,24 +1258,24 @@ som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue)
static unsigned char *
som_reloc_addend (abfd, addend, p, subspace_reloc_sizep, queue)
bfd *abfd;
- int addend;
+ bfd_vma addend;
unsigned char *p;
unsigned int *subspace_reloc_sizep;
struct reloc_queue *queue;
{
- if ((unsigned) (addend) + 0x80 < 0x100)
+ if (addend + 0x80 < 0x100)
{
bfd_put_8 (abfd, R_DATA_OVERRIDE + 1, p);
bfd_put_8 (abfd, addend, p + 1);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue);
}
- else if ((unsigned) (addend) + 0x8000 < 0x10000)
+ else if (addend + 0x8000 < 0x10000)
{
bfd_put_8 (abfd, R_DATA_OVERRIDE + 2, p);
bfd_put_16 (abfd, addend, p + 1);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
}
- else if ((unsigned) (addend) + 0x800000 < 0x1000000)
+ else if (addend + 0x800000 < 0x1000000)
{
bfd_put_8 (abfd, R_DATA_OVERRIDE + 3, p);
bfd_put_8 (abfd, addend >> 16, p + 1);
@@ -1395,7 +1396,7 @@ som_reloc_call (abfd, p, subspace_reloc_sizep, bfd_reloc, sym_num, queue)
else
{
bfd_put_8 (abfd, sym_num >> 16, p + 2);
- bfd_put_16 (abfd, sym_num, p + 3);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 3);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 5, queue);
}
}
@@ -1453,8 +1454,8 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
{
int *final_type, **final_types;
- final_types = (int **) bfd_alloc (abfd, sizeof (int *) * 6);
- final_type = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types = (int **) bfd_alloc (abfd, (bfd_size_type) sizeof (int *) * 6);
+ final_type = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types || !final_type)
return NULL;
@@ -1478,7 +1479,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
case e_tsel:
case e_ltsel:
case e_rtsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
if (field == e_tsel)
@@ -1494,7 +1495,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
case e_lssel:
case e_rssel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_S_MODE;
@@ -1505,7 +1506,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
case e_lsel:
case e_rsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_N_MODE;
@@ -1516,7 +1517,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
case e_ldsel:
case e_rdsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_D_MODE;
@@ -1527,7 +1528,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
case e_lrsel:
case e_rrsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_R_MODE;
@@ -1537,7 +1538,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
break;
case e_nsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_N1SEL;
@@ -1548,11 +1549,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
case e_nlsel:
case e_nlrsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_N0SEL;
- final_types[1] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[1] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[1])
return NULL;
if (field == e_nlsel)
@@ -1571,10 +1572,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
/* The difference of two symbols needs *very* special handling. */
if (sym_diff)
{
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[1] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[2] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[3] = (int *) bfd_alloc (abfd, sizeof (int));
+ bfd_size_type amt = sizeof (int);
+ final_types[0] = (int *) bfd_alloc (abfd, amt);
+ final_types[1] = (int *) bfd_alloc (abfd, amt);
+ final_types[2] = (int *) bfd_alloc (abfd, amt);
+ final_types[3] = (int *) bfd_alloc (abfd, amt);
if (!final_types[0] || !final_types[1] || !final_types[2])
return NULL;
if (field == e_fsel)
@@ -1651,10 +1653,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
/* The difference of two symbols needs *very* special handling. */
if (sym_diff)
{
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[1] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[2] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[3] = (int *) bfd_alloc (abfd, sizeof (int));
+ bfd_size_type amt = sizeof (int);
+ final_types[0] = (int *) bfd_alloc (abfd, amt);
+ final_types[1] = (int *) bfd_alloc (abfd, amt);
+ final_types[2] = (int *) bfd_alloc (abfd, amt);
+ final_types[3] = (int *) bfd_alloc (abfd, amt);
if (!final_types[0] || !final_types[1] || !final_types[2])
return NULL;
if (field == e_fsel)
@@ -1688,7 +1691,8 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym)
/* If we have short and long pcrel modes, then generate the proper
mode selector, then the pcrel relocation. Redundant selectors
will be eliminted as the relocs are sized and emitted. */
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ bfd_size_type amt = sizeof (int);
+ final_types[0] = (int *) bfd_alloc (abfd, amt);
if (!final_types[0])
return NULL;
if (format == 17)
@@ -1773,7 +1777,7 @@ som_object_setup (abfd, file_hdrp, aux_hdrp, current_offset)
/* Allocate space to hold the saved exec header information. */
obj_som_exec_data (abfd) = (struct som_exec_data *)
- bfd_zalloc (abfd, sizeof (struct som_exec_data));
+ bfd_zalloc (abfd, (bfd_size_type) sizeof (struct som_exec_data));
if (obj_som_exec_data (abfd) == NULL)
return NULL;
@@ -1846,18 +1850,19 @@ setup_sections (abfd, file_hdr, current_offset)
unsigned int space_index, i;
unsigned int total_subspaces = 0;
asection **subspace_sections, *section;
+ bfd_size_type amt;
/* First, read in space names. */
- space_strings = bfd_malloc (file_hdr->space_strings_size);
- if (!space_strings && file_hdr->space_strings_size != 0)
+ amt = file_hdr->space_strings_size;
+ space_strings = bfd_malloc (amt);
+ if (!space_strings && amt != 0)
goto error_return;
if (bfd_seek (abfd, current_offset + file_hdr->space_strings_location,
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
goto error_return;
- if (bfd_read (space_strings, 1, file_hdr->space_strings_size, abfd)
- != file_hdr->space_strings_size)
+ if (bfd_bread (space_strings, amt, abfd) != amt)
goto error_return;
/* Loop over all of the space dictionaries, building up sections. */
@@ -1873,16 +1878,18 @@ setup_sections (abfd, file_hdr, current_offset)
if (bfd_seek (abfd,
(current_offset + file_hdr->space_location
+ space_index * sizeof space),
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&space, 1, sizeof space, abfd) != sizeof space)
+ amt = sizeof space;
+ if (bfd_bread (&space, amt, abfd) != amt)
goto error_return;
/* Setup the space name string. */
space.name.n_name = space.name.n_strx + space_strings;
/* Make a section out of it. */
- newname = bfd_alloc (abfd, strlen (space.name.n_name) + 1);
+ amt = strlen (space.name.n_name) + 1;
+ newname = bfd_alloc (abfd, amt);
if (!newname)
goto error_return;
strcpy (newname, space.name.n_name);
@@ -1908,15 +1915,16 @@ setup_sections (abfd, file_hdr, current_offset)
if (bfd_seek (abfd,
(current_offset + file_hdr->subspace_location
+ space.subspace_index * sizeof subspace),
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&subspace, 1, sizeof subspace, abfd) != sizeof subspace)
+ amt = sizeof subspace;
+ if (bfd_bread (&subspace, amt, abfd) != amt)
goto error_return;
/* Seek back to the start of the subspaces for loop below. */
if (bfd_seek (abfd,
(current_offset + file_hdr->subspace_location
+ space.subspace_index * sizeof subspace),
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
goto error_return;
/* Setup the start address and file loc from the first subspace
@@ -1924,7 +1932,7 @@ setup_sections (abfd, file_hdr, current_offset)
space_asect->vma = subspace.subspace_start;
space_asect->filepos = subspace.file_loc_init_value + current_offset;
space_asect->alignment_power = log2 (subspace.alignment);
- if (space_asect->alignment_power == -1)
+ if (space_asect->alignment_power == (unsigned) -1)
goto error_return;
/* Initialize save_subspace so we can reliably determine if this
@@ -1938,14 +1946,15 @@ setup_sections (abfd, file_hdr, current_offset)
asection *subspace_asect;
/* Read in the next subspace. */
- if (bfd_read (&subspace, 1, sizeof subspace, abfd)
- != sizeof subspace)
+ amt = sizeof subspace;
+ if (bfd_bread (&subspace, amt, abfd) != amt)
goto error_return;
/* Setup the subspace name string. */
subspace.name.n_name = subspace.name.n_strx + space_strings;
- newname = bfd_alloc (abfd, strlen (subspace.name.n_name) + 1);
+ amt = strlen (subspace.name.n_name) + 1;
+ newname = bfd_alloc (abfd, amt);
if (!newname)
goto error_return;
strcpy (newname, subspace.name.n_name);
@@ -2036,7 +2045,7 @@ setup_sections (abfd, file_hdr, current_offset)
= subspace.fixup_request_quantity;
/* We can not determine this yet. When we read in the
relocation table the correct value will be filled in. */
- subspace_asect->reloc_count = -1;
+ subspace_asect->reloc_count = (unsigned) -1;
}
/* Update save_subspace if appropriate. */
@@ -2049,7 +2058,7 @@ setup_sections (abfd, file_hdr, current_offset)
subspace_asect->filepos = (subspace.file_loc_init_value
+ current_offset);
subspace_asect->alignment_power = log2 (subspace.alignment);
- if (subspace_asect->alignment_power == -1)
+ if (subspace_asect->alignment_power == (unsigned) -1)
goto error_return;
}
@@ -2074,8 +2083,9 @@ setup_sections (abfd, file_hdr, current_offset)
}
/* Now that we've read in all the subspace records, we need to assign
a target index to each subspace. */
- subspace_sections = (asection **) bfd_malloc (total_subspaces
- * sizeof (asection *));
+ amt = total_subspaces;
+ amt *= sizeof (asection *);
+ subspace_sections = (asection **) bfd_malloc (amt);
if (subspace_sections == NULL)
goto error_return;
@@ -2123,9 +2133,11 @@ som_object_p (abfd)
unsigned long current_offset = 0;
struct lst_header lst_header;
struct som_entry som_entry;
+ bfd_size_type amt;
#define ENTRY_SIZE sizeof (struct som_entry)
- if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
+ amt = FILE_HDR_SIZE;
+ if (bfd_bread ((PTR) &file_hdr, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
@@ -2159,14 +2171,15 @@ som_object_p (abfd)
case EXECLIBMAGIC:
/* Read the lst header and determine where the SOM directory begins. */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return 0;
}
- if (bfd_read ((PTR) & lst_header, 1, SLSTHDR, abfd) != SLSTHDR)
+ amt = SLSTHDR;
+ if (bfd_bread ((PTR) &lst_header, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
@@ -2175,14 +2188,15 @@ som_object_p (abfd)
/* Position to and read the first directory entry. */
- if (bfd_seek (abfd, lst_header.dir_loc, SEEK_SET) < 0)
+ if (bfd_seek (abfd, lst_header.dir_loc, SEEK_SET) != 0)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return 0;
}
- if (bfd_read ((PTR) & som_entry, 1, ENTRY_SIZE, abfd) != ENTRY_SIZE)
+ amt = ENTRY_SIZE;
+ if (bfd_bread ((PTR) &som_entry, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
@@ -2191,7 +2205,7 @@ som_object_p (abfd)
/* Now position to the first SOM. */
- if (bfd_seek (abfd, som_entry.location, SEEK_SET) < 0)
+ if (bfd_seek (abfd, som_entry.location, SEEK_SET) != 0)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
@@ -2201,8 +2215,8 @@ som_object_p (abfd)
current_offset = som_entry.location;
/* And finally, re-read the som header. */
-
- if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
+ amt = FILE_HDR_SIZE;
+ if (bfd_bread ((PTR) &file_hdr, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
@@ -2230,7 +2244,8 @@ som_object_p (abfd)
memset (&aux_hdr, 0, sizeof (struct som_exec_auxhdr));
if (file_hdr.aux_header_size != 0)
{
- if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
+ amt = AUX_HDR_SIZE;
+ if (bfd_bread ((PTR) &aux_hdr, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
@@ -2257,7 +2272,7 @@ som_mkobject (abfd)
{
/* Allocate memory to hold backend information. */
abfd->tdata.som_data = (struct som_data_struct *)
- bfd_zalloc (abfd, sizeof (struct som_data_struct));
+ bfd_zalloc (abfd, (bfd_size_type) sizeof (struct som_data_struct));
if (abfd->tdata.som_data == NULL)
return false;
return true;
@@ -2273,9 +2288,10 @@ som_prep_headers (abfd)
{
struct header *file_hdr;
asection *section;
+ bfd_size_type amt = sizeof (struct header);
/* Make and attach a file header to the BFD. */
- file_hdr = (struct header *) bfd_zalloc (abfd, sizeof (struct header));
+ file_hdr = (struct header *) bfd_zalloc (abfd, amt);
if (file_hdr == NULL)
return false;
obj_som_file_hdr (abfd) = file_hdr;
@@ -2284,8 +2300,9 @@ som_prep_headers (abfd)
{
/* Make and attach an exec header to the BFD. */
- obj_som_exec_hdr (abfd) = (struct som_exec_auxhdr *)
- bfd_zalloc (abfd, sizeof (struct som_exec_auxhdr));
+ amt = sizeof (struct som_exec_auxhdr);
+ obj_som_exec_hdr (abfd) =
+ (struct som_exec_auxhdr *) bfd_zalloc (abfd, amt);
if (obj_som_exec_hdr (abfd) == NULL)
return false;
@@ -2330,9 +2347,9 @@ som_prep_headers (abfd)
if (som_is_space (section))
{
/* Allocate space for the space dictionary. */
+ amt = sizeof (struct space_dictionary_record);
som_section_data (section)->space_dict =
- (struct space_dictionary_record *)
- bfd_zalloc (abfd, sizeof (struct space_dictionary_record));
+ (struct space_dictionary_record *) bfd_zalloc (abfd, amt);
if (som_section_data (section)->space_dict == NULL)
return false;
/* Set space attributes. Note most attributes of SOM spaces
@@ -2353,9 +2370,9 @@ som_prep_headers (abfd)
else
{
/* Allocate space for the subspace dictionary. */
- som_section_data (section)->subspace_dict
- = (struct subspace_dictionary_record *)
- bfd_zalloc (abfd, sizeof (struct subspace_dictionary_record));
+ amt = sizeof (struct subspace_dictionary_record);
+ som_section_data (section)->subspace_dict =
+ (struct subspace_dictionary_record *) bfd_zalloc (abfd, amt);
if (som_section_data (section)->subspace_dict == NULL)
return false;
@@ -2546,9 +2563,10 @@ som_prep_for_fixups (abfd, syms, num_syms)
asymbol **syms;
unsigned long num_syms;
{
- int i;
+ unsigned long i;
asection *section;
asymbol **sorted_syms;
+ bfd_size_type amt;
/* Most SOM relocations involving a symbol have a length which is
dependent on the index of the symbol. So symbols which are
@@ -2574,16 +2592,16 @@ som_prep_for_fixups (abfd, syms, num_syms)
of how often a given symbol is used in a relocation. */
for (section = abfd->sections; section != NULL; section = section->next)
{
- int i;
+ int j;
/* Does this section have any relocations? */
- if (section->reloc_count <= 0)
+ if ((int) section->reloc_count <= 0)
continue;
/* Walk through each relocation for this section. */
- for (i = 1; i < section->reloc_count; i++)
+ for (j = 1; j < (int) section->reloc_count; j++)
{
- arelent *reloc = section->orelocation[i];
+ arelent *reloc = section->orelocation[j];
int scale;
/* A relocation against a symbol in the *ABS* section really
@@ -2620,7 +2638,9 @@ som_prep_for_fixups (abfd, syms, num_syms)
/* Sort a copy of the symbol table, rather than the canonical
output symbol table. */
- sorted_syms = (asymbol **) bfd_zalloc (abfd, num_syms * sizeof (asymbol *));
+ amt = num_syms;
+ amt *= sizeof (asymbol *);
+ sorted_syms = (asymbol **) bfd_zalloc (abfd, amt);
memcpy (sorted_syms, syms, num_syms * sizeof (asymbol *));
qsort (sorted_syms, num_syms, sizeof (asymbol *), compare_syms);
obj_som_sorted_syms (abfd) = sorted_syms;
@@ -2653,6 +2673,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
unsigned int subspace_reloc_size = 0;
unsigned int num_spaces = obj_som_file_hdr (abfd)->space_total;
asection *section = abfd->sections;
+ bfd_size_type amt;
memset (tmp_space, 0, SOM_TMP_BUFSIZE);
p = tmp_space;
@@ -2677,7 +2698,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
subsection != NULL;
subsection = subsection->next)
{
- int reloc_offset, current_rounding_mode;
+ int reloc_offset;
+ unsigned int current_rounding_mode;
#ifndef NO_PCREL_MODES
int current_call_mode;
#endif
@@ -2705,7 +2727,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
each subspace. Seek to the start of the relocation stream
for this subspace in preparation for writing out its fixup
stream. */
- if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) < 0)
+ if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) != 0)
return false;
/* Buffer space has already been allocated. Just perform some
@@ -2743,8 +2765,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
upper limit, but leave lots of space for growth). */
if (p - tmp_space + 100 > SOM_TMP_BUFSIZE)
{
- if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) tmp_space, amt, abfd) != amt)
return false;
p = tmp_space;
@@ -2827,7 +2849,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
{
bfd_put_8 (abfd, bfd_reloc->howto->type + 33, p);
bfd_put_8 (abfd, sym_num >> 16, p + 1);
- bfd_put_16 (abfd, sym_num, p + 2);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 2);
p = try_prev_fixup (abfd, &subspace_reloc_size,
p, 4, reloc_queue);
}
@@ -2856,7 +2878,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
{
bfd_put_8 (abfd, bfd_reloc->howto->type + 1, p);
bfd_put_8 (abfd, sym_num >> 16, p + 1);
- bfd_put_16 (abfd, sym_num, p + 2);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 2);
p = try_prev_fixup (abfd, &subspace_reloc_size,
p, 4, reloc_queue);
}
@@ -2866,7 +2888,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
case R_ENTRY:
{
- int tmp;
+ unsigned int tmp;
arelent *tmp_reloc = NULL;
bfd_put_8 (abfd, R_ENTRY, p);
@@ -2978,7 +3000,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
bfd_put_8 (abfd, bfd_reloc->howto->type, p);
bfd_put_8 (abfd, 0x80, p + 1);
bfd_put_8 (abfd, sym_num >> 16, p + 2);
- bfd_put_16 (abfd, sym_num, p + 3);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 3);
p = try_prev_fixup (abfd, &subspace_reloc_size,
p, 5, reloc_queue);
break;
@@ -3011,8 +3033,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
p, &subspace_reloc_size, reloc_queue);
/* Scribble out the relocations. */
- if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) tmp_space, amt, abfd) != amt)
return false;
p = tmp_space;
@@ -3041,10 +3063,11 @@ som_write_space_strings (abfd, current_offset, string_sizep)
unsigned char *p = tmp_space;
unsigned int strings_size = 0;
asection *section;
+ bfd_size_type amt;
/* Seek to the start of the space strings in preparation for writing
them out. */
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0)
return false;
/* Walk through all the spaces and subspaces (order is not important)
@@ -3068,8 +3091,8 @@ som_write_space_strings (abfd, current_offset, string_sizep)
if (p - tmp_space + 5 + length > tmp_space_size)
{
/* Flush buffer before refilling or reallocating. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
/* Reallocate if now empty buffer still too small. */
@@ -3093,7 +3116,7 @@ som_write_space_strings (abfd, current_offset, string_sizep)
/* First element in a string table entry is the length of the
string. Alignment issues are already handled. */
- bfd_put_32 (abfd, length, p);
+ bfd_put_32 (abfd, (bfd_vma) length, p);
p += 4;
strings_size += 4;
@@ -3119,7 +3142,8 @@ som_write_space_strings (abfd, current_offset, string_sizep)
/* Done with the space/subspace strings. Write out any information
contained in a partial block. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
*string_sizep = strings_size;
return true;
@@ -3131,7 +3155,7 @@ static boolean
som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
compilation_unit)
bfd *abfd;
- unsigned long current_offset;
+ file_ptr current_offset;
asymbol **syms;
unsigned int num_syms;
unsigned int *string_sizep;
@@ -3147,6 +3171,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
unsigned int strings_size = 0;
unsigned char *comp[4];
+ bfd_size_type amt;
/* This gets a bit gruesome because of the compilation unit. The
strings within the compilation unit are part of the symbol
@@ -3164,7 +3189,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
/* Seek to the start of the space strings in preparation for writing
them out. */
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ if (bfd_seek (abfd, current_offset, SEEK_SET) != 0)
return false;
if (compilation_unit)
@@ -3179,8 +3204,8 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
if (p - tmp_space + 5 + length > tmp_space_size)
{
/* Flush buffer before refilling or reallocating. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
/* Reallocate if now empty buffer still too small. */
@@ -3200,7 +3225,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
the string. This must always be 4 byte aligned. This is
also an appropriate time to fill in the string index
field in the symbol table entry. */
- bfd_put_32 (abfd, length, p);
+ bfd_put_32 (abfd, (bfd_vma) length, p);
strings_size += 4;
p += 4;
@@ -3248,8 +3273,8 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
if (p - tmp_space + 5 + length > tmp_space_size)
{
/* Flush buffer before refilling or reallocating. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
/* Reallocate if now empty buffer still too small. */
@@ -3268,7 +3293,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
string. This must always be 4 byte aligned. This is also
an appropriate time to fill in the string index field in the
symbol table entry. */
- bfd_put_32 (abfd, length, p);
+ bfd_put_32 (abfd, (bfd_vma) length, p);
strings_size += 4;
p += 4;
@@ -3289,7 +3314,8 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
}
/* Scribble out any partial block. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
*string_sizep = strings_size;
@@ -3343,47 +3369,47 @@ som_begin_writing (abfd)
}
if (obj_som_version_hdr (abfd) != NULL)
{
- unsigned int len;
+ bfd_size_type len;
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0)
return false;
/* Write the aux_id structure and the string length. */
len = sizeof (struct aux_id) + sizeof (unsigned int);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
- if (bfd_write ((PTR) obj_som_version_hdr (abfd), len, 1, abfd) != len)
+ if (bfd_bwrite ((PTR) obj_som_version_hdr (abfd), len, abfd) != len)
return false;
/* Write the version string. */
len = obj_som_version_hdr (abfd)->header_id.length - sizeof (int);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
- if (bfd_write ((PTR) obj_som_version_hdr (abfd)->user_string,
- len, 1, abfd) != len)
+ if (bfd_bwrite ((PTR) obj_som_version_hdr (abfd)->user_string, len, abfd)
+ != len)
return false;
}
if (obj_som_copyright_hdr (abfd) != NULL)
{
- unsigned int len;
+ bfd_size_type len;
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0)
return false;
/* Write the aux_id structure and the string length. */
len = sizeof (struct aux_id) + sizeof (unsigned int);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
- if (bfd_write ((PTR) obj_som_copyright_hdr (abfd), len, 1, abfd) != len)
+ if (bfd_bwrite ((PTR) obj_som_copyright_hdr (abfd), len, abfd) != len)
return false;
/* Write the copyright string. */
len = obj_som_copyright_hdr (abfd)->header_id.length - sizeof (int);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
- if (bfd_write ((PTR) obj_som_copyright_hdr (abfd)->copyright,
- len, 1, abfd) != len)
+ if (bfd_bwrite ((PTR) obj_som_copyright_hdr (abfd)->copyright, len, abfd)
+ != len)
return false;
}
@@ -3628,9 +3654,9 @@ som_begin_writing (abfd)
zeros are filled in. Ugh. */
if (abfd->flags & (EXEC_P | DYNAMIC))
current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
- if (bfd_seek (abfd, current_offset - 1, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) current_offset - 1, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) "", 1, 1, abfd) != 1)
+ if (bfd_bwrite ((PTR) "", (bfd_size_type) 1, abfd) != 1)
return false;
obj_som_file_hdr (abfd)->unloadable_sp_size
@@ -3660,6 +3686,7 @@ som_finish_writing (abfd)
asection *section;
unsigned long current_offset;
unsigned int total_reloc_size;
+ bfd_size_type amt;
/* Next is the symbol table. These are fixed length records.
@@ -3735,7 +3762,7 @@ som_finish_writing (abfd)
/* Seek to the start of the subspace dictionary records. */
location = obj_som_file_hdr (abfd)->subspace_location;
- if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ if (bfd_seek (abfd, location, SEEK_SET) != 0)
return false;
section = abfd->sections;
@@ -3783,9 +3810,9 @@ som_finish_writing (abfd)
som_section_data (subsection)->subspace_dict->space_index = i;
/* Dump the current subspace header. */
- if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
- sizeof (struct subspace_dictionary_record), 1, abfd)
- != sizeof (struct subspace_dictionary_record))
+ amt = sizeof (struct subspace_dictionary_record);
+ if (bfd_bwrite ((PTR) som_section_data (subsection)->subspace_dict,
+ amt, abfd) != amt)
return false;
}
/* Goto the next section. */
@@ -3839,9 +3866,9 @@ som_finish_writing (abfd)
som_section_data (subsection)->subspace_dict->space_index = i;
/* Dump this subspace header. */
- if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
- sizeof (struct subspace_dictionary_record), 1, abfd)
- != sizeof (struct subspace_dictionary_record))
+ amt = sizeof (struct subspace_dictionary_record);
+ if (bfd_bwrite ((PTR) som_section_data (subsection)->subspace_dict,
+ amt, abfd) != amt)
return false;
}
/* Goto the next section. */
@@ -3854,7 +3881,7 @@ som_finish_writing (abfd)
Seek to the right location and start writing the space
dictionary records. */
location = obj_som_file_hdr (abfd)->space_location;
- if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ if (bfd_seek (abfd, location, SEEK_SET) != 0)
return false;
section = abfd->sections;
@@ -3865,9 +3892,9 @@ som_finish_writing (abfd)
section = section->next;
/* Dump its header. */
- if (bfd_write ((PTR) som_section_data (section)->space_dict,
- sizeof (struct space_dictionary_record), 1, abfd)
- != sizeof (struct space_dictionary_record))
+ amt = sizeof (struct space_dictionary_record);
+ if (bfd_bwrite ((PTR) som_section_data (section)->space_dict,
+ amt, abfd) != amt)
return false;
/* Goto the next section. */
@@ -3878,11 +3905,11 @@ som_finish_writing (abfd)
if (obj_som_compilation_unit (abfd))
{
location = obj_som_file_hdr (abfd)->compiler_location;
- if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ if (bfd_seek (abfd, location, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) obj_som_compilation_unit (abfd),
- COMPUNITSZ, 1, abfd) != COMPUNITSZ)
+ amt = COMPUNITSZ;
+ if (bfd_bwrite ((PTR) obj_som_compilation_unit (abfd), amt, abfd) != amt)
return false;
}
@@ -3903,11 +3930,10 @@ som_finish_writing (abfd)
/* Only thing left to do is write out the file header. It is always
at location zero. Seek there and write it. */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) obj_som_file_hdr (abfd),
- sizeof (struct header), 1, abfd)
- != sizeof (struct header))
+ amt = sizeof (struct header);
+ if (bfd_bwrite ((PTR) obj_som_file_hdr (abfd), amt, abfd) != amt)
return false;
/* Now write the exec header. */
@@ -3941,11 +3967,11 @@ som_finish_writing (abfd)
}
if (bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location,
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) exec_header, AUX_HDR_SIZE, 1, abfd)
- != AUX_HDR_SIZE)
+ amt = AUX_HDR_SIZE;
+ if (bfd_bwrite ((PTR) exec_header, amt, abfd) != amt)
return false;
}
return true;
@@ -4100,15 +4126,17 @@ som_build_and_write_symbol_table (abfd)
file_ptr symtab_location = obj_som_file_hdr (abfd)->symbol_location;
asymbol **bfd_syms = obj_som_sorted_syms (abfd);
struct symbol_dictionary_record *som_symtab = NULL;
- int i, symtab_size;
+ unsigned int i;
+ bfd_size_type symtab_size;
/* Compute total symbol table size and allocate a chunk of memory
to hold the symbol table as we build it. */
- symtab_size = num_syms * sizeof (struct symbol_dictionary_record);
+ symtab_size = num_syms;
+ symtab_size *= sizeof (struct symbol_dictionary_record);
som_symtab = (struct symbol_dictionary_record *) bfd_malloc (symtab_size);
if (som_symtab == NULL && symtab_size != 0)
goto error_return;
- memset (som_symtab, 0, symtab_size);
+ memset (som_symtab, 0, (size_t) symtab_size);
/* Walk over each symbol. */
for (i = 0; i < num_syms; i++)
@@ -4138,7 +4166,7 @@ som_build_and_write_symbol_table (abfd)
if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) som_symtab, symtab_size, 1, abfd) != symtab_size)
+ if (bfd_bwrite ((PTR) som_symtab, symtab_size, abfd) != symtab_size)
goto error_return;
if (som_symtab != NULL)
@@ -4177,6 +4205,7 @@ som_slurp_string_table (abfd)
bfd *abfd;
{
char *stringtab;
+ bfd_size_type amt;
/* Use the saved version if its available. */
if (obj_som_stringtab (abfd) != NULL)
@@ -4192,16 +4221,16 @@ som_slurp_string_table (abfd)
}
/* Allocate and read in the string table. */
- stringtab = bfd_malloc (obj_som_stringtab_size (abfd));
+ amt = obj_som_stringtab_size (abfd);
+ stringtab = bfd_malloc (amt);
if (stringtab == NULL)
return false;
memset (stringtab, 0, obj_som_stringtab_size (abfd));
- if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
+ if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) != 0)
return false;
- if (bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd)
- != obj_som_stringtab_size (abfd))
+ if (bfd_bread (stringtab, amt, abfd) != amt)
return false;
/* Save our results and return success. */
@@ -4282,6 +4311,7 @@ som_slurp_symbol_table (abfd)
char *stringtab;
struct symbol_dictionary_record *buf = NULL, *bufp, *endbufp;
som_symbol_type *sym, *symbase;
+ bfd_size_type amt;
/* Return saved value if it exists. */
if (obj_som_symtab (abfd) != NULL)
@@ -4296,20 +4326,22 @@ som_slurp_symbol_table (abfd)
stringtab = obj_som_stringtab (abfd);
- symbase = ((som_symbol_type *)
- bfd_malloc (symbol_count * sizeof (som_symbol_type)));
+ amt = symbol_count;
+ amt *= sizeof (som_symbol_type);
+ symbase = (som_symbol_type *) bfd_malloc (amt);
if (symbase == NULL)
goto error_return;
memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
/* Read in the external SOM representation. */
- buf = bfd_malloc (symbol_count * symsize);
- if (buf == NULL && symbol_count * symsize != 0)
+ amt = symbol_count;
+ amt *= symsize;
+ buf = bfd_malloc (amt);
+ if (buf == NULL && amt != 0)
goto error_return;
- if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0)
+ if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) != 0)
goto error_return;
- if (bfd_read (buf, symbol_count * symsize, 1, abfd)
- != symbol_count * symsize)
+ if (bfd_bread (buf, amt, abfd) != amt)
goto error_return;
/* Iterate over all the symbols and internalize them. */
@@ -4487,8 +4519,8 @@ static asymbol *
som_make_empty_symbol (abfd)
bfd *abfd;
{
- som_symbol_type *new =
- (som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type));
+ bfd_size_type amt = sizeof (som_symbol_type);
+ som_symbol_type *new = (som_symbol_type *) bfd_zalloc (abfd, amt);
if (new == NULL)
return 0;
new->symbol.the_bfd = abfd;
@@ -4518,7 +4550,7 @@ som_print_symbol (abfd, afile, symbol, how)
break;
case bfd_print_symbol_all:
{
- CONST char *section_name;
+ const char *section_name;
section_name = symbol->section ? symbol->section->name : "(*none*)";
bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
fprintf (file, " %s\t%s", section_name, symbol->name);
@@ -4849,13 +4881,13 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count)
day if the need arises. */
section->contents = bfd_malloc (section->_raw_size);
if (section->contents == NULL)
- return -1;
+ return (unsigned) -1;
deallocate_contents = 1;
bfd_get_section_contents (section->owner,
section,
section->contents,
- 0,
+ (bfd_vma) 0,
section->_raw_size);
}
else if (rptr->addend == 0)
@@ -4903,6 +4935,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
unsigned int fixup_stream_size;
arelent *internal_relocs;
unsigned int num_relocs;
+ bfd_size_type amt;
fixup_stream_size = som_section_data (section)->reloc_size;
/* If there were no relocations, then there is nothing to do. */
@@ -4911,9 +4944,10 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
/* If reloc_count is -1, then the relocation stream has not been
parsed. We must do so now to know how many relocations exist. */
- if (section->reloc_count == -1)
+ if (section->reloc_count == (unsigned) -1)
{
- external_relocs = (char *) bfd_malloc (fixup_stream_size);
+ amt = fixup_stream_size;
+ external_relocs = (char *) bfd_malloc (amt);
if (external_relocs == (char *) NULL)
return false;
/* Read in the external forms. */
@@ -4922,8 +4956,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
SEEK_SET)
!= 0)
return false;
- if (bfd_read (external_relocs, 1, fixup_stream_size, abfd)
- != fixup_stream_size)
+ if (bfd_bread (external_relocs, amt, abfd) != amt)
return false;
/* Let callers know how many relocations found.
@@ -4946,8 +4979,9 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
if (section->relocation != (arelent *) NULL)
return true;
- internal_relocs = (arelent *)
- bfd_zalloc (abfd, (num_relocs * sizeof (arelent)));
+ amt = num_relocs;
+ amt *= sizeof (arelent);
+ internal_relocs = (arelent *) bfd_zalloc (abfd, (amt));
if (internal_relocs == (arelent *) NULL)
return false;
@@ -5019,8 +5053,8 @@ som_new_section_hook (abfd, newsect)
bfd *abfd;
asection *newsect;
{
- newsect->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
+ bfd_size_type amt = sizeof (struct som_section_data_struct);
+ newsect->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (!newsect->used_by_bfd)
return false;
newsect->alignment_power = 3;
@@ -5065,15 +5099,17 @@ som_bfd_copy_private_section_data (ibfd, isection, obfd, osection)
bfd *obfd;
asection *osection;
{
+ bfd_size_type amt;
+
/* One day we may try to grok other private data. */
if (ibfd->xvec->flavour != bfd_target_som_flavour
|| obfd->xvec->flavour != bfd_target_som_flavour
|| (!som_is_space (isection) && !som_is_subspace (isection)))
return true;
+ amt = sizeof (struct som_copyable_section_data_struct);
som_section_data (osection)->copy_data =
- (struct som_copyable_section_data_struct *)
- bfd_zalloc (obfd, sizeof (struct som_copyable_section_data_struct));
+ (struct som_copyable_section_data_struct *) bfd_zalloc (obfd, amt);
if (som_section_data (osection)->copy_data == NULL)
return false;
@@ -5103,7 +5139,7 @@ som_bfd_copy_private_bfd_data (ibfd, obfd)
/* Allocate some memory to hold the data we need. */
obj_som_exec_data (obfd) = (struct som_exec_data *)
- bfd_zalloc (obfd, sizeof (struct som_exec_data));
+ bfd_zalloc (obfd, (bfd_size_type) sizeof (struct som_exec_data));
if (obj_som_exec_data (obfd) == NULL)
return false;
@@ -5128,10 +5164,10 @@ bfd_som_set_section_attributes (section, defined, private, sort_key, spnum)
/* Allocate memory to hold the magic information. */
if (som_section_data (section)->copy_data == NULL)
{
+ bfd_size_type amt = sizeof (struct som_copyable_section_data_struct);
som_section_data (section)->copy_data =
- (struct som_copyable_section_data_struct *)
- bfd_zalloc (section->owner,
- sizeof (struct som_copyable_section_data_struct));
+ (struct som_copyable_section_data_struct *) bfd_zalloc (section->owner,
+ amt);
if (som_section_data (section)->copy_data == NULL)
return false;
}
@@ -5158,10 +5194,10 @@ bfd_som_set_subsection_attributes (section, container, access,
/* Allocate memory to hold the magic information. */
if (som_section_data (section)->copy_data == NULL)
{
+ bfd_size_type amt = sizeof (struct som_copyable_section_data_struct);
som_section_data (section)->copy_data =
- (struct som_copyable_section_data_struct *)
- bfd_zalloc (section->owner,
- sizeof (struct som_copyable_section_data_struct));
+ (struct som_copyable_section_data_struct *) bfd_zalloc (section->owner,
+ amt);
if (som_section_data (section)->copy_data == NULL)
return false;
}
@@ -5195,16 +5231,18 @@ bfd_som_attach_aux_hdr (abfd, type, string)
int type;
char *string;
{
+ bfd_size_type amt;
+
if (type == VERSION_AUX_ID)
{
- int len = strlen (string);
+ size_t len = strlen (string);
int pad = 0;
if (len % 4)
pad = (4 - (len % 4));
- obj_som_version_hdr (abfd) = (struct user_string_aux_hdr *)
- bfd_zalloc (abfd, sizeof (struct aux_id)
- + sizeof (unsigned int) + len + pad);
+ amt = sizeof (struct aux_id) + sizeof (unsigned int) + len + pad;
+ obj_som_version_hdr (abfd) =
+ (struct user_string_aux_hdr *) bfd_zalloc (abfd, amt);
if (!obj_som_version_hdr (abfd))
return false;
obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
@@ -5220,9 +5258,9 @@ bfd_som_attach_aux_hdr (abfd, type, string)
if (len % 4)
pad = (4 - (len % 4));
- obj_som_copyright_hdr (abfd) = (struct copyright_aux_hdr *)
- bfd_zalloc (abfd, sizeof (struct aux_id)
- + sizeof (unsigned int) + len + pad);
+ amt = sizeof (struct aux_id) + sizeof (unsigned int) + len + pad;
+ obj_som_copyright_hdr (abfd) =
+ (struct copyright_aux_hdr *) bfd_zalloc (abfd, amt);
if (!obj_som_copyright_hdr (abfd))
return false;
obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
@@ -5246,14 +5284,14 @@ bfd_som_attach_compilation_unit (abfd, name, language_name, product_id,
const char *product_id;
const char *version_id;
{
- COMPUNIT *n = (COMPUNIT *) bfd_zalloc (abfd, COMPUNITSZ);
+ COMPUNIT *n = (COMPUNIT *) bfd_zalloc (abfd, (bfd_size_type) COMPUNITSZ);
if (n == NULL)
return false;
#define STRDUP(f) \
if (f != NULL) \
{ \
- n->f.n_name = bfd_alloc (abfd, strlen (f) + 1); \
+ n->f.n_name = bfd_alloc (abfd, (bfd_size_type) strlen (f) + 1); \
if (n->f.n_name == NULL) \
return false; \
strcpy (n->f.n_name, f); \
@@ -5282,8 +5320,8 @@ som_get_section_contents (abfd, section, location, offset, count)
if (count == 0 || ((section->flags & SEC_HAS_CONTENTS) == 0))
return true;
if ((bfd_size_type) (offset+count) > section->_raw_size
- || bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) == -1
- || bfd_read (location, (bfd_size_type) 1, count, abfd) != count)
+ || bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
+ || bfd_bread (location, count, abfd) != count)
return (false); /* on error */
return (true);
}
@@ -5316,10 +5354,10 @@ som_set_section_contents (abfd, section, location, offset, count)
/* Seek to the proper offset within the object file and write the
data. */
offset += som_section_data (section)->subspace_dict->file_loc_init_value;
- if (bfd_seek (abfd, offset, SEEK_SET) == -1)
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) location, 1, count, abfd) != count)
+ if (bfd_bwrite ((PTR) location, count, abfd) != count)
return false;
return true;
}
@@ -5341,8 +5379,8 @@ som_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
asection *section ATTRIBUTE_UNUSED;
asymbol **symbols ATTRIBUTE_UNUSED;
bfd_vma offset ATTRIBUTE_UNUSED;
- CONST char **filename_ptr ATTRIBUTE_UNUSED;
- CONST char **functionname_ptr ATTRIBUTE_UNUSED;
+ const char **filename_ptr ATTRIBUTE_UNUSED;
+ const char **functionname_ptr ATTRIBUTE_UNUSED;
unsigned int *line_ptr ATTRIBUTE_UNUSED;
{
return (false);
@@ -5431,11 +5469,12 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
{
unsigned int i;
unsigned int *hash_table = NULL;
+ bfd_size_type amt;
file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
- hash_table =
- (unsigned int *) bfd_malloc (lst_header->hash_size
- * sizeof (unsigned int));
+ amt = lst_header->hash_size;
+ amt *= sizeof (unsigned int);
+ hash_table = (unsigned int *) bfd_malloc (amt);
if (hash_table == NULL && lst_header->hash_size != 0)
goto error_return;
@@ -5444,8 +5483,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
/* Read in the hash table. The has table is an array of 32bit file offsets
which point to the hash chains. */
- if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
- != lst_header->hash_size * 4)
+ if (bfd_bread ((PTR) hash_table, amt, abfd) != amt)
goto error_return;
/* Walk each chain counting the number of symbols found on that particular
@@ -5459,12 +5497,12 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
continue;
/* Seek to the first symbol in this hash chain. */
- if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
+ if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) != 0)
goto error_return;
/* Read in this symbol and update the counter. */
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
+ amt = sizeof (lst_symbol);
+ if (bfd_bread ((PTR) &lst_symbol, amt, abfd) != amt)
goto error_return;
(*count)++;
@@ -5475,12 +5513,12 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
/* Seek to the next symbol. */
if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
- < 0)
+ != 0)
goto error_return;
/* Read the symbol in and update the counter. */
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
+ amt = sizeof (lst_symbol);
+ if (bfd_bread ((PTR) &lst_symbol, amt, abfd) != amt)
goto error_return;
(*count)++;
@@ -5509,34 +5547,32 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
carsym *set = syms[0];
unsigned int *hash_table = NULL;
struct som_entry *som_dict = NULL;
+ bfd_size_type amt;
file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
- hash_table =
- (unsigned int *) bfd_malloc (lst_header->hash_size
- * sizeof (unsigned int));
+ amt = lst_header->hash_size;
+ amt *= sizeof (unsigned int);
+ hash_table = (unsigned int *) bfd_malloc (amt);
if (hash_table == NULL && lst_header->hash_size != 0)
goto error_return;
- som_dict =
- (struct som_entry *) bfd_malloc (lst_header->module_count
- * sizeof (struct som_entry));
- if (som_dict == NULL && lst_header->module_count != 0)
- goto error_return;
-
/* Read in the hash table. The has table is an array of 32bit file offsets
which point to the hash chains. */
- if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
- != lst_header->hash_size * 4)
+ if (bfd_bread ((PTR) hash_table, amt, abfd) != amt)
goto error_return;
/* Seek to and read in the SOM dictionary. We will need this to fill
in the carsym's filepos field. */
- if (bfd_seek (abfd, lst_filepos + lst_header->dir_loc, SEEK_SET) < 0)
+ if (bfd_seek (abfd, lst_filepos + lst_header->dir_loc, SEEK_SET) != 0)
+ goto error_return;
+
+ amt = lst_header->module_count;
+ amt *= sizeof (struct som_entry);
+ som_dict = (struct som_entry *) bfd_malloc (amt);
+ if (som_dict == NULL && lst_header->module_count != 0)
goto error_return;
- if (bfd_read ((PTR) som_dict, lst_header->module_count,
- sizeof (struct som_entry), abfd)
- != lst_header->module_count * sizeof (struct som_entry))
+ if (bfd_bread ((PTR) som_dict, amt, abfd) != amt)
goto error_return;
/* Walk each chain filling in the carsyms as we go along. */
@@ -5549,11 +5585,11 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
continue;
/* Seek to and read the first symbol on the chain. */
- if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
+ if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) != 0)
goto error_return;
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
+ amt = sizeof (lst_symbol);
+ if (bfd_bread ((PTR) &lst_symbol, amt, abfd) != amt)
goto error_return;
/* Get the name of the symbol, first get the length which is stored
@@ -5564,17 +5600,17 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
index can point *anywhere* in the archive to save space, so just
using the string table would not be safe. */
if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
- + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
+ + lst_symbol.name.n_strx - 4, SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&len, 1, 4, abfd) != 4)
+ if (bfd_bread (&len, (bfd_size_type) 4, abfd) != 4)
goto error_return;
/* Allocate space for the name and null terminate it too. */
- set->name = bfd_zalloc (abfd, len + 1);
+ set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
if (!set->name)
goto error_return;
- if (bfd_read (set->name, 1, len, abfd) != len)
+ if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
goto error_return;
set->name[len] = 0;
@@ -5591,27 +5627,28 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
while (lst_symbol.next_entry)
{
/* Seek to the next symbol and read it in. */
- if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET) <0)
+ if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
+ != 0)
goto error_return;
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
+ amt = sizeof (lst_symbol);
+ if (bfd_bread ((PTR) &lst_symbol, amt, abfd) != amt)
goto error_return;
/* Seek to the name length & string and read them in. */
if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
- + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
+ + lst_symbol.name.n_strx - 4, SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&len, 1, 4, abfd) != 4)
+ if (bfd_bread (&len, (bfd_size_type) 4, abfd) != 4)
goto error_return;
/* Allocate space for the name and null terminate it too. */
- set->name = bfd_zalloc (abfd, len + 1);
+ set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
if (!set->name)
goto error_return;
- if (bfd_read (set->name, 1, len, abfd) != len)
+ if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
goto error_return;
set->name[len] = 0;
@@ -5651,7 +5688,8 @@ som_slurp_armap (abfd)
unsigned int parsed_size;
struct artdata *ardata = bfd_ardata (abfd);
char nextname[17];
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
+ bfd_size_type amt = 16;
+ int i = bfd_bread ((PTR) nextname, amt, abfd);
/* Special cases. */
if (i == 0)
@@ -5659,7 +5697,7 @@ som_slurp_armap (abfd)
if (i != 16)
return false;
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) < 0)
+ if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
return false;
/* For archives without .o files there is no symbol table. */
@@ -5670,8 +5708,8 @@ som_slurp_armap (abfd)
}
/* Read in and sanity check the archive header. */
- if (bfd_read ((PTR) &ar_header, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
+ amt = sizeof (struct ar_hdr);
+ if (bfd_bread ((PTR) &ar_header, amt, abfd) != amt)
return false;
if (strncmp (ar_header.ar_fmag, ARFMAG, 2))
@@ -5694,8 +5732,8 @@ som_slurp_armap (abfd)
/* Read in the library symbol table. We'll make heavy use of this
in just a minute. */
- if (bfd_read ((PTR) & lst_header, 1, sizeof (struct lst_header), abfd)
- != sizeof (struct lst_header))
+ amt = sizeof (struct lst_header);
+ if (bfd_bread ((PTR) &lst_header, amt, abfd) != amt)
return false;
/* Sanity check. */
@@ -5711,15 +5749,15 @@ som_slurp_armap (abfd)
return false;
/* Get back to the start of the library symbol table. */
- if (bfd_seek (abfd, ardata->first_file_filepos - parsed_size
- + sizeof (struct lst_header), SEEK_SET) < 0)
+ if (bfd_seek (abfd, (ardata->first_file_filepos - parsed_size
+ + sizeof (struct lst_header)), SEEK_SET) != 0)
return false;
/* Initializae the cache and allocate space for the library symbols. */
ardata->cache = 0;
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * sizeof (carsym)));
+ amt = ardata->symdef_count;
+ amt *= sizeof (carsym);
+ ardata->symdefs = (carsym *) bfd_alloc (abfd, amt);
if (!ardata->symdefs)
return false;
@@ -5730,7 +5768,7 @@ som_slurp_armap (abfd)
/* Seek back to the "first" file in the archive. Note the "first"
file may be the extended name table. */
- if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) < 0)
+ if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) != 0)
return false;
/* Notify the generic archive code that we have a symbol map. */
@@ -5849,20 +5887,23 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength)
struct som_entry *som_dict = NULL;
struct lst_symbol_record **last_hash_entry = NULL;
unsigned int curr_som_offset, som_index = 0;
+ bfd_size_type amt;
- hash_table =
- (unsigned int *) bfd_malloc (lst.hash_size * sizeof (unsigned int));
+ amt = lst.hash_size;
+ amt *= sizeof (unsigned int);
+ hash_table = (unsigned int *) bfd_malloc (amt);
if (hash_table == NULL && lst.hash_size != 0)
goto error_return;
- som_dict =
- (struct som_entry *) bfd_malloc (lst.module_count
- * sizeof (struct som_entry));
+
+ amt = lst.module_count;
+ amt *= sizeof (struct som_entry);
+ som_dict = (struct som_entry *) bfd_malloc (amt);
if (som_dict == NULL && lst.module_count != 0)
goto error_return;
- last_hash_entry =
- ((struct lst_symbol_record **)
- bfd_malloc (lst.hash_size * sizeof (struct lst_symbol_record *)));
+ amt = lst.hash_size;
+ amt *= sizeof (struct lst_symbol_record *);
+ last_hash_entry = ((struct lst_symbol_record **) bfd_malloc (amt));
if (last_hash_entry == NULL && lst.hash_size != 0)
goto error_return;
@@ -5900,10 +5941,12 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength)
curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
/* FIXME should be done with buffers just like everything else... */
- lst_syms = bfd_malloc (nsyms * sizeof (struct lst_symbol_record));
+ amt = nsyms;
+ amt *= sizeof (struct lst_symbol_record);
+ lst_syms = bfd_malloc (amt);
if (lst_syms == NULL && nsyms != 0)
goto error_return;
- strings = bfd_malloc (string_size);
+ strings = bfd_malloc ((bfd_size_type) string_size);
if (strings == NULL && string_size != 0)
goto error_return;
@@ -6037,29 +6080,29 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength)
/* A particular object in the archive may have an odd length; the
linker requires objects begin on an even boundary. So round
up the current offset as necessary. */
- curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
+ curr_som_offset = (curr_som_offset + 0x1) &~ (unsigned) 1;
curr_bfd = curr_bfd->next;
som_index++;
}
/* Now scribble out the hash table. */
- if (bfd_write ((PTR) hash_table, lst.hash_size, 4, abfd)
- != lst.hash_size * 4)
+ amt = lst.hash_size * 4;
+ if (bfd_bwrite ((PTR) hash_table, amt, abfd) != amt)
goto error_return;
/* Then the SOM dictionary. */
- if (bfd_write ((PTR) som_dict, lst.module_count,
- sizeof (struct som_entry), abfd)
- != lst.module_count * sizeof (struct som_entry))
+ amt = lst.module_count * sizeof (struct som_entry);
+ if (bfd_bwrite ((PTR) som_dict, amt, abfd) != amt)
goto error_return;
/* The library symbols. */
- if (bfd_write ((PTR) lst_syms, nsyms, sizeof (struct lst_symbol_record), abfd)
- != nsyms * sizeof (struct lst_symbol_record))
+ amt = nsyms * sizeof (struct lst_symbol_record);
+ if (bfd_bwrite ((PTR) lst_syms, amt, abfd) != amt)
goto error_return;
/* And finally the strings. */
- if (bfd_write ((PTR) strings, string_size, 1, abfd) != string_size)
+ amt = string_size;
+ if (bfd_bwrite ((PTR) strings, amt, abfd) != amt)
goto error_return;
if (hash_table != NULL)
@@ -6107,6 +6150,7 @@ som_write_armap (abfd, elength, map, orl_count, stridx)
struct ar_hdr hdr;
struct lst_header lst;
int *p;
+ bfd_size_type amt;
/* We'll use this for the archive's date and mode later. */
if (stat (abfd->filename, &statbuf) != 0)
@@ -6199,18 +6243,17 @@ som_write_armap (abfd, elength, map, orl_count, stridx)
(((char *) (&hdr))[i]) = ' ';
/* Scribble out the ar header. */
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
+ amt = sizeof (struct ar_hdr);
+ if (bfd_bwrite ((PTR) &hdr, amt, abfd) != amt)
return false;
/* Now scribble out the lst header. */
- if (bfd_write ((PTR) &lst, 1, sizeof (struct lst_header), abfd)
- != sizeof (struct lst_header))
+ amt = sizeof (struct lst_header);
+ if (bfd_bwrite ((PTR) &lst, amt, abfd) != amt)
return false;
/* Build and write the armap. */
- if (som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst, elength)
- == false)
+ if (!som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst, elength))
return false;
/* Done. */
@@ -6236,7 +6279,7 @@ som_bfd_free_cached_info (abfd)
for (o = abfd->sections; o != (asection *) NULL; o = o->next)
{
/* Free the native relocations. */
- o->reloc_count = -1;
+ o->reloc_count = (unsigned) -1;
FREE (som_section_data (o)->reloc_stream);
/* Free the generic relocations. */
FREE (o->relocation);
OpenPOWER on IntegriCloud