1 /* ARM Symbian OS target support.
3 Copyright (C) 2008, 2009, 2010
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 #include "solib-target.h"
30 /* If PC is in a DLL import stub, return the address of the `real'
31 function belonging to the stub. */
34 arm_symbian_skip_trampoline_code (struct frame_info
*frame
, CORE_ADDR pc
)
36 struct gdbarch
*gdbarch
;
37 enum bfd_endian byte_order
;
42 if (!in_plt_section (pc
, NULL
))
45 if (target_read_memory (pc
, buf
, 4) != 0)
48 gdbarch
= get_frame_arch (frame
);
49 byte_order
= gdbarch_byte_order (gdbarch
);
51 /* ldr pc, [pc, #-4]. */
52 insn
= extract_unsigned_integer (buf
, 4, byte_order
);
53 if (insn
!= 0xe51ff004)
56 if (target_read_memory (pc
+ 4, buf
, 4) != 0)
59 dest
= extract_unsigned_integer (buf
, 4, byte_order
);
60 return gdbarch_addr_bits_remove (gdbarch
, dest
);
64 arm_symbian_init_abi (struct gdbarch_info info
,
65 struct gdbarch
*gdbarch
)
67 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
69 /* Shared library handling. */
70 set_gdbarch_skip_trampoline_code (gdbarch
, arm_symbian_skip_trampoline_code
);
72 set_solib_ops (gdbarch
, &solib_target_so_ops
);
75 /* Recognize Symbian object files. */
78 arm_symbian_osabi_sniffer (bfd
*abfd
)
80 Elf_Internal_Phdr
*phdrs
, **segments
;
84 /* Symbian executables are always shared objects (ET_DYN). */
85 if (elf_elfheader (abfd
)->e_type
== ET_EXEC
)
86 return GDB_OSABI_UNKNOWN
;
88 if (elf_elfheader (abfd
)->e_ident
[EI_OSABI
] != ELFOSABI_NONE
)
89 return GDB_OSABI_UNKNOWN
;
91 /* Check for the ELF headers not being part of any PT_LOAD segment.
92 Symbian is the only GDB supported (or GNU binutils supported) ARM
93 target which uses a postlinker to flatten ELF files, dropping the
94 ELF dynamic info in the process. */
95 phdrs_size
= bfd_get_elf_phdr_upper_bound (abfd
);
97 return GDB_OSABI_UNKNOWN
;
99 phdrs
= alloca (phdrs_size
);
100 num_phdrs
= bfd_get_elf_phdrs (abfd
, phdrs
);
102 return GDB_OSABI_UNKNOWN
;
104 for (i
= 0; i
< num_phdrs
; i
++)
105 if (phdrs
[i
].p_type
== PT_LOAD
&& phdrs
[i
].p_offset
== 0)
106 return GDB_OSABI_UNKNOWN
;
108 /* Looks like a Symbian binary. */
109 return GDB_OSABI_SYMBIAN
;
113 _initialize_arm_symbian_tdep (void)
115 gdbarch_register_osabi_sniffer (bfd_arch_arm
,
116 bfd_target_elf_flavour
,
117 arm_symbian_osabi_sniffer
);
119 gdbarch_register_osabi (bfd_arch_arm
, 0, GDB_OSABI_SYMBIAN
,
120 arm_symbian_init_abi
);