]> code.delx.au - gnu-emacs/blobdiff - src/unexelf.c
(XTmouse_position, x_term_init):
[gnu-emacs] / src / unexelf.c
index 1575b23b51d14045e07a7da0e42bdfc3ce353b05..a832755167e8259ecb498868719704dec7ee87ef 100644 (file)
@@ -427,8 +427,8 @@ Filesz      Memsz       Flags       Align
 # include <sym.h>      /* get COFF debugging symbol table declaration */
 #endif
 
-#ifdef __GNU_LIBRARY__
-# include <link.h>     /* get definition of ElfW */
+#if __GNU_LIBRARY__ - 0 >= 6
+# include <link.h>     /* get ElfW etc */
 #endif
 
 #ifndef ElfW
@@ -534,11 +534,11 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
   char *old_section_names;
 
   ElfW(Addr) old_bss_addr, new_bss_addr;
-  ElfW(Addr) old_bss_size, new_data2_size;
+  ElfW(Word) old_bss_size, new_data2_size;
   ElfW(Off)  new_data2_offset;
   ElfW(Addr) new_data2_addr;
 
-  int n, nn, old_bss_index, old_data_index;
+  int n, nn, old_bss_index, old_data_index, new_data2_index;
   struct stat stat_buf;
 
   /* Open the old file & map it into the address space. */
@@ -557,8 +557,8 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
     fatal ("Can't mmap (%s): errno %d\n", old_name, errno);
 
 #ifdef DEBUG
-  fprintf (stderr, "mmap (%s, %lx) -> %lx\n", old_name, stat_buf.st_size,
-          (unsigned long) old_base);
+  fprintf (stderr, "mmap (%s, %x) -> %x\n", old_name, stat_buf.st_size,
+          old_base);
 #endif
 
   /* Get pointers to headers & section names */
@@ -600,16 +600,15 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
 
 #ifdef DEBUG
   fprintf (stderr, "old_bss_index %d\n", old_bss_index);
-  fprintf (stderr, "old_bss_addr %lx\n", old_bss_addr);
-  fprintf (stderr, "old_bss_size %lx\n", old_bss_size);
-  fprintf (stderr, "new_bss_addr %lx\n", new_bss_addr);
-  fprintf (stderr, "new_data2_addr %lx\n", new_data2_addr);
-  fprintf (stderr, "new_data2_size %lx\n", new_data2_size);
-  fprintf (stderr, "new_data2_offset %lx\n", new_data2_offset);
+  fprintf (stderr, "old_bss_addr %x\n", old_bss_addr);
+  fprintf (stderr, "old_bss_size %x\n", old_bss_size);
+  fprintf (stderr, "new_bss_addr %x\n", new_bss_addr);
+  fprintf (stderr, "new_data2_addr %x\n", new_data2_addr);
+  fprintf (stderr, "new_data2_size %x\n", new_data2_size);
+  fprintf (stderr, "new_data2_offset %x\n", new_data2_offset);
 #endif
 
-  if ((unsigned long) new_bss_addr
-      < (unsigned long) old_bss_addr + old_bss_size)
+  if ((unsigned) new_bss_addr < (unsigned) old_bss_addr + old_bss_size)
     fatal (".bss shrank when undumping???\n", 0, 0);
 
   /* Set the output file to the right size and mmap it.  Set
@@ -661,9 +660,9 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
   new_file_h->e_shnum += 1;
 
 #ifdef DEBUG
-  fprintf (stderr, "Old section offset %lx\n", old_file_h->e_shoff);
+  fprintf (stderr, "Old section offset %x\n", old_file_h->e_shoff);
   fprintf (stderr, "Old section count %d\n", old_file_h->e_shnum);
-  fprintf (stderr, "New section offset %lx\n", new_file_h->e_shoff);
+  fprintf (stderr, "New section offset %x\n", new_file_h->e_shoff);
   fprintf (stderr, "New section count %d\n", new_file_h->e_shnum);
 #endif
 
@@ -678,7 +677,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
   for (n = new_file_h->e_phnum - 1; n >= 0; n--)
     {
       /* Compute maximum of all requirements for alignment of section.  */
-      unsigned int alignment = (NEW_PROGRAM_H (n)).p_align;
+      int alignment = (NEW_PROGRAM_H (n)).p_align;
       if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment)
        alignment = OLD_SECTION_H (old_bss_index).sh_addralign;
 
@@ -911,7 +910,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
            for (end = reloc + section.sh_size; reloc < end;
                 reloc += section.sh_entsize)
              {
-               ElfW(Addr) addr;
+               ElfW(Addr) addr = ((ElfW(Rel) *) reloc)->r_offset - offset;
 #ifdef __alpha__
                /* The Alpha ELF binutils currently have a bug that
                   sometimes results in relocs that contain all
@@ -919,7 +918,6 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
                if (((ElfW(Rel) *) reloc)->r_offset == 0)
                    continue;
 #endif
-               addr = ((ElfW(Rel) *) reloc)->r_offset - offset;
                memcpy (new_base + addr, old_base + addr, sizeof(ElfW(Addr)));
              }
          }