52
52
53
53
#include "elf.h"
54
54
55
- struct exec
56
- {
57
- unsigned int a_info ; /* Use macros N_MAGIC, etc for access */
58
- unsigned int a_text ; /* length of text, in bytes */
59
- unsigned int a_data ; /* length of data, in bytes */
60
- unsigned int a_bss ; /* length of uninitialized data area, in bytes */
61
- unsigned int a_syms ; /* length of symbol table data in file, in bytes */
62
- unsigned int a_entry ; /* start address */
63
- unsigned int a_trsize ; /* length of relocation info for text, in bytes */
64
- unsigned int a_drsize ; /* length of relocation info for data, in bytes */
65
- };
66
-
67
-
68
- #define N_MAGIC (exec ) ((exec).a_info & 0xffff)
69
- #define OMAGIC 0407
70
- #define NMAGIC 0410
71
- #define ZMAGIC 0413
72
- #define QMAGIC 0314
73
-
74
55
/* max code+data+bss space allocated to elf interpreter */
75
56
#define INTERP_MAP_SIZE (32 * 1024 * 1024)
76
57
@@ -82,19 +63,13 @@ struct exec
82
63
#define TARGET_ELF_PAGESTART (_v ) ((_v) & ~(unsigned long)(TARGET_ELF_EXEC_PAGESIZE - 1))
83
64
#define TARGET_ELF_PAGEOFFSET (_v ) ((_v) & (TARGET_ELF_EXEC_PAGESIZE - 1))
84
65
85
- #define INTERPRETER_NONE 0
86
- #define INTERPRETER_AOUT 1
87
- #define INTERPRETER_ELF 2
88
-
89
66
#define DLINFO_ITEMS 12
90
67
91
68
static inline void memcpy_fromfs (void * to , const void * from , unsigned long n )
92
69
{
93
70
memcpy (to , from , n );
94
71
}
95
72
96
- static int load_aout_interp (void * exptr , int interp_fd );
97
-
98
73
#ifdef BSWAP_NEEDED
99
74
static void bswap_ehdr (struct elfhdr * ehdr )
100
75
{
@@ -300,7 +275,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
300
275
struct elfhdr * exec ,
301
276
abi_ulong load_addr ,
302
277
abi_ulong load_bias ,
303
- abi_ulong interp_load_addr , int ibcs ,
278
+ abi_ulong interp_load_addr ,
304
279
struct image_info * info )
305
280
{
306
281
abi_ulong sp ;
@@ -330,7 +305,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
330
305
size += DLINFO_ARCH_ITEMS * 2 ;
331
306
#endif
332
307
size += envc + argc + 2 ;
333
- size += (! ibcs ? 3 : 1 ) ; /* argc itself */
308
+ size += 1 ; /* argc itself */
334
309
size *= n ;
335
310
if (size & 15 )
336
311
sp -= 16 - (size & 15 );
@@ -370,7 +345,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
370
345
#endif
371
346
#undef NEW_AUX_ENT
372
347
373
- sp = loader_build_argptr (envc , argc , sp , p , ! ibcs );
348
+ sp = loader_build_argptr (envc , argc , sp , p );
374
349
return sp ;
375
350
}
376
351
@@ -432,7 +407,7 @@ static abi_ulong load_elf_interp(struct elfhdr *interp_elf_ex,
432
407
if (retval < 0 ) {
433
408
perror ("load_elf_interp" );
434
409
exit (-1 );
435
- free (elf_phdata );
410
+ free (elf_phdata );
436
411
return retval ;
437
412
}
438
413
#ifdef BSWAP_NEEDED
@@ -685,11 +660,9 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
685
660
{
686
661
struct elfhdr elf_ex ;
687
662
struct elfhdr interp_elf_ex ;
688
- struct exec interp_ex ;
689
663
int interpreter_fd = -1 ; /* avoid warning */
690
664
abi_ulong load_addr , load_bias ;
691
665
int load_addr_set = 0 ;
692
- unsigned int interpreter_type = INTERPRETER_NONE ;
693
666
int i ;
694
667
struct elf_phdr * elf_ppnt ;
695
668
struct elf_phdr * elf_phdata ;
@@ -702,7 +675,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
702
675
#ifdef LOW_ELF_STACK
703
676
abi_ulong elf_stack = ~((abi_ulong )0UL );
704
677
#endif
705
- char passed_fileno [6 ];
706
678
707
679
load_addr = 0 ;
708
680
load_bias = 0 ;
@@ -760,7 +732,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
760
732
end_code = 0 ;
761
733
start_data = 0 ;
762
734
end_data = 0 ;
763
- interp_ex .a_info = 0 ;
764
735
765
736
for (i = 0 ;i < elf_ex .e_phnum ; i ++ ) {
766
737
if (elf_ppnt -> p_type == PT_INTERP ) {
@@ -813,7 +784,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
813
784
}
814
785
}
815
786
if (retval >= 0 ) {
816
- interp_ex = * ((struct exec * ) bprm -> buf ); /* aout exec-header */
817
787
interp_elf_ex = * ((struct elfhdr * ) bprm -> buf ); /* elf exec-header */
818
788
}
819
789
if (retval < 0 ) {
@@ -830,20 +800,8 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
830
800
831
801
/* Some simple consistency checks for the interpreter */
832
802
if (elf_interpreter ) {
833
- interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT ;
834
-
835
- /* Now figure out which format our binary is */
836
- if ((N_MAGIC (interp_ex ) != OMAGIC ) && (N_MAGIC (interp_ex ) != ZMAGIC ) &&
837
- (N_MAGIC (interp_ex ) != QMAGIC )) {
838
- interpreter_type = INTERPRETER_ELF ;
839
- }
840
-
841
803
if (interp_elf_ex .e_ident [0 ] != 0x7f ||
842
- strncmp ((char * )& interp_elf_ex .e_ident [1 ], "ELF" , 3 ) != 0 ) {
843
- interpreter_type &= ~INTERPRETER_ELF ;
844
- }
845
-
846
- if (!interpreter_type ) {
804
+ strncmp ((char * )& interp_elf_ex .e_ident [1 ], "ELF" , 3 ) != 0 ) {
847
805
free (elf_interpreter );
848
806
free (elf_phdata );
849
807
close (bprm -> fd );
@@ -854,24 +812,11 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
854
812
/* OK, we are done with that, now set up the arg stuff,
855
813
and then start this sucker up */
856
814
857
- {
858
- char * passed_p ;
859
-
860
- if (interpreter_type == INTERPRETER_AOUT ) {
861
- snprintf (passed_fileno , sizeof (passed_fileno ), "%d" , bprm -> fd );
862
- passed_p = passed_fileno ;
863
-
864
- if (elf_interpreter ) {
865
- bprm -> p = copy_elf_strings (1 , & passed_p , bprm -> page , bprm -> p );
866
- bprm -> argc ++ ;
867
- }
868
- }
869
- if (!bprm -> p ) {
870
- free (elf_interpreter );
871
- free (elf_phdata );
872
- close (bprm -> fd );
873
- return - E2BIG ;
874
- }
815
+ if (!bprm -> p ) {
816
+ free (elf_interpreter );
817
+ free (elf_phdata );
818
+ close (bprm -> fd );
819
+ return - E2BIG ;
875
820
}
876
821
877
822
/* OK, This is the point of no return */
@@ -997,13 +942,8 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
997
942
end_data += load_bias ;
998
943
999
944
if (elf_interpreter ) {
1000
- if (interpreter_type & 1 ) {
1001
- elf_entry = load_aout_interp (& interp_ex , interpreter_fd );
1002
- }
1003
- else if (interpreter_type & 2 ) {
1004
- elf_entry = load_elf_interp (& interp_elf_ex , interpreter_fd ,
1005
- & interp_load_addr );
1006
- }
945
+ elf_entry = load_elf_interp (& interp_elf_ex , interpreter_fd ,
946
+ & interp_load_addr );
1007
947
reloc_func_desc = interp_load_addr ;
1008
948
1009
949
close (interpreter_fd );
@@ -1022,19 +962,18 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
1022
962
if (qemu_log_enabled ())
1023
963
load_symbols (& elf_ex , bprm -> fd );
1024
964
1025
- if ( interpreter_type != INTERPRETER_AOUT ) close (bprm -> fd );
965
+ close (bprm -> fd );
1026
966
1027
967
#ifdef LOW_ELF_STACK
1028
968
info -> start_stack = bprm -> p = elf_stack - 4 ;
1029
969
#endif
1030
970
bprm -> p = create_elf_tables (bprm -> p ,
1031
- bprm -> argc ,
1032
- bprm -> envc ,
1033
- & elf_ex ,
1034
- load_addr , load_bias ,
1035
- interp_load_addr ,
1036
- (interpreter_type == INTERPRETER_AOUT ? 0 : 1 ),
1037
- info );
971
+ bprm -> argc ,
972
+ bprm -> envc ,
973
+ & elf_ex ,
974
+ load_addr , load_bias ,
975
+ interp_load_addr ,
976
+ info );
1038
977
info -> load_addr = reloc_func_desc ;
1039
978
info -> start_brk = info -> brk = elf_brk ;
1040
979
info -> end_code = end_code ;
@@ -1063,12 +1002,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
1063
1002
return 0 ;
1064
1003
}
1065
1004
1066
- static int load_aout_interp (void * exptr , int interp_fd )
1067
- {
1068
- printf ("a.out interpreter not yet supported\n" );
1069
- return (0 );
1070
- }
1071
-
1072
1005
void do_init_thread (struct target_pt_regs * regs , struct image_info * infop )
1073
1006
{
1074
1007
init_thread (regs , infop );
0 commit comments