diff options
Diffstat (limited to 'src/unexelf.c')
-rw-r--r-- | src/unexelf.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/unexelf.c b/src/unexelf.c index 1cdcfeb44e4..e61bdd4e880 100644 --- a/src/unexelf.c +++ b/src/unexelf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1985-1988, 1990, 1992, 1999-2017 Free Software +/* Copyright (C) 1985-1988, 1990, 1992, 1999-2022 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -58,9 +58,11 @@ what you give them. Help stamp out software-hoarding! */ #include <sys/types.h> #include <unistd.h> -#if !defined (__NetBSD__) && !defined (__OpenBSD__) -#include <elf.h> -#endif /* not __NetBSD__ and not __OpenBSD__ */ +#ifdef __QNX__ +# include <sys/elf.h> +#elif !defined __NetBSD__ && !defined __OpenBSD__ +# include <elf.h> +#endif #include <sys/mman.h> #if defined (_SYSTYPE_SYSV) #include <sys/elf_mips.h> @@ -185,7 +187,8 @@ verify ((! TYPE_SIGNED (ElfW (Half)) && TYPE_MAXIMUM (ElfW (Half)) <= PTRDIFF_MAX); #ifdef UNEXELF_DEBUG -# define DEBUG_LOG(expr) fprintf (stderr, #expr " 0x%jx\n", (uintmax_t) (expr)) +# define DEBUG_LOG(expr) fprintf (stderr, #expr " 0x%"PRIxMAX"\n", \ + (uintmax_t) (expr)) #endif /* Get the address of a particular section or program header entry, @@ -222,7 +225,6 @@ unexec (const char *new_name, const char *old_name) { int new_file, old_file; off_t new_file_size; - void *new_break; /* Pointers to the base of the image of the two files. */ caddr_t old_base, new_base; @@ -303,6 +305,7 @@ unexec (const char *new_name, const char *old_name) || seg->p_vaddr > old_bss_seg->p_vaddr)) old_bss_seg = seg; } + eassume (old_bss_seg); /* Note that old_bss_addr may be lower than the first bss section address, since the section may need aligning. */ @@ -326,11 +329,13 @@ unexec (const char *new_name, const char *old_name) if (old_bss_index == -1) fatal ("no bss section found"); + void *no_break = (void *) (intptr_t) -1; + void *new_break = no_break; #ifdef HAVE_SBRK new_break = sbrk (0); -#else - new_break = (byte *) old_bss_addr + old_bss_size; #endif + if (new_break == no_break) + new_break = (byte *) old_bss_addr + old_bss_size; new_bss_addr = (ElfW (Addr)) new_break; bss_size_growth = new_bss_addr - old_bss_addr; new_data2_size = bss_size_growth; |