diff options
Diffstat (limited to 'backends')
| -rw-r--r-- | backends/ChangeLog | 46 | ||||
| -rw-r--r-- | backends/Makefile.am | 16 | ||||
| -rw-r--r-- | backends/aarch64_init.c | 3 | ||||
| -rw-r--r-- | backends/aarch64_symbol.c | 14 | ||||
| -rw-r--r-- | backends/arm_init.c | 3 | ||||
| -rw-r--r-- | backends/arm_symbol.c | 15 | ||||
| -rw-r--r-- | backends/bpf_init.c | 2 | ||||
| -rw-r--r-- | backends/bpf_regs.c | 6 | ||||
| -rw-r--r-- | backends/ppc64_init.c | 1 | ||||
| -rw-r--r-- | backends/ppc64_unwind.c | 76 | ||||
| -rw-r--r-- | backends/ppc_corenote.c | 13 | ||||
| -rw-r--r-- | backends/ppc_init.c | 1 | ||||
| -rw-r--r-- | backends/ppc_regs.c | 10 | ||||
| -rw-r--r-- | backends/ppc_symbol.c | 10 | ||||
| -rw-r--r-- | backends/s390_initreg.c | 2 | ||||
| -rw-r--r-- | backends/sparc_reloc.def | 6 |
16 files changed, 197 insertions, 27 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog index 1ac5bab3..a66e923e 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,49 @@ +2017-07-27 Mark Wielaard <[email protected]> + + * sparc_reloc.def: GOTDATA_OP_HIX22, GOTDATA_OP_LOX10 and + GOTDATA_OP can be used in ET_REL files. + +2017-07-19 Gustavo Romero <[email protected]> + + * ppc_corenote.c: Add offsets for ppc64 HTM SPRs: thfar, tfiar, + and texasr. + * ppc_regs.c: Add names for ppc64 HTM SPRs mappings. + +2017-07-20 Mark Wielaard <[email protected]> + + * aarch64_init.c (aarch64_init): Hook data_marker_symbol. + * aarch64_symbol.c (aarch64_data_marker_symbol): New function. + * arm_init.c (arm_init): Hook data_marker_symbol. + * arm_symbol.c (aarch64_data_marker_symbol): New function. + +2017-07-18 Mark Wielaard <[email protected]> + + * Makefile.am (cpu_bpf): Always define. + * bpf_init.c (disasm): Always hook. + * bpf_regs.c: Include bpf.h instead of linux/bpf.h. Don't define + MAX_BPF_REG. + +2017-02-17 Ulf Hermann <[email protected]> + + * Makefile.am: Add libeu. + (libebl_%so): Link with --no-undefined,-z,defs,-z,relro + and libeu.a. + +2017-06-17 Mark Wielaard <[email protected]> + + * s390_initreg.c: Swap sys/ptrace.h and asm/ptrace.h include order. + +2017-06-15 Andreas Schwab <[email protected]> + + * ppc_symbol.c (ppc_machine_flag_check): New function. + * ppc_init.c (ppc_init): Hook it. + +2017-05-30 Mark Wielaard <[email protected]> + + * ppc64_unwind.c: New file. + * ppc64_init.c (pcc64_init): Hook unwind. + * Makefile.am (ppc64_SRCS): Add ppc64_unwind.c + 2017-04-06 Mark Wielaard <[email protected]> * i386_unwind.c: New file. diff --git a/backends/Makefile.am b/backends/Makefile.am index 96004dcc..03b9d201 100644 --- a/backends/Makefile.am +++ b/backends/Makefile.am @@ -46,6 +46,7 @@ lib_LIBRARIES = libebl_static_pic.a libelf = ../libelf/libelf.so libdw = ../libdw/libdw.so +libeu = ../lib/libeu.a # The following is minimal set of backends that we link with libdw to # avoid dlopen. Note repeats files below because some backends reuse @@ -64,7 +65,7 @@ static_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ ppc_corenote.c ppc_auxv.c ppc_attrs.c ppc_syscall.c \ ppc_cfi.c ppc_initreg.c \ ppc64_init.c ppc64_symbol.c ppc64_retval.c ppc64_corenote.c \ - ppc64_resolve_sym.c \ + ppc64_resolve_sym.c ppc64_unwind.c \ s390_init.c s390_symbol.c s390_regs.c s390_retval.c \ s390_corenote.c s390x_corenote.c s390_cfi.c s390_initreg.c \ s390_unwind.c bpf_init.c bpf_regs.c @@ -124,7 +125,7 @@ am_libebl_ppc_pic_a_OBJECTS = $(ppc_SRCS:.c=.os) ppc64_SRCS = ppc64_init.c ppc64_symbol.c ppc64_retval.c \ ppc64_corenote.c ppc_regs.c ppc_auxv.c ppc_attrs.c ppc_syscall.c \ - ppc_cfi.c ppc_initreg.c ppc64_resolve_sym.c + ppc_cfi.c ppc_initreg.c ppc64_unwind.c ppc64_resolve_sym.c libebl_ppc64_pic_a_SOURCES = $(ppc64_SRCS) am_libebl_ppc64_pic_a_OBJECTS = $(ppc64_SRCS:.c=.os) @@ -145,24 +146,19 @@ libebl_m68k_pic_a_SOURCES = $(m68k_SRCS) am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os) bpf_SRCS = bpf_init.c bpf_regs.c -# The disam hook depends on this if we have linux/bpf.h. -if HAVE_LINUX_BPF_H cpu_bpf = ../libcpu/libcpu_bpf.a -else -cpu_bpf = -endif libebl_bpf_pic_a_SOURCES = $(bpf_SRCS) am_libebl_bpf_pic_a_OBJECTS = $(bpf_SRCS:.c=.os) -libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) +libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) $(libeu) @rm -f $(@:.so=.map) $(AM_V_at)echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \ > $(@:.so=.map) $(AM_V_CCLD)$(LINK) -shared -o $(@:.map=.so) \ -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \ - -Wl,--version-script,$(@:.so=.map) \ - -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) + -Wl,--version-script,$(@:.so=.map),--no-undefined \ + -Wl,-z,defs,-z,relro -Wl,--as-needed $(libelf) $(libdw) $(libeu) @$(textrel_check) libebl_i386.so: $(cpu_i386) diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c index 08664943..fad923fa 100644 --- a/backends/aarch64_init.c +++ b/backends/aarch64_init.c @@ -1,5 +1,5 @@ /* Initialization of AArch64 specific backend library. - Copyright (C) 2013 Red Hat, Inc. + Copyright (C) 2013, 2017 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -56,6 +56,7 @@ aarch64_init (Elf *elf __attribute__ ((unused)), HOOK (eh, reloc_simple_type); HOOK (eh, return_value_location); HOOK (eh, check_special_symbol); + HOOK (eh, data_marker_symbol); HOOK (eh, abi_cfi); /* X0-X30 (31 regs) + SP + 1 Reserved + ELR, 30 Reserved regs (34-43) diff --git a/backends/aarch64_symbol.c b/backends/aarch64_symbol.c index 76999e4b..da3382e9 100644 --- a/backends/aarch64_symbol.c +++ b/backends/aarch64_symbol.c @@ -1,5 +1,5 @@ /* AArch64 specific symbolic name handling. - Copyright (C) 2013, 2015 Red Hat, Inc. + Copyright (C) 2013, 2015, 2017 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -90,3 +90,15 @@ aarch64_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr, const GElf_Sym *sym, return false; } + +/* A data mapping symbol is a symbol with "$d" name or "$d.<any...>" name, + STT_NOTYPE, STB_LOCAL and st_size of zero. The indicate the stat of a + sequence of data items. */ +bool +aarch64_data_marker_symbol (const GElf_Sym *sym, const char *sname) +{ + return (sym != NULL && sname != NULL + && sym->st_size == 0 && GELF_ST_BIND (sym->st_info) == STB_LOCAL + && GELF_ST_TYPE (sym->st_info) == STT_NOTYPE + && (strcmp (sname, "$d") == 0 || strncmp (sname, "$d.", 3) == 0)); +} diff --git a/backends/arm_init.c b/backends/arm_init.c index caadac65..f2b1b11e 100644 --- a/backends/arm_init.c +++ b/backends/arm_init.c @@ -1,5 +1,5 @@ /* Initialization of Arm specific backend library. - Copyright (C) 2002, 2005, 2009, 2013, 2014, 2015 Red Hat, Inc. + Copyright (C) 2002, 2005, 2009, 2013, 2014, 2015, 2017 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2002. @@ -64,6 +64,7 @@ arm_init (Elf *elf __attribute__ ((unused)), HOOK (eh, abi_cfi); HOOK (eh, check_reloc_target_type); HOOK (eh, symbol_type_name); + HOOK (eh, data_marker_symbol); /* We only unwind the core integer registers. */ eh->frame_nregs = 16; diff --git a/backends/arm_symbol.c b/backends/arm_symbol.c index da4a50a7..3edda724 100644 --- a/backends/arm_symbol.c +++ b/backends/arm_symbol.c @@ -1,5 +1,5 @@ /* Arm specific symbolic name handling. - Copyright (C) 2002-2009, 2014, 2015 Red Hat, Inc. + Copyright (C) 2002-2009, 2014, 2015, 2017 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -32,6 +32,7 @@ #include <elf.h> #include <stddef.h> +#include <string.h> #define BACKEND arm_ #include "libebl_CPU.h" @@ -142,3 +143,15 @@ arm_symbol_type_name (int type, } return NULL; } + +/* A data mapping symbol is a symbol with "$d" name or "$d.<any...>" name, + * STT_NOTYPE, STB_LOCAL and st_size of zero. The indicate the stat of a + * sequence of data items. */ +bool +arm_data_marker_symbol (const GElf_Sym *sym, const char *sname) +{ + return (sym != NULL && sname != NULL + && sym->st_size == 0 && GELF_ST_BIND (sym->st_info) == STB_LOCAL + && GELF_ST_TYPE (sym->st_info) == STT_NOTYPE + && (strcmp (sname, "$d") == 0 || strncmp (sname, "$d.", 3) == 0)); +} diff --git a/backends/bpf_init.c b/backends/bpf_init.c index 22842e26..8ea1bc1a 100644 --- a/backends/bpf_init.c +++ b/backends/bpf_init.c @@ -52,9 +52,7 @@ bpf_init (Elf *elf __attribute__ ((unused)), eh->name = "BPF"; bpf_init_reloc (eh); HOOK (eh, register_info); -#ifdef HAVE_LINUX_BPF_H HOOK (eh, disasm); -#endif return MODVERSION; } diff --git a/backends/bpf_regs.c b/backends/bpf_regs.c index 180af83b..1863a164 100644 --- a/backends/bpf_regs.c +++ b/backends/bpf_regs.c @@ -32,11 +32,7 @@ #include <stdio.h> #include <string.h> -#ifdef HAVE_LINUX_BPF_H -#include <linux/bpf.h> -#else -#define MAX_BPF_REG 10 -#endif +#include "bpf.h" #define BACKEND bpf_ #include "libebl_CPU.h" diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c index 11d3a77f..e5670338 100644 --- a/backends/ppc64_init.c +++ b/backends/ppc64_init.c @@ -73,6 +73,7 @@ ppc64_init (Elf *elf __attribute__ ((unused)), eh->frame_nregs = (114 - 1) + 32; HOOK (eh, set_initial_registers_tid); HOOK (eh, dwarf_to_regno); + HOOK (eh, unwind); HOOK (eh, resolve_sym_value); /* Find the function descriptor .opd table for resolve_sym_value. */ diff --git a/backends/ppc64_unwind.c b/backends/ppc64_unwind.c new file mode 100644 index 00000000..4fa0b5a9 --- /dev/null +++ b/backends/ppc64_unwind.c @@ -0,0 +1,76 @@ +/* Get previous frame state for an existing frame state. + Copyright (C) 2017 Red Hat, Inc. + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of either + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version + + or both in parallel, as here. + + elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see <http://www.gnu.org/licenses/>. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#define BACKEND ppc64_ + +#define LR_REG 65 /* Not 108, see ppc_dwarf_to_regno. */ +#define SP_REG 1 + +#define LR_OFFSET 16 + +#include "libebl_CPU.h" + +/* Simplistic fallback frame unwinder. SP points to the backchain (contains + address of previous stack pointer). At SP offset 16 is the LR save area + (contains the value of the previous LR). */ + +bool +EBLHOOK(unwind) (Ebl *ebl __attribute__ ((unused)), + Dwarf_Addr pc __attribute__ ((unused)), + ebl_tid_registers_t *setfunc, ebl_tid_registers_get_t *getfunc, + ebl_pid_memory_read_t *readfunc, void *arg, + bool *signal_framep __attribute__ ((unused))) +{ + Dwarf_Word sp, newSp, lr, newLr; + + /* Stack pointer points to the backchain which contains the previous sp. */ + if (! getfunc (SP_REG, 1, &sp, arg)) + sp = 0; + + /* Link register contains previous program counter. */ + if (! getfunc (LR_REG, 1, &lr, arg) + || lr == 0 + || ! setfunc (-1, 1, &lr, arg)) + return false; + + if (! readfunc(sp, &newSp, arg)) + newSp = 0; + + if (! readfunc(newSp + LR_OFFSET, &newLr, arg)) + newLr = 0; + + setfunc(SP_REG, 1, &newSp, arg); + setfunc(LR_REG, 1, &newLr, arg); + + /* Sanity check the stack grows down. */ + return newSp > sp; +} diff --git a/backends/ppc_corenote.c b/backends/ppc_corenote.c index 9ac88712..2b4ada7a 100644 --- a/backends/ppc_corenote.c +++ b/backends/ppc_corenote.c @@ -94,9 +94,20 @@ static const Ebl_Register_Location spe_regs[] = { .offset = 34 * 4, .regno = 612, .count = 1, .bits = 32 } }; +static const Ebl_Register_Location tm_spr_regs[] = + { + /* tfhar */ + { .offset = 0, .regno = 114, .count = 1, .bits = 64 }, + /* texasr */ + { .offset = 8, .regno = 116, .count = 1, .bits = 64 }, + /* tfiar */ + { .offset = 16, .regno = 115, .count = 1, .bits = 64 } + }; + #define EXTRA_NOTES \ EXTRA_REGSET (NT_PPC_VMX, 34 * 16, altivec_regs) \ - EXTRA_REGSET (NT_PPC_SPE, 35 * 4, spe_regs) + EXTRA_REGSET (NT_PPC_SPE, 35 * 4, spe_regs) \ + EXTRA_REGSET (NT_PPC_TM_SPR, 3 * 8, tm_spr_regs) #if BITS == 32 # define ULONG uint32_t diff --git a/backends/ppc_init.c b/backends/ppc_init.c index c3e3ca36..aea9f2d7 100644 --- a/backends/ppc_init.c +++ b/backends/ppc_init.c @@ -53,6 +53,7 @@ ppc_init (Elf *elf __attribute__ ((unused)), eh->name = "PowerPC"; ppc_init_reloc (eh); HOOK (eh, reloc_simple_type); + HOOK (eh, machine_flag_check); HOOK (eh, dynamic_tag_name); HOOK (eh, dynamic_tag_check); HOOK (eh, check_special_symbol); diff --git a/backends/ppc_regs.c b/backends/ppc_regs.c index bcf4f7a3..c2d50118 100644 --- a/backends/ppc_regs.c +++ b/backends/ppc_regs.c @@ -149,7 +149,15 @@ ppc_register_info (Ebl *ebl __attribute__ ((unused)), namelen = 4; break; - case 110 ... 117: + case 114: + return stpcpy (name, "tfhar") + 1 - name; + case 115: + return stpcpy (name, "tfiar") + 1 - name; + case 116: + return stpcpy (name, "texasr") + 1 - name; + + case 110 ... 113: + case 117: case 120 ... 121: case 123 ... 199: name[0] = 's'; diff --git a/backends/ppc_symbol.c b/backends/ppc_symbol.c index 1273c1d2..4b32003a 100644 --- a/backends/ppc_symbol.c +++ b/backends/ppc_symbol.c @@ -57,6 +57,16 @@ ppc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) } +/* Check whether machine flags are valid. */ +bool +ppc_machine_flag_check (GElf_Word flags) +{ + return ((flags &~ (EF_PPC_EMB + | EF_PPC_RELOCATABLE + | EF_PPC_RELOCATABLE_LIB)) == 0); +} + + const char * ppc_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)), size_t len __attribute__ ((unused))) diff --git a/backends/s390_initreg.c b/backends/s390_initreg.c index 011305ce..23bf8edc 100644 --- a/backends/s390_initreg.c +++ b/backends/s390_initreg.c @@ -34,8 +34,8 @@ #include <assert.h> #if defined(__s390__) && defined(__linux__) # include <sys/user.h> -# include <asm/ptrace.h> # include <sys/ptrace.h> +# include <asm/ptrace.h> #endif #define BACKEND s390_ diff --git a/backends/sparc_reloc.def b/backends/sparc_reloc.def index ce0b5556..7cd5ce96 100644 --- a/backends/sparc_reloc.def +++ b/backends/sparc_reloc.def @@ -110,9 +110,9 @@ RELOC_TYPE (TLS_TPOFF32, DYN) RELOC_TYPE (TLS_TPOFF64, DYN) RELOC_TYPE (GOTDATA_HIX22, REL) RELOC_TYPE (GOTDATA_LOX10, REL) -RELOC_TYPE (GOTDATA_OP_HIX22, DYN) -RELOC_TYPE (GOTDATA_OP_LOX10, DYN) -RELOC_TYPE (GOTDATA_OP, DYN) +RELOC_TYPE (GOTDATA_OP_HIX22, REL|DYN) +RELOC_TYPE (GOTDATA_OP_LOX10, REL|DYN) +RELOC_TYPE (GOTDATA_OP, REL|DYN) RELOC_TYPE (H34, REL) RELOC_TYPE (SIZE32, REL) RELOC_TYPE (SIZE64, REL) |
