[L4alpha-cvscommit] CVS: dite/src dit.c,1.9,1.10 edit.c,1.26,1.27 elf32.c,1.16,1.17
Status: Beta
Brought to you by:
dpotts
|
From: Simon W. <sj...@us...> - 2002-06-03 08:44:54
|
Update of /cvsroot/l4alpha/dite/src
In directory usw-pr-cvs1:/tmp/cvs-serv11239/src
Modified Files:
dit.c edit.c elf32.c
Log Message:
MIPS changes
Index: dit.c
===================================================================
RCS file: /cvsroot/l4alpha/dite/src/dit.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** dit.c 27 Mar 2001 07:06:37 -0000 1.9
--- dit.c 3 Jun 2002 08:44:47 -0000 1.10
***************
*** 2,6 ****
* Project: EDIT --- Extended DIT.
* Created: 21/07/2000 07:47:23 by Simon Winwood (sjw)
! * Last Modified: 27/03/2001 16:56:55 by (sjw)
* Version info: $Revision$
* Description:
--- 2,6 ----
* Project: EDIT --- Extended DIT.
* Created: 21/07/2000 07:47:23 by Simon Winwood (sjw)
! * Last Modified: 03/06/2002 18:20:58 by Simon Winwood (sjw)
* Version info: $Revision$
* Description:
***************
*** 16,19 ****
--- 16,22 ----
*
* $Log$
+ * Revision 1.10 2002/06/03 08:44:47 sjw_
+ * MIPS changes
+ *
* Revision 1.9 2001/03/27 07:06:37 sjw
* Added copyright notices to all of my files.
***************
*** 110,113 ****
--- 113,118 ----
return 1;
+ log(LOG_LOW, "DIT segment is %d\n", i);
+
memmove(&(source->segments[i]), &(source->segments[i + 1]),
(--source->nsegments - i) * sizeof(struct edit_segment));
***************
*** 167,170 ****
--- 172,195 ----
}
+ uint64_t get_end_addr(struct edit_file *efile, int dit_segment)
+ {
+ int i;
+ struct edit_segment *segs;
+ unsigned long link_addr;
+
+ i = efile->nsegments - 1;
+ segs = efile->segments;
+
+ /* Note that we also need to leave a page for the DIT header ... sigh */
+ link_addr = ALIGN(segs[i].memsize + segs[i].vaddr - efile->offset, efile->pagesize);
+ if(dit_segment == efile->nsegments) {
+ link_addr += efile->pagesize;
+ /* in MIPS L4, the kinfo page is right after the DIT page ... this won't hurt anyone else, I hope */
+ link_addr += efile->pagesize;
+ }
+
+ return link_addr;
+ }
+
/* Creates the DIT segment and adds it to the efile */
uint64_t add_dit_segment(struct edit_file *efile, int dit_segment)
***************
*** 174,178 ****
struct edit_segment *seg;
unsigned long phoffset;
! uint64_t vaddr;
Dit_Phdr *phdr = efile->phdrs;
int i;
--- 199,203 ----
struct edit_segment *seg;
unsigned long phoffset;
! uint64_t vaddr, vaddrend;
Dit_Phdr *phdr = efile->phdrs;
int i;
***************
*** 207,210 ****
--- 232,241 ----
}
+ seg->vaddr = vaddr;
+ seg->paddr = vaddr; /* FIXME (sjw Fri Jul 21 09:22:55 2000 ) --- Correct? */
+ seg->memsize = efile->pagesize;
+
+ vaddrend = get_end_addr(efile, dit_segment);
+
/* Fill in dhdr */
d_ident = dit_seg;
***************
*** 221,226 ****
offsetof(Dit_Dhdr, d_fileend) + dit_seg, efile->endianness);
! write32(vaddr + sizeof(Dit_Dhdr) + efile->ndit * sizeof(Dit_Phdr),
! offsetof(Dit_Dhdr, d_vaddrend) + dit_seg, efile->endianness);
phoffset = (unsigned long) dit_seg + sizeof(Dit_Dhdr);
--- 252,256 ----
offsetof(Dit_Dhdr, d_fileend) + dit_seg, efile->endianness);
! write32(vaddrend, offsetof(Dit_Dhdr, d_vaddrend) + dit_seg, efile->endianness);
phoffset = (unsigned long) dit_seg + sizeof(Dit_Dhdr);
***************
*** 236,245 ****
}
- seg->vaddr = vaddr;
- seg->paddr = vaddr; /* FIXME (sjw Fri Jul 21 09:22:55 2000 ) --- Correct? */
-
/* FIXME (sjw Tue Sep 26 03:05:20 2000 ) --- Correct? */
seg->filesize = sizeof(Dit_Dhdr) + efile->ndit * sizeof(Dit_Phdr);
- seg->memsize = efile->pagesize;
/* Don't care about alignment */
--- 266,271 ----
Index: edit.c
===================================================================
RCS file: /cvsroot/l4alpha/dite/src/edit.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** edit.c 27 Mar 2001 07:06:36 -0000 1.26
--- edit.c 3 Jun 2002 08:44:47 -0000 1.27
***************
*** 2,6 ****
* Project: EDIT --- Extended DIT
* Created: 12/07/2000 19:46:03 by Simon Winwood (sjw)
! * Last Modified: 27/03/2001 16:57:18 by (sjw)
* Version info: $Revision$
* Description:
--- 2,6 ----
* Project: EDIT --- Extended DIT
* Created: 12/07/2000 19:46:03 by Simon Winwood (sjw)
! * Last Modified: 03/06/2002 15:55:13 by Simon Winwood (sjw)
* Version info: $Revision$
* Description:
***************
*** 18,21 ****
--- 18,24 ----
*
* $Log$
+ * Revision 1.27 2002/06/03 08:44:47 sjw_
+ * MIPS changes
+ *
* Revision 1.26 2001/03/27 07:06:36 sjw
* Added copyright notices to all of my files.
***************
*** 196,200 ****
}
! const static char *optstring = "-hVvqt:D:o:O:a:dluRe:b:xri";
const struct option longopts[] = {
--- 199,203 ----
}
! const static char *optstring = "-hVvqnt:D:o:O:a:dluRe:b:xri";
const struct option longopts[] = {
***************
*** 547,550 ****
--- 550,554 ----
target.entry = (target.entry == 0 ? sources[i].entry : target.entry);
+ sources[i].offset = target.offset;
if(sources[i].objtype != OBJ_RAW) {
***************
*** 571,575 ****
merge_dit(&(sources[0]), &(sources[0]));
! print_link(&(sources[0]));
exit(EXIT_SUCCESS);
--- 575,579 ----
merge_dit(&(sources[0]), &(sources[0]));
! print_link(&(sources[0]), dit_segment);
exit(EXIT_SUCCESS);
***************
*** 599,605 ****
merge_files(&target, num_sources, sources);
! if(add_dit_segment(&target, dit_segment)) {
! log(LOG_CRITICAL, "Couldn't add DIT segment\n");
! exit(EXIT_FAILURE);
}
--- 603,611 ----
merge_files(&target, num_sources, sources);
! if(!(target.flags & FL_NODIT)) {
! if(add_dit_segment(&target, dit_segment)) {
! log(LOG_CRITICAL, "Couldn't add DIT segment\n");
! exit(EXIT_FAILURE);
! }
}
***************
*** 698,711 ****
}
! int print_link(struct edit_file *efile)
{
int i;
struct edit_segment *segs;
!
! /* Align the output file to the desired value */
! i = efile->nsegments - 1;
segs = efile->segments;
/* FIXME (sjw Mon Sep 25 18:27:55 2000 ) --- Correct? */
! printf("0x%lx\n", ALIGN(segs[i].memsize + segs[i].vaddr - efile->offset, efile->pagesize));
return 0;
--- 704,726 ----
}
! int print_link(struct edit_file *efile, int dit_segment)
{
int i;
struct edit_segment *segs;
! unsigned long link_addr;
!
! i = efile->nsegments - 1;
segs = efile->segments;
+
+ /* Note that we also need to leave a page for the DIT header ... sigh */
+ link_addr = ALIGN(segs[i].memsize + segs[i].vaddr - efile->offset, efile->pagesize);
+ if(dit_segment == efile->nsegments) {
+ link_addr += efile->pagesize;
+ /* in MIPS L4, the kinfo page is right after the DIT page ... this won't hurt anyone else, I hope */
+ link_addr += efile->pagesize;
+ }
+ /* Align the output file to the desired value */
/* FIXME (sjw Mon Sep 25 18:27:55 2000 ) --- Correct? */
! printf("0x%lx\n", link_addr);
return 0;
Index: elf32.c
===================================================================
RCS file: /cvsroot/l4alpha/dite/src/elf32.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** elf32.c 27 Mar 2001 07:06:36 -0000 1.16
--- elf32.c 3 Jun 2002 08:44:47 -0000 1.17
***************
*** 2,6 ****
* Project: EDIT --- Extended DIT
* Created: 12/07/2000 19:40:57 by Simon Winwood (sjw)
! * Last Modified: 27/03/2001 16:57:43 by (sjw)
* Version info: $Revision$
* Description:
--- 2,6 ----
* Project: EDIT --- Extended DIT
* Created: 12/07/2000 19:40:57 by Simon Winwood (sjw)
! * Last Modified: 03/06/2002 15:39:02 by Simon Winwood (sjw)
* Version info: $Revision$
* Description:
***************
*** 17,20 ****
--- 17,23 ----
*
* $Log$
+ * Revision 1.17 2002/06/03 08:44:47 sjw_
+ * MIPS changes
+ *
* Revision 1.16 2001/03/27 07:06:36 sjw
* Added copyright notices to all of my files.
***************
*** 218,222 ****
void *target_map;
uint64_t dit_vaddr;
! int file_size, data_start, next_data, i;
struct edit_segment *segs = efile->segments;
Elf32_Ehdr ehdr;
--- 221,225 ----
void *target_map;
uint64_t dit_vaddr;
! int file_size, data_start, next_data, shdr_start, i;
struct edit_segment *segs = efile->segments;
Elf32_Ehdr ehdr;
***************
*** 236,241 ****
/* Find size of file -- include space for header. Segments will be calculated later */
! next_data = data_start = file_size = sizeof(Elf32_Ehdr) + sizeof(Elf32_Shdr)
! + (sizeof(Elf32_Phdr) * (efile->nsegments));
memset(&ehdr, 0, sizeof(Elf32_Ehdr));
--- 239,247 ----
/* Find size of file -- include space for header. Segments will be calculated later */
! shdr_start = next_data = data_start = file_size =
! sizeof(Elf32_Ehdr) + (sizeof(Elf32_Phdr) * (efile->nsegments));
!
! for(i = 0; i < efile->nsegments; i++)
! shdr_start += segs[i].filesize;
memset(&ehdr, 0, sizeof(Elf32_Ehdr));
***************
*** 256,261 ****
write32(efile->entry, &(ehdr.e_entry), efile->endianness);
! write32(sizeof(Elf32_Ehdr) + sizeof(Elf32_Shdr), &(ehdr.e_phoff), efile->endianness);
! write32(sizeof(Elf32_Ehdr), &(ehdr.e_shoff), efile->endianness);
write32(elfarchflags(efile->arch), &(ehdr.e_flags), efile->endianness);
write16(sizeof(Elf32_Ehdr), &(ehdr.e_ehsize), efile->endianness);
--- 262,267 ----
write32(efile->entry, &(ehdr.e_entry), efile->endianness);
! write32(sizeof(Elf32_Ehdr), &(ehdr.e_phoff), efile->endianness);
! write32(shdr_start, &(ehdr.e_shoff), efile->endianness);
write32(elfarchflags(efile->arch), &(ehdr.e_flags), efile->endianness);
write16(sizeof(Elf32_Ehdr), &(ehdr.e_ehsize), efile->endianness);
***************
*** 274,283 ****
}
- memset(&shdr, 0, sizeof(Elf32_Shdr));
- if(fwrite(&shdr, sizeof(Elf32_Shdr), 1, fptr) != 1) {
- log(LOG_CRITICAL, "Could not write to '%s'\n", efile->filename);
- return 1;
- }
-
memset(&phdr, 0, sizeof(Elf32_Phdr));
--- 280,283 ----
***************
*** 322,325 ****
--- 322,332 ----
next_data += segs[i].filesize;
+ }
+
+ /* Write out the section headers (empty) */
+ memset(&shdr, 0, sizeof(Elf32_Shdr));
+ if(fwrite(&shdr, sizeof(Elf32_Shdr), 1, fptr) != 1) {
+ log(LOG_CRITICAL, "Could not write to '%s'\n", efile->filename);
+ return 1;
}
|