/* Dump an executable image.
- Copyright (C) 1985-1988, 1999, 2001-2011 Free Software Foundation, Inc.
+ Copyright (C) 1985-1988, 1999, 2001-2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <unistd.h>
#include <fcntl.h>
+#include "mem-limits.h"
+
char *start_of_text (void); /* Start of text */
-extern char *start_of_data (void); /* Start of initialized data */
extern int _data;
extern int _text;
static long load_scnptr;
static long orig_load_scnptr;
static long orig_data_scnptr;
-static int unrelocate_symbols (int, int, char *, char *);
+static int unrelocate_symbols (int, int, const char *, const char *);
#ifndef MAX_SECTIONS
#define MAX_SECTIONS 10
#endif
-static int adjust_lnnoptrs (int, int, char *);
+static int adjust_lnnoptrs (int, int, const char *);
static int pagemask;
-#include <setjmp.h>
#include "lisp.h"
static void
-report_error (char *file, int fd)
+report_error (const char *file, int fd)
{
if (fd)
close (fd);
#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1
static void
-report_error_1 (int fd, char *msg, int a1, int a2)
+report_error_1 (int fd, const char *msg, int a1, int a2)
{
close (fd);
error (msg, a1, a2);
}
-static int make_hdr (int, int, unsigned, unsigned, unsigned, char *, char *);
-static void mark_x (char *);
+static int make_hdr (int, int, const char *, const char *);
+static void mark_x (const char *);
static int copy_text_and_data (int);
-static int copy_sym (int, int, char *, char *);
+static int copy_sym (int, int, const char *, const char *);
static void write_segment (int, char *, char *);
\f
/* ****************************************************************
*/
static int
make_hdr (int new, int a_out,
- char *a_name, char *new_name)
+ const char *a_name, const char *new_name)
{
int scns;
unsigned int bss_start;
}
#define CHECK_SCNHDR(ptr, name, flags) \
- if (strcmp(s->s_name, name) == 0) { \
+ if (strcmp (s->s_name, name) == 0) { \
if (s->s_flags != flags) { \
- fprintf(stderr, "unexec: %lx flags where %x expected in %s section.\n", \
- (unsigned long)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", \
- name); \
+ fprintf (stderr, "unexec: duplicate section header for section %s.\n", \
+ name); \
} \
ptr = s; \
}
- CHECK_SCNHDR(f_thdr, _TEXT, STYP_TEXT);
- CHECK_SCNHDR(f_dhdr, _DATA, STYP_DATA);
- CHECK_SCNHDR(f_bhdr, _BSS, STYP_BSS);
- CHECK_SCNHDR(f_lhdr, _LOADER, STYP_LOADER);
- CHECK_SCNHDR(f_dbhdr, _DEBUG, STYP_DEBUG);
- CHECK_SCNHDR(f_tchdr, _TYPCHK, STYP_TYPCHK);
- CHECK_SCNHDR(f_xhdr, _EXCEPT, STYP_EXCEPT);
+ CHECK_SCNHDR (f_thdr, _TEXT, STYP_TEXT);
+ CHECK_SCNHDR (f_dhdr, _DATA, STYP_DATA);
+ CHECK_SCNHDR (f_bhdr, _BSS, STYP_BSS);
+ CHECK_SCNHDR (f_lhdr, _LOADER, STYP_LOADER);
+ CHECK_SCNHDR (f_dbhdr, _DEBUG, STYP_DEBUG);
+ CHECK_SCNHDR (f_tchdr, _TYPCHK, STYP_TYPCHK);
+ CHECK_SCNHDR (f_xhdr, _EXCEPT, STYP_EXCEPT);
}
if (f_thdr == 0)
* Copy the relocation information and symbol table from the a.out to the new
*/
static int
-copy_sym (int new, int a_out, char *a_name, char *new_name)
+copy_sym (int new, int a_out, const char *a_name, const char *new_name)
{
char page[UnexBlockSz];
int n;
* After successfully building the new a.out, mark it executable
*/
static void
-mark_x (char *name)
+mark_x (const char *name)
{
struct stat sbuf;
int um;
}
\f
static int
-adjust_lnnoptrs (int writedesc, int readdesc, char *new_name)
+adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
{
int nsyms;
int naux;
}
static int
-unrelocate_symbols (int new, int a_out, char *a_name, char *new_name)
+unrelocate_symbols (int new, int a_out,
+ const char *a_name, const char *new_name)
{
int i;
LDHDR ldhdr;
#else
/* This worked (and was needed) before AIX 4.2.
I have no idea why. -- Mike */
- ulong d_reloc = (ulong) &_data - ALIGN(f_ohdr.data_start, 2);
+ ulong d_reloc = (ulong) &_data - ALIGN (f_ohdr.data_start, 2);
#endif
int * p;