* krab@california.daimi.aau.dk
*/
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <getopt.h>
-#include <stdarg.h>
-#include <bfd.h>
-#include <elf.h>
-#include "flat.h"
+#include <stdio.h> /* Userland pieces of the ANSI C standard I/O package */
+#include <stdlib.h> /* Userland prototypes of the ANSI C std lib functions */
+#include <stdarg.h> /* Allows va_list to exist in the these namespaces */
+#include <string.h> /* Userland prototypes of the string handling funcs */
+#include <strings.h>
+#include <unistd.h> /* Userland prototypes of the Unix std system calls */
+#include <fcntl.h> /* Flag value for file handling functions */
+#include <time.h>
+
+#include <netinet/in.h> /* Consts and structs defined by the internet system */
+
+/* from $(INSTALLDIR)/include */
+#include <bfd.h> /* Main header file for the BFD library */
+
+#include <elf.h> /* TARGET_* ELF support for the BFD library */
+
+/* from uClinux-x.x.x/include/linux */
+#include "flat.h" /* Binary flat header description */
+
+
+#ifdef TARGET_v850e
+#define TARGET_v850
+#endif
#if defined(TARGET_m68k)
#define ARCH "m68k/coldfire"
#elif defined(TARGET_v850)
#define ARCH "v850"
#else
-#error "Don't know how to support you CPU archiecture??"
+#error "Don't know how to support your CPU architecture??"
#endif
/*
int load_to_ram = 0; /* instruct loader to allocate everything into RAM */
int compress = 0; /* 1 = compress everything, 2 = compress data only */
int use_resolved = 0; /* If true, get the value of symbol references from */
- /* the program contents, not from the relocation table. */
- /* In this case, the input ELF file must be already */
- /* fully resolved (using the `-q' flag with recent */
- /* versions of GNU ld will give you a fully resolved */
- /* output file with relocation entries). */
+ /* the program contents, not from the relocation table. */
+ /* In this case, the input ELF file must be already */
+ /* fully resolved (using the `-q' flag with recent */
+ /* versions of GNU ld will give you a fully resolved */
+ /* output file with relocation entries). */
const char *progname, *filename;
int lineno;
if (type & E_WARNING) {
fprintf (stderr, "warning: ");
nwarnings++;
- }
- else
+ } else {
nerrors++;
+ }
va_start (args, format);
vfprintf (stderr, format, args);
if (storage_needed < 0)
abort ();
- if (storage_needed == 0) {
+ if (storage_needed == 0)
return NULL;
- }
symbol_table = (asymbol **) malloc (storage_needed);
sym_vma = bfd_section_vma(abs_bfd, sym_section);
sym_addr += sym_vma + q->addend;
break;
+ case R_ARM_GOT32:
+ case R_ARM_GOTPC:
+ /* Should be fine as is */
+ break;
case R_ARM_PLT32:
if (verbose)
fprintf(stderr,
tmp.l = *((unsigned long *) (sectionp + q->address));
hl = tmp.c[i0] | (tmp.c[i1] << 8) | (tmp.c[i2] << 16);
- if ((*p)->howto->type != R_ARM_PC24)
+ if (((*p)->howto->type != R_ARM_PC24) &&
+ ((*p)->howto->type != R_ARM_PLT32))
hl |= (tmp.c[i3] << 24);
else if (tmp.c[i2] & 0x80)
hl |= 0xff000000; /* sign extend */
tmp.c[i0] = hl & 0xff;
tmp.c[i1] = (hl >> 8) & 0xff;
tmp.c[i2] = (hl >> 16) & 0xff;
- if ((*p)->howto->type != R_ARM_PC24)
+ if (((*p)->howto->type != R_ARM_PC24) &&
+ ((*p)->howto->type != R_ARM_PLT32))
tmp.c[i3] = (hl >> 24) & 0xff;
if ((*p)->howto->type == R_ARM_ABS32)
*((unsigned long *) (sectionp + q->address)) = htonl(hl);
" -d : compress data/relocs\n"
" -a : use existing symbol references\n"
" instead of recalculating from\n"
- " relocation info\n");
+ " relocation info\n"
" -p abs-pic-file : GOT/PIC processing with files\n"
" -s stacksize : set application stack size\n"
" -o output-file : output file name\n\n",
s->lma, s->_cooked_size, s->output_offset,
s->alignment_power, s->filepos);
}
- if (text_len != data_vma) {
- if (text_len > data_vma) {
+ if ((text_vma + text_len) != data_vma) {
+ if ((text_vma + text_len) > data_vma) {
printf("ERROR: text=%x overlaps data=%x ?\n", text_len, data_vma);
exit(1);
}
if (verbose)
printf("WARNING: data=%x does not directly follow text=%x\n",
data_vma, text_len);
- text_len = data_vma;
+ text_len = data_vma - text_vma;
}
if (bfd_get_section_contents(abs_bfd,
s->alignment_power, s->filepos);
}
- if ((text_len + data_len) != bss_vma) {
- if ((text_len + data_len) > bss_vma) {
+ if ((text_vma + text_len + data_len) != bss_vma) {
+ if ((text_vma + text_len + data_len) > bss_vma) {
printf("ERROR: text=%x + data=%x overlaps bss=%x ?\n", text_len,
data_len, bss_vma);
exit(1);
if (verbose)
printf("WARNING: bss=%x does not directly follow text=%x + data=%x(%x)\n",
bss_vma, text_len, data_len, text_len + data_len);
- data_len = bss_vma - text_len;
+ data_len = bss_vma - data_vma;
}
reloc = (unsigned long *) output_relocs (abs_bfd, symbol_table,
| (pic_with_got ? FLAT_FLAG_GOTPIC : 0)
| (compress ? (compress == 2 ? FLAT_FLAG_GZDATA : FLAT_FLAG_GZIP) : 0)
);
+ hdr.build_date = htonl((unsigned long)time(NULL));
bzero(hdr.filler, sizeof(hdr.filler));
for (i=0; i<reloc_len; i++) reloc[i] = htonl(reloc[i]);