···22222323struct flat_hdr {
2424 char magic[4];
2525- target_ulong rev; /* version (as above) */
2626- target_ulong entry; /* Offset of first executable instruction
2727- with text segment from beginning of file */
2828- target_ulong data_start; /* Offset of data segment from beginning of
2929- file */
3030- target_ulong data_end; /* Offset of end of data segment
3131- from beginning of file */
3232- target_ulong bss_end; /* Offset of end of bss segment from beginning
3333- of file */
2525+ abi_ulong rev; /* version (as above) */
2626+ abi_ulong entry; /* Offset of first executable instruction
2727+ with text segment from beginning of file */
2828+ abi_ulong data_start; /* Offset of data segment from beginning of
2929+ file */
3030+ abi_ulong data_end; /* Offset of end of data segment
3131+ from beginning of file */
3232+ abi_ulong bss_end; /* Offset of end of bss segment from beginning
3333+ of file */
34343535 /* (It is assumed that data_end through bss_end forms the bss segment.) */
36363737- target_ulong stack_size; /* Size of stack, in bytes */
3838- target_ulong reloc_start; /* Offset of relocation records from
3939- beginning of file */
4040- target_ulong reloc_count; /* Number of relocation records */
4141- target_ulong flags;
4242- target_ulong build_date; /* When the program/library was built */
4343- target_ulong filler[5]; /* Reservered, set to zero */
3737+ abi_ulong stack_size; /* Size of stack, in bytes */
3838+ abi_ulong reloc_start; /* Offset of relocation records from
3939+ beginning of file */
4040+ abi_ulong reloc_count; /* Number of relocation records */
4141+ abi_ulong flags;
4242+ abi_ulong build_date; /* When the program/library was built */
4343+ abi_ulong filler[5]; /* Reservered, set to zero */
4444};
45454646#define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */
+46-46
linux-user/flatload.c
···6363#define UNLOADED_LIB 0x7ff000ff /* Placeholder for unused library */
64646565struct lib_info {
6666- target_ulong start_code; /* Start of text segment */
6767- target_ulong start_data; /* Start of data segment */
6868- target_ulong end_data; /* Start of bss section */
6969- target_ulong start_brk; /* End of data segment */
7070- target_ulong text_len; /* Length of text segment */
7171- target_ulong entry; /* Start address for this module */
7272- target_ulong build_date; /* When this one was compiled */
6666+ abi_ulong start_code; /* Start of text segment */
6767+ abi_ulong start_data; /* Start of data segment */
6868+ abi_ulong end_data; /* Start of bss section */
6969+ abi_ulong start_brk; /* End of data segment */
7070+ abi_ulong text_len; /* Length of text segment */
7171+ abi_ulong entry; /* Start address for this module */
7272+ abi_ulong build_date; /* When this one was compiled */
7373 short loaded; /* Has this library been loaded? */
7474};
7575···8989 */
90909191/* Push a block of strings onto the guest stack. */
9292-static target_ulong copy_strings(target_ulong p, int n, char **s)
9292+static abi_ulong copy_strings(abi_ulong p, int n, char **s)
9393{
9494 int len;
9595···102102 return p;
103103}
104104105105-int target_pread(int fd, target_ulong ptr, target_ulong len,
106106- target_ulong offset)
105105+int target_pread(int fd, abi_ulong ptr, abi_ulong len,
106106+ abi_ulong offset)
107107{
108108 void *buf;
109109 int ret;
···262262263263/****************************************************************************/
264264265265-static target_ulong
266266-calc_reloc(target_ulong r, struct lib_info *p, int curid, int internalp)
265265+static abi_ulong
266266+calc_reloc(abi_ulong r, struct lib_info *p, int curid, int internalp)
267267{
268268- target_ulong addr;
268268+ abi_ulong addr;
269269 int id;
270270- target_ulong start_brk;
271271- target_ulong start_data;
272272- target_ulong text_len;
273273- target_ulong start_code;
270270+ abi_ulong start_brk;
271271+ abi_ulong start_data;
272272+ abi_ulong text_len;
273273+ abi_ulong start_code;
274274275275#ifdef CONFIG_BINFMT_SHARED_FLAT
276276#error needs checking
···381381/****************************************************************************/
382382383383static int load_flat_file(struct linux_binprm * bprm,
384384- struct lib_info *libinfo, int id, target_ulong *extra_stack)
384384+ struct lib_info *libinfo, int id, abi_ulong *extra_stack)
385385{
386386 struct flat_hdr * hdr;
387387- target_ulong textpos = 0, datapos = 0, result;
388388- target_ulong realdatastart = 0;
389389- target_ulong text_len, data_len, bss_len, stack_len, flags;
390390- target_ulong memp = 0; /* for finding the brk area */
391391- target_ulong extra;
392392- target_ulong reloc = 0, rp;
387387+ abi_ulong textpos = 0, datapos = 0, result;
388388+ abi_ulong realdatastart = 0;
389389+ abi_ulong text_len, data_len, bss_len, stack_len, flags;
390390+ abi_ulong memp = 0; /* for finding the brk area */
391391+ abi_ulong extra;
392392+ abi_ulong reloc = 0, rp;
393393 int i, rev, relocs = 0;
394394- target_ulong fpos;
395395- target_ulong start_code, end_code;
396396- target_ulong indx_len;
394394+ abi_ulong fpos;
395395+ abi_ulong start_code, end_code;
396396+ abi_ulong indx_len;
397397398398 hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */
399399···440440 /*
441441 * calculate the extra space we need to map in
442442 */
443443- extra = relocs * sizeof(target_ulong);
443443+ extra = relocs * sizeof(abi_ulong);
444444 if (extra < bss_len + stack_len)
445445 extra = bss_len + stack_len;
446446447447 /* Add space for library base pointers. Make sure this does not
448448 misalign the doesn't misalign the data segment. */
449449- indx_len = MAX_SHARED_LIBS * sizeof(target_ulong);
450450- indx_len = (indx_len + 15) & ~(target_ulong)15;
449449+ indx_len = MAX_SHARED_LIBS * sizeof(abi_ulong);
450450+ indx_len = (indx_len + 15) & ~(abi_ulong)15;
451451452452 /*
453453 * there are a couple of cases here, the separate code/data
···485485#ifdef CONFIG_BINFMT_ZFLAT
486486 if (flags & FLAT_FLAG_GZDATA) {
487487 result = decompress_exec(bprm, fpos, (char *) datapos,
488488- data_len + (relocs * sizeof(target_ulong)))
488488+ data_len + (relocs * sizeof(abi_ulong)))
489489 } else
490490#endif
491491 {
492492 result = target_pread(bprm->fd, datapos,
493493- data_len + (relocs * sizeof(target_ulong)),
493493+ data_len + (relocs * sizeof(abi_ulong)),
494494 fpos);
495495 }
496496 if (result < 0) {
···544544 text_len, 0);
545545 if (result >= 0) {
546546 result = target_pread(bprm->fd, datapos,
547547- data_len + (relocs * sizeof(target_ulong)),
547547+ data_len + (relocs * sizeof(abi_ulong)),
548548 ntohl(hdr->data_start));
549549 }
550550 }
···597597 if (flags & FLAT_FLAG_GOTPIC) {
598598 rp = datapos;
599599 while (1) {
600600- target_ulong addr;
600600+ abi_ulong addr;
601601 addr = tgetl(rp);
602602 if (addr == -1)
603603 break;
···607607 return -ENOEXEC;
608608 tputl(rp, addr);
609609 }
610610- rp += sizeof(target_ulong);
610610+ rp += sizeof(abi_ulong);
611611 }
612612 }
613613···624624 */
625625 if (rev > OLD_FLAT_VERSION) {
626626 for (i = 0; i < relocs; i++) {
627627- target_ulong addr, relval;
627627+ abi_ulong addr, relval;
628628629629 /* Get the address of the pointer to be
630630 relocated (of course, the address has to be
631631 relocated first). */
632632- relval = tgetl(reloc + i * sizeof (target_ulong));
632632+ relval = tgetl(reloc + i * sizeof (abi_ulong));
633633 addr = flat_get_relocate_addr(relval);
634634 rp = calc_reloc(addr, libinfo, id, 1);
635635 if (rp == RELOC_FAILED)
···657657 }
658658 } else {
659659 for (i = 0; i < relocs; i++) {
660660- target_ulong relval;
661661- relval = tgetl(reloc + i * sizeof (target_ulong));
660660+ abi_ulong relval;
661661+ relval = tgetl(reloc + i * sizeof (abi_ulong));
662662 old_reloc(&libinfo[0], relval);
663663 }
664664 }
···712712 struct image_info * info)
713713{
714714 struct lib_info libinfo[MAX_SHARED_LIBS];
715715- target_ulong p = bprm->p;
716716- target_ulong stack_len;
717717- target_ulong start_addr;
718718- target_ulong sp;
715715+ abi_ulong p = bprm->p;
716716+ abi_ulong stack_len;
717717+ abi_ulong start_addr;
718718+ abi_ulong sp;
719719 int res;
720720 int i, j;
721721···740740 /* Update data segment pointers for all libraries */
741741 for (i=0; i<MAX_SHARED_LIBS; i++) {
742742 if (libinfo[i].loaded) {
743743- target_ulong p;
743743+ abi_ulong p;
744744 p = libinfo[i].start_data;
745745 for (j=0; j<MAX_SHARED_LIBS; j++) {
746746 p -= 4;
···758758 p = copy_strings(p, bprm->envc, bprm->envp);
759759 p = copy_strings(p, bprm->argc, bprm->argv);
760760 /* Align stack. */
761761- sp = p & ~(target_ulong)(sizeof(target_ulong) - 1);
761761+ sp = p & ~(abi_ulong)(sizeof(abi_ulong) - 1);
762762 /* Enforce final stack alignment of 16 bytes. This is sufficient
763763 for all current targets, and excess alignment is harmless. */
764764 stack_len = bprm->envc + bprm->argc + 2;
765765 stack_len += 3; /* argc, arvg, argp */
766766- stack_len *= sizeof(target_ulong);
766766+ stack_len *= sizeof(abi_ulong);
767767 if ((sp + stack_len) & 15)
768768 sp -= 16 - ((sp + stack_len) & 15);
769769 sp = loader_build_argptr(bprm->envc, bprm->argc, sp, p, 1);