blob: 67f146ec85d56551273a0920602c9d0f8ef62534 [file] [log] [blame]
Petr Machata50b96032012-03-24 04:56:52 +01001#ifndef LTRACE_PPC_ARCH_H
2#define LTRACE_PPC_ARCH_H
3
4#include <gelf.h>
5
Juan Cespedes5bfb0612002-03-31 20:01:28 +02006#define BREAKPOINT_VALUE { 0x7f, 0xe0, 0x00, 0x08 }
Juan Cespedesf1bfe202002-03-27 00:22:23 +01007#define BREAKPOINT_LENGTH 4
8#define DECR_PC_AFTER_BREAK 0
Juan Cespedesd914a202004-11-10 00:15:33 +01009
10#define LT_ELFCLASS ELFCLASS32
11#define LT_ELF_MACHINE EM_PPC
Petr Machatab3f8fef2006-11-30 14:45:07 +010012
Paul Gilliam76c61f12006-06-14 06:55:21 +020013#ifdef __powerpc64__ // Says 'ltrace' is 64 bits, says nothing about target.
Ian Wienand9a2ad352006-02-20 22:44:45 +010014#define LT_ELFCLASS2 ELFCLASS64
15#define LT_ELF_MACHINE2 EM_PPC64
Petr Machatab3f8fef2006-11-30 14:45:07 +010016#define ARCH_SUPPORTS_OPD
Petr Machata7003fee2006-07-18 13:06:26 +020017#endif
Ian Wienand9a2ad352006-02-20 22:44:45 +010018
Paul Gilliambe320772006-04-24 22:06:23 +020019#define PLT_REINITALISATION_BP "_start"
Ian Wienand9a2ad352006-02-20 22:44:45 +010020
Luis Machado55c5feb2008-03-12 15:56:01 +010021#define ARCH_HAVE_UMOVELONG
Petr Machataa266acb2012-04-12 23:50:23 +020022#define ARCH_HAVE_ATOMIC_SINGLESTEP
Petr Machata50b96032012-03-24 04:56:52 +010023#define ARCH_HAVE_ADD_PLT_ENTRY
Petr Machatac67a6e62012-03-28 02:39:49 +020024#define ARCH_HAVE_TRANSLATE_ADDRESS
Petr Machatad9573322012-04-17 05:21:02 +020025#define ARCH_HAVE_DYNLINK_DONE
Petr Machata50b96032012-03-24 04:56:52 +010026
27struct library_symbol;
Petr Machataabfe1182012-04-15 04:34:28 +020028
29#define ARCH_HAVE_LTELF_DATA
Petr Machatae67635d2012-03-21 03:37:39 +010030struct arch_ltelf_data {
Petr Machatae67635d2012-03-21 03:37:39 +010031 GElf_Addr plt_stub_vma;
Petr Machata50b96032012-03-24 04:56:52 +010032 struct library_symbol *stubs;
Petr Machatad9573322012-04-17 05:21:02 +020033 int secure_plt;
34};
35
36#define ARCH_HAVE_LIBRARY_DATA
37struct arch_library_data {
38 int bss_plt_prelinked;
Petr Machatae67635d2012-03-21 03:37:39 +010039};
Petr Machata50b96032012-03-24 04:56:52 +010040
Petr Machatab64b5c72012-03-27 03:19:42 +020041enum ppc64_plt_type {
Petr Machatafbd97422012-04-16 21:09:18 +020042 /* Either a non-PLT symbol, or PPC32 symbol. */
43 PPC_DEFAULT = 0,
44
Petr Machata585f60f2012-04-17 17:05:12 +020045 /* PPC64 STUB, never resolved. */
46 PPC64_PLT_STUB,
Petr Machatab64b5c72012-03-27 03:19:42 +020047
48 /* Unresolved PLT symbol (.plt contains PLT address). */
Petr Machata585f60f2012-04-17 17:05:12 +020049 PPC_PLT_UNRESOLVED,
Petr Machatab64b5c72012-03-27 03:19:42 +020050
51 /* Resolved PLT symbol. The corresponding .plt slot contained
52 * target address, which was changed to the address of
53 * corresponding PLT entry. The original is now saved in
Petr Machata1b4c76e2012-04-06 14:50:17 +020054 * RESOLVED_VALUE. */
Petr Machata585f60f2012-04-17 17:05:12 +020055 PPC_PLT_RESOLVED,
Petr Machatab64b5c72012-03-27 03:19:42 +020056};
57
Petr Machata24c6e9d2012-04-15 04:31:34 +020058#define ARCH_HAVE_LIBRARY_SYMBOL_DATA
Petr Machatab64b5c72012-03-27 03:19:42 +020059struct arch_library_symbol_data {
60 enum ppc64_plt_type type;
Petr Machata58b2d0f2012-03-28 02:19:20 +020061 GElf_Addr resolved_value;
62
63 /* Address of corresponding slot in .plt. */
64 GElf_Addr plt_slot_addr;
Petr Machatab64b5c72012-03-27 03:19:42 +020065};
66
Petr Machataabfe1182012-04-15 04:34:28 +020067#define ARCH_HAVE_BREAKPOINT_DATA
Petr Machatab64b5c72012-03-27 03:19:42 +020068struct arch_breakpoint_data {
Petr Machataabfe1182012-04-15 04:34:28 +020069 /* We need this just for arch_breakpoint_init. */
Petr Machatab64b5c72012-03-27 03:19:42 +020070};
71
Petr Machata6b314182012-04-15 04:40:45 +020072#define ARCH_HAVE_PROCESS_DATA
73struct arch_process_data {
74 /* Breakpoint that hits when the dynamic linker is about to
75 * update a .plt slot. NULL before that address is known. */
76 struct breakpoint *dl_plt_update_bp;
77
78 /* PLT update breakpoint looks here for the handler. */
79 struct process_stopping_handler *handler;
80};
81
Petr Machata50b96032012-03-24 04:56:52 +010082#endif /* LTRACE_PPC_ARCH_H */