41
41
42
42
#include "qemu.h"
43
43
#include "flat.h"
44
+ #define ntohl (x ) be32_to_cpu(x)
45
+ #include <target_flat.h>
44
46
45
47
//#define DEBUG
46
48
50
52
#define DBG_FLT (...)
51
53
#endif
52
54
53
- #define flat_reloc_valid (reloc , size ) ((reloc) <= (size))
54
- #define flat_old_ram_flag (flag ) (flag)
55
- #ifdef TARGET_WORDS_BIGENDIAN
56
- #define flat_get_relocate_addr (relval ) (relval)
57
- #else
58
- #define flat_get_relocate_addr (relval ) bswap32(relval)
59
- #endif
60
-
61
55
#define RELOC_FAILED 0xff00ff01 /* Relocation incorrect somewhere */
62
56
#define UNLOADED_LIB 0x7ff000ff /* Placeholder for unused library */
63
57
@@ -78,8 +72,6 @@ static int load_flat_shared_library(int id, struct lib_info *p);
78
72
79
73
struct linux_binprm ;
80
74
81
- #define ntohl (x ) be32_to_cpu(x)
82
-
83
75
/****************************************************************************/
84
76
/*
85
77
* create_flat_tables() parses the env- and arg-strings in new user
@@ -625,6 +617,7 @@ static int load_flat_file(struct linux_binprm * bprm,
625
617
* __start to address 4 so that is okay).
626
618
*/
627
619
if (rev > OLD_FLAT_VERSION ) {
620
+ abi_ulong persistent = 0 ;
628
621
for (i = 0 ; i < relocs ; i ++ ) {
629
622
abi_ulong addr , relval ;
630
623
@@ -633,6 +626,9 @@ static int load_flat_file(struct linux_binprm * bprm,
633
626
relocated first). */
634
627
if (get_user_ual (relval , reloc + i * sizeof (abi_ulong )))
635
628
return - EFAULT ;
629
+ relval = ntohl (relval );
630
+ if (flat_set_persistent (relval , & persistent ))
631
+ continue ;
636
632
addr = flat_get_relocate_addr (relval );
637
633
rp = calc_reloc (addr , libinfo , id , 1 );
638
634
if (rp == RELOC_FAILED )
@@ -641,22 +637,20 @@ static int load_flat_file(struct linux_binprm * bprm,
641
637
/* Get the pointer's value. */
642
638
if (get_user_ual (addr , rp ))
643
639
return - EFAULT ;
640
+ addr = flat_get_addr_from_rp (rp , relval , flags , & persistent );
644
641
if (addr != 0 ) {
645
642
/*
646
643
* Do the relocation. PIC relocs in the data section are
647
644
* already in target order
648
645
*/
649
-
650
- #ifndef TARGET_WORDS_BIGENDIAN
651
646
if ((flags & FLAT_FLAG_GOTPIC ) == 0 )
652
- addr = bswap32 (addr );
653
- #endif
647
+ addr = ntohl (addr );
654
648
addr = calc_reloc (addr , libinfo , id , 0 );
655
649
if (addr == RELOC_FAILED )
656
650
return - ENOEXEC ;
657
651
658
652
/* Write back the relocated pointer. */
659
- if (put_user_ual ( addr , rp ))
653
+ if (flat_put_addr_at_rp ( rp , addr , relval ))
660
654
return - EFAULT ;
661
655
}
662
656
}
@@ -782,7 +776,8 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
782
776
stack_len *= sizeof (abi_ulong );
783
777
if ((sp + stack_len ) & 15 )
784
778
sp -= 16 - ((sp + stack_len ) & 15 );
785
- sp = loader_build_argptr (bprm -> envc , bprm -> argc , sp , p , 1 );
779
+ sp = loader_build_argptr (bprm -> envc , bprm -> argc , sp , p ,
780
+ flat_argvp_envp_on_stack ());
786
781
787
782
/* Fake some return addresses to ensure the call chain will
788
783
* initialise library in order for us. We are required to call
0 commit comments