return NULL;
symbol_table = (asymbol **) malloc (storage_needed);
+ if (symbol_table == NULL) {
+ perror("malloc");
+ exit(1);
+ }
number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
* Also note that both the relocatable and absolute versions have this
* terminator even though the relocatable one doesn't have the GOT!
*/
- if (pic_with_got) {
+ if (pic_with_got && !use_resolved) {
unsigned long *lp = (unsigned long *)data;
/* Should call ntohl(*lp) here but is isn't going to matter */
while (*lp != 0xffffffff) lp++;
}
symb = get_symbols(rel_bfd, &nsymb);
- relpp = (arelent **) xmalloc(relsize);
+ relpp = (arelent **) malloc(relsize);
+ if (relpp == NULL) {
+ perror("malloc");
+ exit(1);
+ }
+
relcount = bfd_canonicalize_reloc(rel_bfd, r, relpp, symb);
if (relcount <= 0) {
if (verbose)
+ lo;
}
} else
- goto bad_v850_reloc_err;
+ goto bad_resolved_reloc;
break;
case R_V850_LO16:
&& (p[-1]->addend == p[0]->addend))
break; /* not an error */
else
- goto bad_v850_reloc_err;
+ goto bad_resolved_reloc;
case R_V850_HI16:
- bad_v850_reloc_err:
- printf("ERROR: reloc type %s unsupported in this context\n",
- q->howto->name);
- bad_relocs++;
- break;
-#endif /* TARGET_V850 */
-
-#if defined(TARGET_arm)
+ goto bad_resolved_reloc;
+ default:
+ goto good_32bit_resolved_reloc;
+#elif defined(TARGET_arm)
case R_ARM_ABS32:
relocation_needed = 1;
break;
+ case R_ARM_REL32:
+ case R_ARM_THM_PC11:
case R_ARM_THM_PC22:
relocation_needed = 0;
break;
default:
- printf("ERROR: reloc type %s unsupported in this context\n",
- q->howto->name);
- bad_relocs++;
- break;
+ goto bad_resolved_reloc;
+#elif defined(TARGET_m68k)
+ case R_68K_32:
+ goto good_32bit_resolved_reloc;
+ case R_68K_PC32:
+ case R_68K_PC16:
+ /* The linker has already resolved
+ PC relocs for us. In PIC links,
+ the symbol must be in the data
+ segment. */
+ case R_68K_NONE:
+ continue;
+ default:
+ goto bad_resolved_reloc;
#else
default:
/* The default is to assume that the
give an error by default, and
require `safe' relocations to be
enumberated explicitly?). */
+ goto good_32bit_resolve_reloc;
+#endif
+ good_32bit_resolved_reloc:
if (bfd_big_endian (abs_bfd))
sym_addr =
(r_mem[0] << 24)
+ (r_mem[2] << 16)
+ (r_mem[3] << 24);
relocation_needed = 1;
-#endif
+ break;
+
+ bad_resolved_reloc:
+ printf("ERROR: reloc type %s unsupported in this context\n",
+ q->howto->name);
+ bad_relocs++;
+ break;
}
} else {
/* Calculate the sym address ourselves. */
if (num > 0) {
/* It'd be nice if we could just use fseek, but that doesn't seem to
work for stdio output files. */
- bzero(zeroes, 1024);
+ memset(zeroes, 0x00, 1024);
while (num > sizeof(zeroes)) {
fwrite(zeroes, sizeof(zeroes), 1, stream);
num -= sizeof(zeroes);
use_resolved = 1;
break;
case 's':
- stack = atoi(optarg);
+ if (sscanf(optarg, "%i", &stack) != 1) {
+ fprintf(stderr, "%s invalid stack size %s\n", argv[0], optarg);
+ usage();
+ }
break;
case 'R':
rel_file = optarg;
}
text = malloc(text_len);
+ if (text == NULL) {
+ perror("malloc");
+ exit(1);
+ }
if (verbose)
printf("TEXT -> vma=0x%x len=0x%x\n", text_vma, text_len);
exit (2);
}
data = malloc(data_len);
+ if (data == NULL) {
+ perror("malloc");
+ exit(1);
+ }
if (verbose)
printf("DATA -> vma=0x%x len=0x%x\n", data_vma, data_len);
| (compress ? (compress == 2 ? FLAT_FLAG_GZDATA : FLAT_FLAG_GZIP) : 0)
);
hdr.build_date = htonl((unsigned long)time(NULL));
- bzero(hdr.filler, sizeof(hdr.filler));
+ memset(hdr.filler, 0x00, sizeof(hdr.filler));
for (i=0; i<reloc_len; i++) reloc[i] = htonl(reloc[i]);
if (!ofile) {
ofile = malloc(strlen(fname) + 5 + 1); /* 5 to add suffix */
+ if (ofile == NULL) {
+ perror("malloc");
+ exit(1);
+ }
strcpy(ofile, fname);
strcat(ofile, ".bflt");
}