diff options
Diffstat (limited to 'src/unexelf.c')
| -rw-r--r-- | src/unexelf.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/unexelf.c b/src/unexelf.c index 1009c87066b..b58c78501b8 100644 --- a/src/unexelf.c +++ b/src/unexelf.c | |||
| @@ -386,6 +386,8 @@ temacs: | |||
| 386 | Instead we read the whole file, modify it, and write it out. */ | 386 | Instead we read the whole file, modify it, and write it out. */ |
| 387 | 387 | ||
| 388 | #include <config.h> | 388 | #include <config.h> |
| 389 | #include <unexec.h> | ||
| 390 | |||
| 389 | extern void fatal (const char *msgid, ...); | 391 | extern void fatal (const char *msgid, ...); |
| 390 | 392 | ||
| 391 | #include <sys/types.h> | 393 | #include <sys/types.h> |
| @@ -518,10 +520,6 @@ typedef struct { | |||
| 518 | # define ElfW(type) ElfExpandBitsW (ELFSIZE, type) | 520 | # define ElfW(type) ElfExpandBitsW (ELFSIZE, type) |
| 519 | #endif | 521 | #endif |
| 520 | 522 | ||
| 521 | #ifndef ELF_BSS_SECTION_NAME | ||
| 522 | #define ELF_BSS_SECTION_NAME ".bss" | ||
| 523 | #endif | ||
| 524 | |||
| 525 | /* Get the address of a particular section or program header entry, | 523 | /* Get the address of a particular section or program header entry, |
| 526 | * accounting for the size of the entries. | 524 | * accounting for the size of the entries. |
| 527 | */ | 525 | */ |
| @@ -553,8 +551,6 @@ typedef struct { | |||
| 553 | (*(ElfW(Shdr) *) ((byte *) old_section_h + old_file_h->e_shentsize * (n))) | 551 | (*(ElfW(Shdr) *) ((byte *) old_section_h + old_file_h->e_shentsize * (n))) |
| 554 | #define NEW_SECTION_H(n) \ | 552 | #define NEW_SECTION_H(n) \ |
| 555 | (*(ElfW(Shdr) *) ((byte *) new_section_h + new_file_h->e_shentsize * (n))) | 553 | (*(ElfW(Shdr) *) ((byte *) new_section_h + new_file_h->e_shentsize * (n))) |
| 556 | #define OLD_PROGRAM_H(n) \ | ||
| 557 | (*(ElfW(Phdr) *) ((byte *) old_program_h + old_file_h->e_phentsize * (n))) | ||
| 558 | #define NEW_PROGRAM_H(n) \ | 554 | #define NEW_PROGRAM_H(n) \ |
| 559 | (*(ElfW(Phdr) *) ((byte *) new_program_h + new_file_h->e_phentsize * (n))) | 555 | (*(ElfW(Phdr) *) ((byte *) new_program_h + new_file_h->e_phentsize * (n))) |
| 560 | 556 | ||
| @@ -623,6 +619,10 @@ unexec (const char *new_name, const char *old_name) | |||
| 623 | { | 619 | { |
| 624 | int new_file, old_file, new_file_size; | 620 | int new_file, old_file, new_file_size; |
| 625 | 621 | ||
| 622 | #if defined (emacs) || !defined (DEBUG) | ||
| 623 | void *new_break; | ||
| 624 | #endif | ||
| 625 | |||
| 626 | /* Pointers to the base of the image of the two files. */ | 626 | /* Pointers to the base of the image of the two files. */ |
| 627 | caddr_t old_base, new_base; | 627 | caddr_t old_base, new_base; |
| 628 | 628 | ||
| @@ -753,7 +753,8 @@ unexec (const char *new_name, const char *old_name) | |||
| 753 | old_name, old_file_h, old_section_h, 0); | 753 | old_name, old_file_h, old_section_h, 0); |
| 754 | 754 | ||
| 755 | #if defined (emacs) || !defined (DEBUG) | 755 | #if defined (emacs) || !defined (DEBUG) |
| 756 | new_bss_addr = (ElfW(Addr)) sbrk (0); | 756 | new_break = sbrk (0); |
| 757 | new_bss_addr = (ElfW(Addr)) new_break; | ||
| 757 | #else | 758 | #else |
| 758 | new_bss_addr = old_bss_addr + old_bss_size + 0x1234; | 759 | new_bss_addr = old_bss_addr + old_bss_size + 0x1234; |
| 759 | #endif | 760 | #endif |
| @@ -954,13 +955,13 @@ temacs: | |||
| 954 | Link Info Adralgn Entsize | 955 | Link Info Adralgn Entsize |
| 955 | 956 | ||
| 956 | [22] 1 3 0x335150 0x315150 0x4 .data.rel.local | 957 | [22] 1 3 0x335150 0x315150 0x4 .data.rel.local |
| 957 | 0 0 0x4 0 | 958 | 0 0 0x4 0 |
| 958 | 959 | ||
| 959 | [23] 8 3 0x335158 0x315158 0x42720 .bss | 960 | [23] 8 3 0x335158 0x315158 0x42720 .bss |
| 960 | 0 0 0x8 0 | 961 | 0 0 0x8 0 |
| 961 | 962 | ||
| 962 | [24] 2 0 0 0x315154 0x1c9d0 .symtab | 963 | [24] 2 0 0 0x315154 0x1c9d0 .symtab |
| 963 | 25 1709 0x4 0x10 | 964 | 25 1709 0x4 0x10 |
| 964 | */ | 965 | */ |
| 965 | 966 | ||
| 966 | if (NEW_SECTION_H (nn).sh_offset >= old_bss_offset | 967 | if (NEW_SECTION_H (nn).sh_offset >= old_bss_offset |
| @@ -1228,8 +1229,8 @@ temacs: | |||
| 1228 | ElfW(Shdr) section = NEW_SECTION_H (n); | 1229 | ElfW(Shdr) section = NEW_SECTION_H (n); |
| 1229 | 1230 | ||
| 1230 | /* Cause a compilation error if anyone uses n instead of nn below. */ | 1231 | /* Cause a compilation error if anyone uses n instead of nn below. */ |
| 1231 | struct {int a;} n; | 1232 | #define n ((void) 0); |
| 1232 | (void)n.a; /* Prevent `unused variable' warnings. */ | 1233 | n /* Prevent 'macro "n" is not used' warnings. */ |
| 1233 | 1234 | ||
| 1234 | switch (section.sh_type) | 1235 | switch (section.sh_type) |
| 1235 | { | 1236 | { |
| @@ -1276,6 +1277,8 @@ temacs: | |||
| 1276 | } | 1277 | } |
| 1277 | break; | 1278 | break; |
| 1278 | } | 1279 | } |
| 1280 | |||
| 1281 | #undef n | ||
| 1279 | } | 1282 | } |
| 1280 | 1283 | ||
| 1281 | /* Write out new_file, and free the buffers. */ | 1284 | /* Write out new_file, and free the buffers. */ |
| @@ -1307,4 +1310,3 @@ temacs: | |||
| 1307 | if (chmod (new_name, stat_buf.st_mode) == -1) | 1310 | if (chmod (new_name, stat_buf.st_mode) == -1) |
| 1308 | fatal ("Can't chmod (%s): errno %d\n", new_name, errno); | 1311 | fatal ("Can't chmod (%s): errno %d\n", new_name, errno); |
| 1309 | } | 1312 | } |
| 1310 | |||