aboutsummaryrefslogtreecommitdiffstats
path: root/src/unexec.c
diff options
context:
space:
mode:
authorMiles Bader2008-01-30 07:57:28 +0000
committerMiles Bader2008-01-30 07:57:28 +0000
commitd235ca2ff8fab139ce797757fcb159d1e28fa7e0 (patch)
tree96c5cd1a06a0d9dc26e8470c6eabfc032c0046f3 /src/unexec.c
parent3709a060f679dba14df71ae64a0035fa2b5b3106 (diff)
parent02cbe062bee38a6705bafb1699d77e3c44cfafcf (diff)
downloademacs-d235ca2ff8fab139ce797757fcb159d1e28fa7e0.tar.gz
emacs-d235ca2ff8fab139ce797757fcb159d1e28fa7e0.zip
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-324
Diffstat (limited to 'src/unexec.c')
-rw-r--r--src/unexec.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/src/unexec.c b/src/unexec.c
index 05cff698313..b0ef8fc4d51 100644
--- a/src/unexec.c
+++ b/src/unexec.c
@@ -975,92 +975,9 @@ copy_text_and_data (new, a_out)
975 lseek (new, (long) N_TXTOFF (hdr), 0); 975 lseek (new, (long) N_TXTOFF (hdr), 0);
976#endif /* no A_TEXT_SEEK */ 976#endif /* no A_TEXT_SEEK */
977 977
978#ifdef RISCiX
979
980 /* Acorn's RISC-iX has a wacky way of initialising the position of the heap.
981 * There is a little table in crt0.o that is filled at link time with
982 * the min and current brk positions, among other things. When start
983 * runs, it copies the table to where these parameters live during
984 * execution. This data is in text space, so it cannot be modified here
985 * before saving the executable, so the data is written manually. In
986 * addition, the table does not have a label, and the nearest accessible
987 * label (mcount) is not prefixed with a '_', thus making it inaccessible
988 * from within C programs. To overcome this, emacs's executable is passed
989 * through the command 'nm %s | fgrep mcount' into a pipe, and the
990 * resultant output is then used to find the address of 'mcount'. As far as
991 * is possible to determine, in RISC-iX releases prior to 1.2, the negative
992 * offset of the table from mcount is 0x2c, whereas from 1.2 onwards it is
993 * 0x30. bss_end has been rounded up to page boundary. This solution is
994 * based on suggestions made by Kevin Welton and Steve Hunt of Acorn, and
995 * avoids the need for a custom version of crt0.o for emacs which has its
996 * table in data space.
997 */
998
999 {
1000 char command[1024];
1001 char errbuf[1024];
1002 char address_text[32];
1003 int proforma[4];
1004 FILE *pfile;
1005 char *temp_ptr;
1006 char c;
1007 int mcount_address, mcount_offset, count;
1008 extern char *_execname;
1009
1010
1011 /* The use of _execname is incompatible with RISCiX 1.1 */
1012 sprintf (command, "nm %s | fgrep mcount", _execname);
1013
1014 if ( (pfile = popen(command, "r")) == NULL)
1015 {
1016 sprintf (errbuf, "Could not open pipe");
1017 PERROR (errbuf);
1018 }
1019
1020 count=0;
1021 while ( ((c=getc(pfile)) != EOF) && (c != ' ') && (count < 31))
1022 address_text[count++]=c;
1023 address_text[count]=0;
1024
1025 if ((count == 0) || pclose(pfile) != NULL)
1026 {
1027 sprintf (errbuf, "Failed to execute the command '%s'\n", command);
1028 PERROR (errbuf);
1029 }
1030
1031 sscanf(address_text, "%x", &mcount_address);
1032 ptr = (char *) unexec_text_start;
1033 mcount_offset = (char *)mcount_address - ptr;
1034
1035#ifdef RISCiX_1_1
1036#define EDATA_OFFSET 0x2c
1037#else
1038#define EDATA_OFFSET 0x30
1039#endif
1040
1041 end = ptr + mcount_offset - EDATA_OFFSET;
1042
1043 write_segment (new, ptr, end);
1044
1045 proforma[0] = bss_end; /* becomes _edata */
1046 proforma[1] = bss_end; /* becomes _end */
1047 proforma[2] = bss_end; /* becomes _minbrk */
1048 proforma[3] = bss_end; /* becomes _curbrk */
1049
1050 write (new, proforma, 16);
1051
1052 temp_ptr = ptr;
1053 ptr = end + 16;
1054 end = temp_ptr + hdr.a_text;
1055
1056 write_segment (new, ptr, end);
1057 }
1058
1059#else /* !RISCiX */
1060 ptr = (char *) unexec_text_start; 978 ptr = (char *) unexec_text_start;
1061 end = ptr + hdr.a_text; 979 end = ptr + hdr.a_text;
1062 write_segment (new, ptr, end); 980 write_segment (new, ptr, end);
1063#endif /* RISCiX */
1064 981
1065 ptr = (char *) unexec_data_start; 982 ptr = (char *) unexec_data_start;
1066 end = ptr + hdr.a_data; 983 end = ptr + hdr.a_data;
@@ -1175,13 +1092,8 @@ adjust_lnnoptrs (writedesc, readdesc, new_name)
1175{ 1092{
1176 register int nsyms; 1093 register int nsyms;
1177 register int new; 1094 register int new;
1178#if defined (amdahl_uts) || defined (pfa)
1179 SYMENT symentry;
1180 AUXENT auxentry;
1181#else
1182 struct syment symentry; 1095 struct syment symentry;
1183 union auxent auxentry; 1096 union auxent auxentry;
1184#endif
1185 1097
1186 if (!lnnoptr || !f_hdr.f_symptr) 1098 if (!lnnoptr || !f_hdr.f_symptr)
1187 return 0; 1099 return 0;