This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
#ifndef emacs
#define PERROR(arg) perror (arg); return -1
#else
-#include "config.h"
+#include <config.h>
#define PERROR(file) report_error (file, new)
#endif
-#ifndef CANNOT_DUMP /* all rest of file! */
-
-#ifndef CANNOT_UNEXEC /* most of rest of file */
-
#include <a.out.h>
/* Define getpagesize () if the system does not.
Note that this may depend on symbols defined in a.out.h
#endif
#ifdef emacs
+#include "lisp.h"
static
report_error (file, fd)
{
if (fd)
close (fd);
- error ("Failure operating on %s", file);
+ report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
}
#endif /* emacs */
#define CHECK_SCNHDR(ptr, name, flags) \
if (strcmp(s->s_name, name) == 0) { \
if (s->s_flags != flags) { \
- fprintf(stderr, "unexec: %x flags where %x expected in %s section.\n", \
- s->s_flags, flags, name); \
+ fprintf(stderr, "unexec: %lx flags where %x expected in %s section.\n", \
+ (unsigned long)s->s_flags, flags, name); \
} \
if (ptr) { \
fprintf(stderr, "unexec: duplicate section header for section %s.\n", \
else if (nwrite != ret)
{
sprintf (buf,
- "unexec write failure: addr 0x%x, fileno %d, size 0x%x, wrote 0x%x, errno %d",
- ptr, new, nwrite, ret, errno);
+ "unexec write failure: addr 0x%lx, fileno %d, size 0x%x, wrote 0x%x, errno %d",
+ (unsigned long)ptr, new, nwrite, ret, errno);
PERROR (buf);
}
i += nwrite;
char *new_name;
{
register int nsyms;
+ register int naux;
register int new;
#ifdef amdahl_uts
SYMENT symentry;
for (nsyms = 0; nsyms < f_hdr.f_nsyms; nsyms++)
{
read (new, &symentry, SYMESZ);
- if (symentry.n_numaux)
+ for (naux = 0; naux < symentry.n_numaux; naux++)
{
read (new, &auxentry, AUXESZ);
nsyms++;
{
int orig_int;
+#ifdef AIX4_1
+ lseek (a_out, orig_data_scnptr + (ldrel->l_vaddr - d_start), 0);
+#else
lseek (a_out, orig_data_scnptr + ldrel->l_vaddr, 0);
+#endif
if (read (a_out, (void *) &orig_int, sizeof (orig_int)) != sizeof (orig_int))
{
switch (ldrel->l_symndx) {
case SYMNDX_TEXT:
+#ifdef AIX4_1
+ p = (int *) (ldrel->l_vaddr);
+ orig_int = * p;
+#else
p = (int *) (d_start + ldrel->l_vaddr);
orig_int = * p - (t_start - f_ohdr.text_start);
+#endif
break;
case SYMNDX_DATA:
case SYMNDX_BSS:
+#ifdef AIX4_1
+ p = (int *) (ldrel->l_vaddr);
+ orig_int = * p;
+#else
p = (int *) (d_start + ldrel->l_vaddr);
orig_int = * p - (d_start - f_ohdr.data_start);
+#endif
break;
}
+#ifdef AIX4_1
+ lseek (new, data_scnptr + (ldrel->l_vaddr - d_start), 0);
+#else
lseek (new, data_scnptr + ldrel->l_vaddr, 0);
+#endif
if (write (new, (void *) &orig_int, sizeof (orig_int)) != sizeof (orig_int))
{
PERROR (new_name);
}
}
#endif /* XCOFF */
-
-#endif /* not CANNOT_UNEXEC */
-
-#endif /* not CANNOT_DUMP */