blob: 2d0ad65430c3a1c5d2f54acfb31222d41d013034 [file] [log] [blame]
Petr Machatad5285b22012-01-09 04:29:17 +01001/*
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 Machata50b96032012-03-24 04:56:52 +010022#ifndef LTRACE_PPC_ARCH_H
23#define LTRACE_PPC_ARCH_H
24
25#include <gelf.h>
26
Juan Cespedes5bfb0612002-03-31 20:01:28 +020027#define BREAKPOINT_VALUE { 0x7f, 0xe0, 0x00, 0x08 }
Juan Cespedesf1bfe202002-03-27 00:22:23 +010028#define BREAKPOINT_LENGTH 4
29#define DECR_PC_AFTER_BREAK 0
Juan Cespedesd914a202004-11-10 00:15:33 +010030
31#define LT_ELFCLASS ELFCLASS32
32#define LT_ELF_MACHINE EM_PPC
Petr Machatab3f8fef2006-11-30 14:45:07 +010033
Paul Gilliam76c61f12006-06-14 06:55:21 +020034#ifdef __powerpc64__ // Says 'ltrace' is 64 bits, says nothing about target.
Ian Wienand9a2ad352006-02-20 22:44:45 +010035#define LT_ELFCLASS2 ELFCLASS64
36#define LT_ELF_MACHINE2 EM_PPC64
Petr Machatab3f8fef2006-11-30 14:45:07 +010037#define ARCH_SUPPORTS_OPD
Petr Machata7003fee2006-07-18 13:06:26 +020038#endif
Ian Wienand9a2ad352006-02-20 22:44:45 +010039
Petr Machataa266acb2012-04-12 23:50:23 +020040#define ARCH_HAVE_ATOMIC_SINGLESTEP
Petr Machata50b96032012-03-24 04:56:52 +010041#define ARCH_HAVE_ADD_PLT_ENTRY
Petr Machatac67a6e62012-03-28 02:39:49 +020042#define ARCH_HAVE_TRANSLATE_ADDRESS
Petr Machatad9573322012-04-17 05:21:02 +020043#define ARCH_HAVE_DYNLINK_DONE
Petr Machata54737da2012-05-05 03:39:23 +020044#define ARCH_HAVE_FETCH_ARG
Petr Machatad5285b22012-01-09 04:29:17 +010045#define ARCH_ENDIAN_BIG
Petr Machataaf9e30e2012-05-17 01:35:37 +020046#define ARCH_HAVE_SIZEOF
47#define ARCH_HAVE_ALIGNOF
Petr Machata50b96032012-03-24 04:56:52 +010048
49struct library_symbol;
Petr Machataabfe1182012-04-15 04:34:28 +020050
51#define ARCH_HAVE_LTELF_DATA
Petr Machatae67635d2012-03-21 03:37:39 +010052struct arch_ltelf_data {
Petr Machatae67635d2012-03-21 03:37:39 +010053 GElf_Addr plt_stub_vma;
Petr Machata50b96032012-03-24 04:56:52 +010054 struct library_symbol *stubs;
Petr Machatab1492df2012-04-30 21:01:40 +020055 Elf_Data *opd_data;
56 GElf_Addr opd_base;
57 GElf_Xword opd_size;
Petr Machatad9573322012-04-17 05:21:02 +020058 int secure_plt;
59};
60
61#define ARCH_HAVE_LIBRARY_DATA
62struct arch_library_data {
63 int bss_plt_prelinked;
Petr Machatae67635d2012-03-21 03:37:39 +010064};
Petr Machata50b96032012-03-24 04:56:52 +010065
Petr Machatab64b5c72012-03-27 03:19:42 +020066enum ppc64_plt_type {
Petr Machatafbd97422012-04-16 21:09:18 +020067 /* Either a non-PLT symbol, or PPC32 symbol. */
68 PPC_DEFAULT = 0,
69
Petr Machata585f60f2012-04-17 17:05:12 +020070 /* PPC64 STUB, never resolved. */
71 PPC64_PLT_STUB,
Petr Machatab64b5c72012-03-27 03:19:42 +020072
73 /* Unresolved PLT symbol (.plt contains PLT address). */
Petr Machata585f60f2012-04-17 17:05:12 +020074 PPC_PLT_UNRESOLVED,
Petr Machatab64b5c72012-03-27 03:19:42 +020075
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 Machata1b4c76e2012-04-06 14:50:17 +020079 * RESOLVED_VALUE. */
Petr Machata585f60f2012-04-17 17:05:12 +020080 PPC_PLT_RESOLVED,
Petr Machatab64b5c72012-03-27 03:19:42 +020081};
82
Petr Machata24c6e9d2012-04-15 04:31:34 +020083#define ARCH_HAVE_LIBRARY_SYMBOL_DATA
Petr Machatab64b5c72012-03-27 03:19:42 +020084struct arch_library_symbol_data {
85 enum ppc64_plt_type type;
Petr Machata58b2d0f2012-03-28 02:19:20 +020086 GElf_Addr resolved_value;
87
88 /* Address of corresponding slot in .plt. */
89 GElf_Addr plt_slot_addr;
Petr Machatab64b5c72012-03-27 03:19:42 +020090};
91
Petr Machataabfe1182012-04-15 04:34:28 +020092#define ARCH_HAVE_BREAKPOINT_DATA
Petr Machatab64b5c72012-03-27 03:19:42 +020093struct arch_breakpoint_data {
Petr Machataabfe1182012-04-15 04:34:28 +020094 /* We need this just for arch_breakpoint_init. */
Petr Machatab64b5c72012-03-27 03:19:42 +020095};
96
Petr Machata6b314182012-04-15 04:40:45 +020097#define ARCH_HAVE_PROCESS_DATA
98struct 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 Machata50b96032012-03-24 04:56:52 +0100107#endif /* LTRACE_PPC_ARCH_H */