Mercurial > emacs
comparison src/unexelf.c @ 90260:0ca0d9181b5e
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-95
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 598-615)
- Update from CVS
- Remove lisp/toolbar directory
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 142-146)
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 16 Jan 2006 06:59:21 +0000 |
parents | aa89c814f853 6bc455208c59 |
children | 7beb78bc1f8e |
comparison
equal
deleted
inserted
replaced
90259:a3ba65547f84 | 90260:0ca0d9181b5e |
---|---|
700 fatal ("Can't fstat (%s): errno %d\n", old_name, errno); | 700 fatal ("Can't fstat (%s): errno %d\n", old_name, errno); |
701 | 701 |
702 #if MAP_ANON == 0 | 702 #if MAP_ANON == 0 |
703 mmap_fd = open ("/dev/zero", O_RDONLY); | 703 mmap_fd = open ("/dev/zero", O_RDONLY); |
704 if (mmap_fd < 0) | 704 if (mmap_fd < 0) |
705 fatal ("Can't open /dev/zero for reading: errno %d\n", errno); | 705 fatal ("Can't open /dev/zero for reading: errno %d\n", errno, 0); |
706 #endif | 706 #endif |
707 | 707 |
708 /* We cannot use malloc here because that may use sbrk. If it does, | 708 /* We cannot use malloc here because that may use sbrk. If it does, |
709 we'd dump our temporary buffers with Emacs, and we'd have to be | 709 we'd dump our temporary buffers with Emacs, and we'd have to be |
710 extra careful to use the correct value of sbrk(0) after | 710 extra careful to use the correct value of sbrk(0) after |
711 allocating all buffers in the code below, which we aren't. */ | 711 allocating all buffers in the code below, which we aren't. */ |
712 old_file_size = stat_buf.st_size; | 712 old_file_size = stat_buf.st_size; |
713 old_base = mmap (NULL, old_file_size, PROT_READ | PROT_WRITE, | 713 old_base = mmap (NULL, old_file_size, PROT_READ | PROT_WRITE, |
714 MAP_ANON | MAP_PRIVATE, mmap_fd, 0); | 714 MAP_ANON | MAP_PRIVATE, mmap_fd, 0); |
715 if (old_base == MAP_FAILED) | 715 if (old_base == MAP_FAILED) |
716 fatal ("Can't allocate buffer for %s\n", old_name); | 716 fatal ("Can't allocate buffer for %s\n", old_name, 0); |
717 | 717 |
718 if (read (old_file, old_base, stat_buf.st_size) != stat_buf.st_size) | 718 if (read (old_file, old_base, stat_buf.st_size) != stat_buf.st_size) |
719 fatal ("Didn't read all of %s: errno %d\n", old_name, errno); | 719 fatal ("Didn't read all of %s: errno %d\n", old_name, errno); |
720 | 720 |
721 /* Get pointers to headers & section names */ | 721 /* Get pointers to headers & section names */ |
800 fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno); | 800 fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno); |
801 | 801 |
802 new_base = mmap (NULL, new_file_size, PROT_READ | PROT_WRITE, | 802 new_base = mmap (NULL, new_file_size, PROT_READ | PROT_WRITE, |
803 MAP_ANON | MAP_PRIVATE, mmap_fd, 0); | 803 MAP_ANON | MAP_PRIVATE, mmap_fd, 0); |
804 if (new_base == MAP_FAILED) | 804 if (new_base == MAP_FAILED) |
805 fatal ("Can't allocate buffer for %s\n", old_name); | 805 fatal ("Can't allocate buffer for %s\n", old_name, 0); |
806 | 806 |
807 new_file_h = (ElfW(Ehdr) *) new_base; | 807 new_file_h = (ElfW(Ehdr) *) new_base; |
808 new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff); | 808 new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff); |
809 new_section_h = (ElfW(Shdr) *) | 809 new_section_h = (ElfW(Shdr) *) |
810 ((byte *) new_base + old_file_h->e_shoff + new_data2_size); | 810 ((byte *) new_base + old_file_h->e_shoff + new_data2_size); |
1077 #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | 1077 #if defined (__sony_news) && defined (_SYSTYPE_SYSV) |
1078 if (NEW_SECTION_H (nn).sh_type == SHT_MIPS_DEBUG | 1078 if (NEW_SECTION_H (nn).sh_type == SHT_MIPS_DEBUG |
1079 && old_mdebug_index != -1) | 1079 && old_mdebug_index != -1) |
1080 { | 1080 { |
1081 int diff = NEW_SECTION_H(nn).sh_offset | 1081 int diff = NEW_SECTION_H(nn).sh_offset |
1082 - OLD_SECTION_H(old_mdebug_index).sh_offset; | 1082 - OLD_SECTION_H(old_mdebug_index).sh_offset; |
1083 HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base); | 1083 HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base); |
1084 | 1084 |
1085 if (diff) | 1085 if (diff) |
1086 { | 1086 { |
1087 phdr->cbLineOffset += diff; | 1087 phdr->cbLineOffset += diff; |
1255 } | 1255 } |
1256 | 1256 |
1257 /* Write out new_file, and free the buffers. */ | 1257 /* Write out new_file, and free the buffers. */ |
1258 | 1258 |
1259 if (write (new_file, new_base, new_file_size) != new_file_size) | 1259 if (write (new_file, new_base, new_file_size) != new_file_size) |
1260 #ifndef emacs | |
1261 fatal ("Didn't write %d bytes: errno %d\n", | |
1262 new_file_size, errno); | |
1263 #else | |
1260 fatal ("Didn't write %d bytes to %s: errno %d\n", | 1264 fatal ("Didn't write %d bytes to %s: errno %d\n", |
1261 new_file_size, new_base, errno); | 1265 new_file_size, new_base, errno); |
1262 | 1266 #endif |
1263 munmap (old_base, old_file_size); | 1267 munmap (old_base, old_file_size); |
1264 munmap (new_base, new_file_size); | 1268 munmap (new_base, new_file_size); |
1265 | 1269 |
1266 /* Close the files and make the new file executable. */ | 1270 /* Close the files and make the new file executable. */ |
1267 | 1271 |