2005-04-17 05:20:36 +07:00
|
|
|
#ifndef _LINUX_ELF_H
|
|
|
|
#define _LINUX_ELF_H
|
|
|
|
|
|
|
|
#include <asm/elf.h>
|
2012-10-13 16:46:48 +07:00
|
|
|
#include <uapi/linux/elf.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-12-12 20:54:36 +07:00
|
|
|
#ifndef elf_read_implies_exec
|
|
|
|
/* Executables for which elf_read_implies_exec() returns TRUE will
|
|
|
|
have the READ_IMPLIES_EXEC personality flag set automatically.
|
|
|
|
Override in asm/elf.h as needed. */
|
|
|
|
# define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
|
|
|
|
#endif
|
2013-02-18 05:47:04 +07:00
|
|
|
#ifndef SET_PERSONALITY
|
|
|
|
#define SET_PERSONALITY(ex) \
|
|
|
|
set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
|
|
|
|
#endif
|
2011-12-12 20:54:36 +07:00
|
|
|
|
binfmt_elf: allow arch code to examine PT_LOPROC ... PT_HIPROC headers
MIPS is introducing new variants of its O32 ABI which differ in their
handling of floating point, in order to enable a gradual transition
towards a world where mips32 binaries can take advantage of new hardware
features only available when configured for certain FP modes. In order
to do this ELF binaries are being augmented with a new section that
indicates, amongst other things, the FP mode requirements of the binary.
The presence & location of such a section is indicated by a program
header in the PT_LOPROC ... PT_HIPROC range.
In order to allow the MIPS architecture code to examine the program
header & section in question, pass all program headers in this range
to an architecture-specific arch_elf_pt_proc function. This function
may return an error if the header is deemed invalid or unsuitable for
the system, in which case that error will be returned from
load_elf_binary and upwards through the execve syscall.
A means is required for the architecture code to make a decision once
it is known that all such headers have been seen, but before it is too
late to return from an execve syscall. For this purpose the
arch_check_elf function is added, and called once, after all PT_LOPROC
to PT_HIPROC headers have been passed to arch_elf_pt_proc but before
the code which invoked execve has been lost. This enables the
architecture code to make a decision based upon all the headers present
in an ELF binary and its interpreter, as is required to forbid
conflicting FP ABI requirements between an ELF & its interpreter.
In order to allow data to be stored throughout the calls to the above
functions, struct arch_elf_state is introduced.
Finally a variant of the SET_PERSONALITY macro is introduced which
accepts a pointer to the struct arch_elf_state, allowing it to act
based upon state observed from the architecture specific program
headers.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/7679/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2014-09-11 14:30:16 +07:00
|
|
|
#ifndef SET_PERSONALITY2
|
|
|
|
#define SET_PERSONALITY2(ex, state) \
|
|
|
|
SET_PERSONALITY(ex)
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#if ELF_CLASS == ELFCLASS32
|
|
|
|
|
|
|
|
extern Elf32_Dyn _DYNAMIC [];
|
|
|
|
#define elfhdr elf32_hdr
|
|
|
|
#define elf_phdr elf32_phdr
|
2010-03-06 04:44:10 +07:00
|
|
|
#define elf_shdr elf32_shdr
|
2005-04-17 05:20:36 +07:00
|
|
|
#define elf_note elf32_note
|
2006-12-07 11:37:53 +07:00
|
|
|
#define elf_addr_t Elf32_Off
|
2010-03-06 04:44:07 +07:00
|
|
|
#define Elf_Half Elf32_Half
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
extern Elf64_Dyn _DYNAMIC [];
|
|
|
|
#define elfhdr elf64_hdr
|
|
|
|
#define elf_phdr elf64_phdr
|
2010-03-06 04:44:10 +07:00
|
|
|
#define elf_shdr elf64_shdr
|
2005-04-17 05:20:36 +07:00
|
|
|
#define elf_note elf64_note
|
2006-12-07 11:37:53 +07:00
|
|
|
#define elf_addr_t Elf64_Off
|
2010-03-06 04:44:07 +07:00
|
|
|
#define Elf_Half Elf64_Half
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
[POWERPC] spufs: Cleanup ELF coredump extra notes logic
To start with, arch_notes_size() etc. is a little too ambiguous a name for
my liking, so change the function names to be more explicit.
Calling through macros is ugly, especially with hidden parameters, so don't
do that, call the routines directly.
Use ARCH_HAVE_EXTRA_ELF_NOTES as the only flag, and based on it decide
whether we want the extern declarations or the empty versions.
Since we have empty routines, actually use them in the coredump code to
save a few #ifdefs.
We want to change the handling of foffset so that the write routine updates
foffset as it goes, instead of using file->f_pos (so that writing to a pipe
works). So pass foffset to the write routine, and for now just set it to
file->f_pos at the end of writing.
It should also be possible for the write routine to fail, so change it to
return int and treat a non-zero return as failure.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-09-19 11:38:12 +07:00
|
|
|
/* Optional callbacks to write extra ELF notes. */
|
2011-12-12 20:54:36 +07:00
|
|
|
struct file;
|
2013-10-06 09:24:29 +07:00
|
|
|
struct coredump_params;
|
2011-12-12 20:54:36 +07:00
|
|
|
|
[POWERPC] coredump: Add SPU elf notes to coredump.
This patch adds SPU elf notes to the coredump. It creates a separate note
for each of /regs, /fpcr, /lslr, /decr, /decr_status, /mem, /signal1,
/signal1_type, /signal2, /signal2_type, /event_mask, /event_status,
/mbox_info, /ibox_info, /wbox_info, /dma_info, /proxydma_info, /object-id.
A new macro, ARCH_HAVE_EXTRA_NOTES, was created for architectures to
specify they have extra elf core notes.
A new macro, ELF_CORE_EXTRA_NOTES_SIZE, was created so the size of the
additional notes could be calculated and added to the notes phdr entry.
A new macro, ELF_CORE_WRITE_EXTRA_NOTES, was created so the new notes
would be written after the existing notes.
The SPU coredump code resides in spufs. Stub functions are provided in the
kernel which are hooked into the spufs code which does the actual work via
register_arch_coredump_calls().
A new set of __spufs_<file>_read/get() functions was provided to allow the
coredump code to read from the spufs files without having to lock the
SPU context for each file read from.
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Dwayne Grant McConnell <decimal@us.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
2006-11-23 06:46:37 +07:00
|
|
|
#ifndef ARCH_HAVE_EXTRA_ELF_NOTES
|
[POWERPC] spufs: Cleanup ELF coredump extra notes logic
To start with, arch_notes_size() etc. is a little too ambiguous a name for
my liking, so change the function names to be more explicit.
Calling through macros is ugly, especially with hidden parameters, so don't
do that, call the routines directly.
Use ARCH_HAVE_EXTRA_ELF_NOTES as the only flag, and based on it decide
whether we want the extern declarations or the empty versions.
Since we have empty routines, actually use them in the coredump code to
save a few #ifdefs.
We want to change the handling of foffset so that the write routine updates
foffset as it goes, instead of using file->f_pos (so that writing to a pipe
works). So pass foffset to the write routine, and for now just set it to
file->f_pos at the end of writing.
It should also be possible for the write routine to fail, so change it to
return int and treat a non-zero return as failure.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-09-19 11:38:12 +07:00
|
|
|
static inline int elf_coredump_extra_notes_size(void) { return 0; }
|
2013-10-06 09:24:29 +07:00
|
|
|
static inline int elf_coredump_extra_notes_write(struct coredump_params *cprm) { return 0; }
|
[POWERPC] spufs: Cleanup ELF coredump extra notes logic
To start with, arch_notes_size() etc. is a little too ambiguous a name for
my liking, so change the function names to be more explicit.
Calling through macros is ugly, especially with hidden parameters, so don't
do that, call the routines directly.
Use ARCH_HAVE_EXTRA_ELF_NOTES as the only flag, and based on it decide
whether we want the extern declarations or the empty versions.
Since we have empty routines, actually use them in the coredump code to
save a few #ifdefs.
We want to change the handling of foffset so that the write routine updates
foffset as it goes, instead of using file->f_pos (so that writing to a pipe
works). So pass foffset to the write routine, and for now just set it to
file->f_pos at the end of writing.
It should also be possible for the write routine to fail, so change it to
return int and treat a non-zero return as failure.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-09-19 11:38:12 +07:00
|
|
|
#else
|
|
|
|
extern int elf_coredump_extra_notes_size(void);
|
2013-10-06 09:24:29 +07:00
|
|
|
extern int elf_coredump_extra_notes_write(struct coredump_params *cprm);
|
[POWERPC] spufs: Cleanup ELF coredump extra notes logic
To start with, arch_notes_size() etc. is a little too ambiguous a name for
my liking, so change the function names to be more explicit.
Calling through macros is ugly, especially with hidden parameters, so don't
do that, call the routines directly.
Use ARCH_HAVE_EXTRA_ELF_NOTES as the only flag, and based on it decide
whether we want the extern declarations or the empty versions.
Since we have empty routines, actually use them in the coredump code to
save a few #ifdefs.
We want to change the handling of foffset so that the write routine updates
foffset as it goes, instead of using file->f_pos (so that writing to a pipe
works). So pass foffset to the write routine, and for now just set it to
file->f_pos at the end of writing.
It should also be possible for the write routine to fail, so change it to
return int and treat a non-zero return as failure.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2007-09-19 11:38:12 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif /* _LINUX_ELF_H */
|