aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-02-12 10:43:11 -0800
committerPaul Eggert2013-02-12 10:43:11 -0800
commitf53f992ad53e62a8452884f9322250894ddbb505 (patch)
tree2f9acf504b252629809a67f436166a84355a72fc /src
parent4458c2551b1a0bd89e5c299b009516e17f255c28 (diff)
downloademacs-f53f992ad53e62a8452884f9322250894ddbb505.tar.gz
emacs-f53f992ad53e62a8452884f9322250894ddbb505.zip
Improve AIX port some more.
With this, it should be as good as it was in 23.3, though it's still pretty bad: the dumped emacs does not run. See Mark Fleishman in http://lists.gnu.org/archive/html/help-gnu-emacs/2011-04/msg00287.html * unexaix.c (start_of_text): Remove. (_data, _text): Declare as char[], not int, as AIX manual suggests. (bias, lnnoptr, text_scnptr, data_scnptr, load_scnptr) (orig_load_scnptr, orig_data_scnptr): Now off_t, not long, since they are file offsets. (make_hdr): Use _data, not start_of_data (). This is the key part of the fix. (make_hdr, unrelocate_symbols): Use off_t for file offsets. (unrelocate_symbols): Cast pointers to intptr_t, not to ulong. Fixes: debbugs:13650
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/unexaix.c49
2 files changed, 31 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 95e58e2d92c..d798c933b6d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,19 @@
12013-02-12 Paul Eggert <eggert@cs.ucla.edu> 12013-02-12 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Improve AIX port some more (Bug#13650).
4 With this, it should be as good as it was in 23.3, though it's
5 still pretty bad: the dumped emacs does not run. See Mark Fleishman in
6 http://lists.gnu.org/archive/html/help-gnu-emacs/2011-04/msg00287.html
7 * unexaix.c (start_of_text): Remove.
8 (_data, _text): Declare as char[], not int, as AIX manual suggests.
9 (bias, lnnoptr, text_scnptr, data_scnptr, load_scnptr)
10 (orig_load_scnptr, orig_data_scnptr):
11 Now off_t, not long, since they are file offsets.
12 (make_hdr): Use _data, not start_of_data ().
13 This is the key part of the fix.
14 (make_hdr, unrelocate_symbols): Use off_t for file offsets.
15 (unrelocate_symbols): Cast pointers to intptr_t, not to ulong.
16
3 * pre-crt0.c (data_start): Initialize to 1. 17 * pre-crt0.c (data_start): Initialize to 1.
4 This ports to compilers that optimize the external declaration 18 This ports to compilers that optimize the external declaration
5 'int x = 0;' as if it were 'int x;' to shrink the executable. 19 'int x = 0;' as if it were 'int x;' to shrink the executable.
diff --git a/src/unexaix.c b/src/unexaix.c
index a3ffd509058..da44480fdca 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -61,10 +61,8 @@ what you give them. Help stamp out software-hoarding! */
61 61
62#include "mem-limits.h" 62#include "mem-limits.h"
63 63
64char *start_of_text (void); /* Start of text */ 64extern char _data[];
65 65extern char _text[];
66extern int _data;
67extern int _text;
68 66
69#include <filehdr.h> 67#include <filehdr.h>
70#include <aouthdr.h> 68#include <aouthdr.h>
@@ -73,15 +71,15 @@ extern int _text;
73 71
74static struct filehdr f_hdr; /* File header */ 72static struct filehdr f_hdr; /* File header */
75static struct aouthdr f_ohdr; /* Optional file header (a.out) */ 73static struct aouthdr f_ohdr; /* Optional file header (a.out) */
76static long bias; /* Bias to add for growth */ 74static off_t bias; /* Bias to add for growth */
77static long lnnoptr; /* Pointer to line-number info within file */ 75static off_t lnnoptr; /* Pointer to line-number info within file */
78 76
79static long text_scnptr; 77static off_t text_scnptr;
80static long data_scnptr; 78static off_t data_scnptr;
81#define ALIGN(val, pwr) (((val) + ((1L<<(pwr))-1)) & ~((1L<<(pwr))-1)) 79#define ALIGN(val, pwr) (((val) + ((1L<<(pwr))-1)) & ~((1L<<(pwr))-1))
82static long load_scnptr; 80static off_t load_scnptr;
83static long orig_load_scnptr; 81static off_t orig_load_scnptr;
84static long orig_data_scnptr; 82static off_t orig_data_scnptr;
85static int unrelocate_symbols (int, int, const char *, const char *); 83static int unrelocate_symbols (int, int, const char *, const char *);
86 84
87#ifndef MAX_SECTIONS 85#ifndef MAX_SECTIONS
@@ -188,7 +186,7 @@ make_hdr (int new, int a_out,
188 pagemask = getpagesize () - 1; 186 pagemask = getpagesize () - 1;
189 187
190 /* Adjust text/data boundary. */ 188 /* Adjust text/data boundary. */
191 data_start = (uintptr_t) start_of_data (); 189 data_start = (uintptr_t) _data;
192 190
193 data_start = data_start & ~pagemask; /* (Down) to page boundary. */ 191 data_start = data_start & ~pagemask; /* (Down) to page boundary. */
194 192
@@ -288,7 +286,7 @@ make_hdr (int new, int a_out,
288 286
289 /* fix scnptr's */ 287 /* fix scnptr's */
290 { 288 {
291 ulong ptr = section[0].s_scnptr; 289 off_t ptr = section[0].s_scnptr;
292 290
293 bias = -1; 291 bias = -1;
294 for (scns = 0; scns < f_hdr.f_nscns; scns++) 292 for (scns = 0; scns < f_hdr.f_nscns; scns++)
@@ -384,12 +382,12 @@ copy_text_and_data (int new)
384 char *end; 382 char *end;
385 char *ptr; 383 char *ptr;
386 384
387 lseek (new, (long) text_scnptr, SEEK_SET); 385 lseek (new, text_scnptr, SEEK_SET);
388 ptr = start_of_text () + text_scnptr; 386 ptr = _text + text_scnptr;
389 end = ptr + f_ohdr.tsize; 387 end = ptr + f_ohdr.tsize;
390 write_segment (new, ptr, end); 388 write_segment (new, ptr, end);
391 389
392 lseek (new, (long) data_scnptr, SEEK_SET); 390 lseek (new, data_scnptr, SEEK_SET);
393 ptr = (char *) f_ohdr.data_start; 391 ptr = (char *) f_ohdr.data_start;
394 end = ptr + f_ohdr.dsize; 392 end = ptr + f_ohdr.dsize;
395 write_segment (new, ptr, end); 393 write_segment (new, ptr, end);
@@ -549,13 +547,13 @@ unrelocate_symbols (int new, int a_out,
549 int i; 547 int i;
550 LDHDR ldhdr; 548 LDHDR ldhdr;
551 LDREL ldrel; 549 LDREL ldrel;
552 ulong t_reloc = (ulong) &_text - f_ohdr.text_start; 550 off_t t_reloc = (intptr_t) _text - f_ohdr.text_start;
553#ifndef ALIGN_DATA_RELOC 551#ifndef ALIGN_DATA_RELOC
554 ulong d_reloc = (ulong) &_data - f_ohdr.data_start; 552 off_t d_reloc = (intptr_t) _data - f_ohdr.data_start;
555#else 553#else
556 /* This worked (and was needed) before AIX 4.2. 554 /* This worked (and was needed) before AIX 4.2.
557 I have no idea why. -- Mike */ 555 I have no idea why. -- Mike */
558 ulong d_reloc = (ulong) &_data - ALIGN (f_ohdr.data_start, 2); 556 off_t d_reloc = (intptr_t) _data - ALIGN (f_ohdr.data_start, 2);
559#endif 557#endif
560 int * p; 558 int * p;
561 559
@@ -640,16 +638,3 @@ unrelocate_symbols (int new, int a_out,
640 } 638 }
641 return 0; 639 return 0;
642} 640}
643
644/*
645 * Return the address of the start of the text segment prior to
646 * doing an unexec. After unexec the return value is undefined.
647 * See crt0.c for further explanation and _start.
648 *
649 */
650
651char *
652start_of_text (void)
653{
654 return ((char *) 0x10000000);
655}