| Petr Machata | d5285b2 | 2012-01-09 04:29:17 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of ltrace. |
| 3 | * Copyright (C) 2012 Petr Machata |
| 4 | * Copyright (C) 2006 Paul Gilliam |
| 5 | * Copyright (C) 2002,2004 Juan Cespedes |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of the |
| 10 | * License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | * 02110-1301 USA |
| 21 | */ |
| Petr Machata | 50b9603 | 2012-03-24 04:56:52 +0100 | [diff] [blame] | 22 | #ifndef LTRACE_PPC_ARCH_H |
| 23 | #define LTRACE_PPC_ARCH_H |
| 24 | |
| 25 | #include <gelf.h> |
| 26 | |
| Juan Cespedes | 5bfb061 | 2002-03-31 20:01:28 +0200 | [diff] [blame] | 27 | #define BREAKPOINT_VALUE { 0x7f, 0xe0, 0x00, 0x08 } |
| Juan Cespedes | f1bfe20 | 2002-03-27 00:22:23 +0100 | [diff] [blame] | 28 | #define BREAKPOINT_LENGTH 4 |
| 29 | #define DECR_PC_AFTER_BREAK 0 |
| Juan Cespedes | d914a20 | 2004-11-10 00:15:33 +0100 | [diff] [blame] | 30 | |
| 31 | #define LT_ELFCLASS ELFCLASS32 |
| 32 | #define LT_ELF_MACHINE EM_PPC |
| Petr Machata | b3f8fef | 2006-11-30 14:45:07 +0100 | [diff] [blame] | 33 | |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 34 | #ifdef __powerpc64__ // Says 'ltrace' is 64 bits, says nothing about target. |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 35 | #define LT_ELFCLASS2 ELFCLASS64 |
| 36 | #define LT_ELF_MACHINE2 EM_PPC64 |
| Petr Machata | b3f8fef | 2006-11-30 14:45:07 +0100 | [diff] [blame] | 37 | #define ARCH_SUPPORTS_OPD |
| Petr Machata | 7003fee | 2006-07-18 13:06:26 +0200 | [diff] [blame] | 38 | #endif |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 39 | |
| Petr Machata | a266acb | 2012-04-12 23:50:23 +0200 | [diff] [blame] | 40 | #define ARCH_HAVE_ATOMIC_SINGLESTEP |
| Petr Machata | 50b9603 | 2012-03-24 04:56:52 +0100 | [diff] [blame] | 41 | #define ARCH_HAVE_ADD_PLT_ENTRY |
| Petr Machata | c67a6e6 | 2012-03-28 02:39:49 +0200 | [diff] [blame] | 42 | #define ARCH_HAVE_TRANSLATE_ADDRESS |
| Petr Machata | d957332 | 2012-04-17 05:21:02 +0200 | [diff] [blame] | 43 | #define ARCH_HAVE_DYNLINK_DONE |
| Petr Machata | 54737da | 2012-05-05 03:39:23 +0200 | [diff] [blame] | 44 | #define ARCH_HAVE_FETCH_ARG |
| Petr Machata | d5285b2 | 2012-01-09 04:29:17 +0100 | [diff] [blame] | 45 | #define ARCH_ENDIAN_BIG |
| Petr Machata | af9e30e | 2012-05-17 01:35:37 +0200 | [diff] [blame] | 46 | #define ARCH_HAVE_SIZEOF |
| 47 | #define ARCH_HAVE_ALIGNOF |
| Petr Machata | 50b9603 | 2012-03-24 04:56:52 +0100 | [diff] [blame] | 48 | |
| 49 | struct library_symbol; |
| Petr Machata | abfe118 | 2012-04-15 04:34:28 +0200 | [diff] [blame] | 50 | |
| 51 | #define ARCH_HAVE_LTELF_DATA |
| Petr Machata | e67635d | 2012-03-21 03:37:39 +0100 | [diff] [blame] | 52 | struct arch_ltelf_data { |
| Petr Machata | e67635d | 2012-03-21 03:37:39 +0100 | [diff] [blame] | 53 | GElf_Addr plt_stub_vma; |
| Petr Machata | 50b9603 | 2012-03-24 04:56:52 +0100 | [diff] [blame] | 54 | struct library_symbol *stubs; |
| Petr Machata | b1492df | 2012-04-30 21:01:40 +0200 | [diff] [blame] | 55 | Elf_Data *opd_data; |
| 56 | GElf_Addr opd_base; |
| 57 | GElf_Xword opd_size; |
| Petr Machata | d957332 | 2012-04-17 05:21:02 +0200 | [diff] [blame] | 58 | int secure_plt; |
| 59 | }; |
| 60 | |
| 61 | #define ARCH_HAVE_LIBRARY_DATA |
| 62 | struct arch_library_data { |
| 63 | int bss_plt_prelinked; |
| Petr Machata | e67635d | 2012-03-21 03:37:39 +0100 | [diff] [blame] | 64 | }; |
| Petr Machata | 50b9603 | 2012-03-24 04:56:52 +0100 | [diff] [blame] | 65 | |
| Petr Machata | b64b5c7 | 2012-03-27 03:19:42 +0200 | [diff] [blame] | 66 | enum ppc64_plt_type { |
| Petr Machata | fbd9742 | 2012-04-16 21:09:18 +0200 | [diff] [blame] | 67 | /* Either a non-PLT symbol, or PPC32 symbol. */ |
| 68 | PPC_DEFAULT = 0, |
| 69 | |
| Petr Machata | 585f60f | 2012-04-17 17:05:12 +0200 | [diff] [blame] | 70 | /* PPC64 STUB, never resolved. */ |
| 71 | PPC64_PLT_STUB, |
| Petr Machata | b64b5c7 | 2012-03-27 03:19:42 +0200 | [diff] [blame] | 72 | |
| 73 | /* Unresolved PLT symbol (.plt contains PLT address). */ |
| Petr Machata | 585f60f | 2012-04-17 17:05:12 +0200 | [diff] [blame] | 74 | PPC_PLT_UNRESOLVED, |
| Petr Machata | b64b5c7 | 2012-03-27 03:19:42 +0200 | [diff] [blame] | 75 | |
| 76 | /* Resolved PLT symbol. The corresponding .plt slot contained |
| 77 | * target address, which was changed to the address of |
| 78 | * corresponding PLT entry. The original is now saved in |
| Petr Machata | 1b4c76e | 2012-04-06 14:50:17 +0200 | [diff] [blame] | 79 | * RESOLVED_VALUE. */ |
| Petr Machata | 585f60f | 2012-04-17 17:05:12 +0200 | [diff] [blame] | 80 | PPC_PLT_RESOLVED, |
| Petr Machata | b64b5c7 | 2012-03-27 03:19:42 +0200 | [diff] [blame] | 81 | }; |
| 82 | |
| Petr Machata | 24c6e9d | 2012-04-15 04:31:34 +0200 | [diff] [blame] | 83 | #define ARCH_HAVE_LIBRARY_SYMBOL_DATA |
| Petr Machata | b64b5c7 | 2012-03-27 03:19:42 +0200 | [diff] [blame] | 84 | struct arch_library_symbol_data { |
| 85 | enum ppc64_plt_type type; |
| Petr Machata | 58b2d0f | 2012-03-28 02:19:20 +0200 | [diff] [blame] | 86 | GElf_Addr resolved_value; |
| 87 | |
| 88 | /* Address of corresponding slot in .plt. */ |
| 89 | GElf_Addr plt_slot_addr; |
| Petr Machata | b64b5c7 | 2012-03-27 03:19:42 +0200 | [diff] [blame] | 90 | }; |
| 91 | |
| Petr Machata | abfe118 | 2012-04-15 04:34:28 +0200 | [diff] [blame] | 92 | #define ARCH_HAVE_BREAKPOINT_DATA |
| Petr Machata | b64b5c7 | 2012-03-27 03:19:42 +0200 | [diff] [blame] | 93 | struct arch_breakpoint_data { |
| Petr Machata | abfe118 | 2012-04-15 04:34:28 +0200 | [diff] [blame] | 94 | /* We need this just for arch_breakpoint_init. */ |
| Petr Machata | b64b5c7 | 2012-03-27 03:19:42 +0200 | [diff] [blame] | 95 | }; |
| 96 | |
| Petr Machata | 6b31418 | 2012-04-15 04:40:45 +0200 | [diff] [blame] | 97 | #define ARCH_HAVE_PROCESS_DATA |
| 98 | struct arch_process_data { |
| 99 | /* Breakpoint that hits when the dynamic linker is about to |
| 100 | * update a .plt slot. NULL before that address is known. */ |
| 101 | struct breakpoint *dl_plt_update_bp; |
| 102 | |
| 103 | /* PLT update breakpoint looks here for the handler. */ |
| 104 | struct process_stopping_handler *handler; |
| 105 | }; |
| 106 | |
| Petr Machata | 50b9603 | 2012-03-24 04:56:52 +0100 | [diff] [blame] | 107 | #endif /* LTRACE_PPC_ARCH_H */ |