Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- ObjectFileMachO.cpp -------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "ObjectFileMachO.h" |
| 11 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | #include "lldb/Core/ArchSpec.h" |
| 13 | #include "lldb/Core/DataBuffer.h" |
| 14 | #include "lldb/Core/FileSpec.h" |
| 15 | #include "lldb/Core/FileSpecList.h" |
| 16 | #include "lldb/Core/Module.h" |
| 17 | #include "lldb/Core/PluginManager.h" |
| 18 | #include "lldb/Core/Section.h" |
| 19 | #include "lldb/Core/StreamFile.h" |
| 20 | #include "lldb/Core/StreamString.h" |
| 21 | #include "lldb/Core/Timer.h" |
| 22 | #include "lldb/Core/UUID.h" |
| 23 | #include "lldb/Symbol/ObjectFile.h" |
| 24 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 25 | |
| 26 | using namespace lldb; |
| 27 | using namespace lldb_private; |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 28 | using namespace llvm::MachO; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 29 | |
| 30 | |
| 31 | void |
| 32 | ObjectFileMachO::Initialize() |
| 33 | { |
| 34 | PluginManager::RegisterPlugin (GetPluginNameStatic(), |
| 35 | GetPluginDescriptionStatic(), |
| 36 | CreateInstance); |
| 37 | } |
| 38 | |
| 39 | void |
| 40 | ObjectFileMachO::Terminate() |
| 41 | { |
| 42 | PluginManager::UnregisterPlugin (CreateInstance); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | const char * |
| 47 | ObjectFileMachO::GetPluginNameStatic() |
| 48 | { |
| 49 | return "object-file.mach-o"; |
| 50 | } |
| 51 | |
| 52 | const char * |
| 53 | ObjectFileMachO::GetPluginDescriptionStatic() |
| 54 | { |
| 55 | return "Mach-o object file reader (32 and 64 bit)"; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | ObjectFile * |
| 60 | ObjectFileMachO::CreateInstance (Module* module, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length) |
| 61 | { |
| 62 | if (ObjectFileMachO::MagicBytesMatch(dataSP)) |
| 63 | { |
| 64 | std::auto_ptr<ObjectFile> objfile_ap(new ObjectFileMachO (module, dataSP, file, offset, length)); |
| 65 | if (objfile_ap.get() && objfile_ap->ParseHeader()) |
| 66 | return objfile_ap.release(); |
| 67 | } |
| 68 | return NULL; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | static uint32_t |
| 73 | MachHeaderSizeFromMagic(uint32_t magic) |
| 74 | { |
| 75 | switch (magic) |
| 76 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 77 | case HeaderMagic32: |
| 78 | case HeaderMagic32Swapped: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 79 | return sizeof(struct mach_header); |
| 80 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 81 | case HeaderMagic64: |
| 82 | case HeaderMagic64Swapped: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 83 | return sizeof(struct mach_header_64); |
| 84 | break; |
| 85 | |
| 86 | default: |
| 87 | break; |
| 88 | } |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | bool |
| 94 | ObjectFileMachO::MagicBytesMatch (DataBufferSP& dataSP) |
| 95 | { |
| 96 | DataExtractor data(dataSP, eByteOrderHost, 4); |
| 97 | uint32_t offset = 0; |
| 98 | uint32_t magic = data.GetU32(&offset); |
| 99 | return MachHeaderSizeFromMagic(magic) != 0; |
| 100 | } |
| 101 | |
| 102 | |
| 103 | ObjectFileMachO::ObjectFileMachO(Module* module, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length) : |
| 104 | ObjectFile(module, file, offset, length, dataSP), |
| 105 | m_mutex (Mutex::eMutexTypeRecursive), |
| 106 | m_header(), |
| 107 | m_sections_ap(), |
| 108 | m_symtab_ap() |
| 109 | { |
| 110 | ::bzero (&m_header, sizeof(m_header)); |
| 111 | ::bzero (&m_dysymtab, sizeof(m_dysymtab)); |
| 112 | } |
| 113 | |
| 114 | |
| 115 | ObjectFileMachO::~ObjectFileMachO() |
| 116 | { |
| 117 | } |
| 118 | |
| 119 | |
| 120 | bool |
| 121 | ObjectFileMachO::ParseHeader () |
| 122 | { |
| 123 | lldb_private::Mutex::Locker locker(m_mutex); |
| 124 | bool can_parse = false; |
| 125 | uint32_t offset = 0; |
| 126 | m_data.SetByteOrder (eByteOrderHost); |
| 127 | // Leave magic in the original byte order |
| 128 | m_header.magic = m_data.GetU32(&offset); |
| 129 | switch (m_header.magic) |
| 130 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 131 | case HeaderMagic32: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 132 | m_data.SetByteOrder (eByteOrderHost); |
| 133 | m_data.SetAddressByteSize(4); |
| 134 | can_parse = true; |
| 135 | break; |
| 136 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 137 | case HeaderMagic64: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 138 | m_data.SetByteOrder (eByteOrderHost); |
| 139 | m_data.SetAddressByteSize(8); |
| 140 | can_parse = true; |
| 141 | break; |
| 142 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 143 | case HeaderMagic32Swapped: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 144 | m_data.SetByteOrder(eByteOrderHost == eByteOrderBig ? eByteOrderLittle : eByteOrderBig); |
| 145 | m_data.SetAddressByteSize(4); |
| 146 | can_parse = true; |
| 147 | break; |
| 148 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 149 | case HeaderMagic64Swapped: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 150 | m_data.SetByteOrder(eByteOrderHost == eByteOrderBig ? eByteOrderLittle : eByteOrderBig); |
| 151 | m_data.SetAddressByteSize(8); |
| 152 | can_parse = true; |
| 153 | break; |
| 154 | |
| 155 | default: |
| 156 | break; |
| 157 | } |
| 158 | |
| 159 | if (can_parse) |
| 160 | { |
| 161 | m_data.GetU32(&offset, &m_header.cputype, 6); |
| 162 | |
Greg Clayton | 41f9232 | 2010-06-11 03:25:34 +0000 | [diff] [blame] | 163 | ArchSpec mach_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype); |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 164 | |
| 165 | if (SetModulesArchitecture (mach_arch)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 166 | { |
| 167 | // Read in all only the load command data |
| 168 | DataBufferSP data_sp(m_file.ReadFileContents(m_offset, m_header.sizeofcmds + MachHeaderSizeFromMagic(m_header.magic))); |
| 169 | m_data.SetData (data_sp); |
| 170 | return true; |
| 171 | } |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | memset(&m_header, 0, sizeof(struct mach_header)); |
| 176 | } |
| 177 | return false; |
| 178 | } |
| 179 | |
| 180 | |
| 181 | ByteOrder |
| 182 | ObjectFileMachO::GetByteOrder () const |
| 183 | { |
| 184 | lldb_private::Mutex::Locker locker(m_mutex); |
| 185 | return m_data.GetByteOrder (); |
| 186 | } |
| 187 | |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 188 | bool |
| 189 | ObjectFileMachO::IsExecutable() const |
| 190 | { |
| 191 | return m_header.filetype == HeaderFileTypeExecutable; |
| 192 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 193 | |
| 194 | size_t |
| 195 | ObjectFileMachO::GetAddressByteSize () const |
| 196 | { |
| 197 | lldb_private::Mutex::Locker locker(m_mutex); |
| 198 | return m_data.GetAddressByteSize (); |
| 199 | } |
| 200 | |
| 201 | |
| 202 | Symtab * |
| 203 | ObjectFileMachO::GetSymtab() |
| 204 | { |
| 205 | lldb_private::Mutex::Locker locker(m_mutex); |
| 206 | if (m_symtab_ap.get() == NULL) |
| 207 | { |
| 208 | m_symtab_ap.reset(new Symtab(this)); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 209 | ParseSymtab (true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 210 | } |
| 211 | return m_symtab_ap.get(); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | SectionList * |
| 216 | ObjectFileMachO::GetSectionList() |
| 217 | { |
| 218 | lldb_private::Mutex::Locker locker(m_mutex); |
| 219 | if (m_sections_ap.get() == NULL) |
| 220 | { |
| 221 | m_sections_ap.reset(new SectionList()); |
| 222 | ParseSections(); |
| 223 | } |
| 224 | return m_sections_ap.get(); |
| 225 | } |
| 226 | |
| 227 | |
| 228 | size_t |
| 229 | ObjectFileMachO::ParseSections () |
| 230 | { |
| 231 | lldb::user_id_t segID = 0; |
| 232 | lldb::user_id_t sectID = 0; |
| 233 | struct segment_command_64 load_cmd; |
| 234 | uint32_t offset = MachHeaderSizeFromMagic(m_header.magic); |
| 235 | uint32_t i; |
| 236 | //bool dump_sections = false; |
| 237 | for (i=0; i<m_header.ncmds; ++i) |
| 238 | { |
| 239 | const uint32_t load_cmd_offset = offset; |
| 240 | if (m_data.GetU32(&offset, &load_cmd, 2) == NULL) |
| 241 | break; |
| 242 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 243 | if (load_cmd.cmd == LoadCommandSegment32 || load_cmd.cmd == LoadCommandSegment64) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 244 | { |
| 245 | if (m_data.GetU8(&offset, (uint8_t*)load_cmd.segname, 16)) |
| 246 | { |
| 247 | load_cmd.vmaddr = m_data.GetAddress(&offset); |
| 248 | load_cmd.vmsize = m_data.GetAddress(&offset); |
| 249 | load_cmd.fileoff = m_data.GetAddress(&offset); |
| 250 | load_cmd.filesize = m_data.GetAddress(&offset); |
| 251 | if (m_data.GetU32(&offset, &load_cmd.maxprot, 4)) |
| 252 | { |
| 253 | // Keep a list of mach segments around in case we need to |
| 254 | // get at data that isn't stored in the abstracted Sections. |
| 255 | m_mach_segments.push_back (load_cmd); |
| 256 | |
| 257 | ConstString segment_name (load_cmd.segname, std::min<int>(strlen(load_cmd.segname), sizeof(load_cmd.segname))); |
| 258 | // Use a segment ID of the segment index shifted left by 8 so they |
| 259 | // never conflict with any of the sections. |
| 260 | SectionSP segment_sp; |
| 261 | if (segment_name) |
| 262 | { |
| 263 | segment_sp.reset(new Section (NULL, |
| 264 | GetModule(), // Module to which this section belongs |
| 265 | ++segID << 8, // Section ID is the 1 based segment index shifted right by 8 bits as not to collide with any of the 256 section IDs that are possible |
| 266 | segment_name, // Name of this section |
| 267 | eSectionTypeContainer, // This section is a container of other sections. |
| 268 | load_cmd.vmaddr, // File VM address == addresses as they are found in the object file |
| 269 | load_cmd.vmsize, // VM size in bytes of this section |
| 270 | load_cmd.fileoff, // Offset to the data for this section in the file |
| 271 | load_cmd.filesize, // Size in bytes of this section as found in the the file |
| 272 | load_cmd.flags)); // Flags for this section |
| 273 | |
| 274 | m_sections_ap->AddSection(segment_sp); |
| 275 | } |
| 276 | |
| 277 | struct section_64 sect64; |
| 278 | ::bzero (§64, sizeof(sect64)); |
| 279 | // Push a section into our mach sections for the section at |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 280 | // index zero (NListSectionNoSection) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 281 | m_mach_sections.push_back(sect64); |
| 282 | uint32_t segment_sect_idx; |
| 283 | const lldb::user_id_t first_segment_sectID = sectID + 1; |
| 284 | |
| 285 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 286 | const uint32_t num_u32s = load_cmd.cmd == LoadCommandSegment32 ? 7 : 8; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 287 | for (segment_sect_idx=0; segment_sect_idx<load_cmd.nsects; ++segment_sect_idx) |
| 288 | { |
| 289 | if (m_data.GetU8(&offset, (uint8_t*)sect64.sectname, sizeof(sect64.sectname)) == NULL) |
| 290 | break; |
| 291 | if (m_data.GetU8(&offset, (uint8_t*)sect64.segname, sizeof(sect64.segname)) == NULL) |
| 292 | break; |
| 293 | sect64.addr = m_data.GetAddress(&offset); |
| 294 | sect64.size = m_data.GetAddress(&offset); |
| 295 | |
| 296 | if (m_data.GetU32(&offset, §64.offset, num_u32s) == NULL) |
| 297 | break; |
| 298 | |
| 299 | // Keep a list of mach sections around in case we need to |
| 300 | // get at data that isn't stored in the abstracted Sections. |
| 301 | m_mach_sections.push_back (sect64); |
| 302 | |
| 303 | ConstString section_name (sect64.sectname, std::min<size_t>(strlen(sect64.sectname), sizeof(sect64.sectname))); |
| 304 | if (!segment_name) |
| 305 | { |
| 306 | // We have a segment with no name so we need to conjure up |
| 307 | // segments that correspond to the section's segname if there |
| 308 | // isn't already such a section. If there is such a section, |
| 309 | // we resize the section so that it spans all sections. |
| 310 | // We also mark these sections as fake so address matches don't |
| 311 | // hit if they land in the gaps between the child sections. |
| 312 | segment_name.SetTrimmedCStringWithLength(sect64.segname, sizeof(sect64.segname)); |
| 313 | segment_sp = m_sections_ap->FindSectionByName (segment_name); |
| 314 | if (segment_sp.get()) |
| 315 | { |
| 316 | Section *segment = segment_sp.get(); |
| 317 | // Grow the section size as needed. |
| 318 | const lldb::addr_t sect64_min_addr = sect64.addr; |
| 319 | const lldb::addr_t sect64_max_addr = sect64_min_addr + sect64.size; |
| 320 | const lldb::addr_t curr_seg_byte_size = segment->GetByteSize(); |
| 321 | const lldb::addr_t curr_seg_min_addr = segment->GetFileAddress(); |
| 322 | const lldb::addr_t curr_seg_max_addr = curr_seg_min_addr + curr_seg_byte_size; |
| 323 | if (sect64_min_addr >= curr_seg_min_addr) |
| 324 | { |
| 325 | const lldb::addr_t new_seg_byte_size = sect64_max_addr - curr_seg_min_addr; |
| 326 | // Only grow the section size if needed |
| 327 | if (new_seg_byte_size > curr_seg_byte_size) |
| 328 | segment->SetByteSize (new_seg_byte_size); |
| 329 | } |
| 330 | else |
| 331 | { |
| 332 | // We need to change the base address of the segment and |
| 333 | // adjust the child section offsets for all existing children. |
| 334 | const lldb::addr_t slide_amount = sect64_min_addr - curr_seg_min_addr; |
| 335 | segment->Slide(slide_amount, false); |
| 336 | segment->GetChildren().Slide (-slide_amount, false); |
| 337 | segment->SetByteSize (curr_seg_max_addr - sect64_min_addr); |
| 338 | } |
Greg Clayton | 8d38ac4 | 2010-06-28 23:51:11 +0000 | [diff] [blame] | 339 | |
| 340 | // Grow the section size as needed. |
| 341 | if (sect64.offset) |
| 342 | { |
| 343 | const lldb::addr_t segment_min_file_offset = segment->GetFileOffset(); |
| 344 | const lldb::addr_t segment_max_file_offset = segment_min_file_offset + segment->GetFileSize(); |
| 345 | |
| 346 | const lldb::addr_t section_min_file_offset = sect64.offset; |
| 347 | const lldb::addr_t section_max_file_offset = section_min_file_offset + sect64.size; |
| 348 | const lldb::addr_t new_file_offset = std::min (section_min_file_offset, segment_min_file_offset); |
| 349 | const lldb::addr_t new_file_size = std::max (section_max_file_offset, segment_max_file_offset) - new_file_offset; |
| 350 | segment->SetFileOffset (new_file_offset); |
| 351 | segment->SetFileSize (new_file_size); |
| 352 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 353 | } |
| 354 | else |
| 355 | { |
| 356 | // Create a fake section for the section's named segment |
| 357 | segment_sp.reset(new Section(segment_sp.get(), // Parent section |
| 358 | GetModule(), // Module to which this section belongs |
| 359 | ++segID << 8, // Section ID is the 1 based segment index shifted right by 8 bits as not to collide with any of the 256 section IDs that are possible |
| 360 | segment_name, // Name of this section |
| 361 | eSectionTypeContainer, // This section is a container of other sections. |
| 362 | sect64.addr, // File VM address == addresses as they are found in the object file |
| 363 | sect64.size, // VM size in bytes of this section |
| 364 | sect64.offset, // Offset to the data for this section in the file |
| 365 | sect64.offset ? sect64.size : 0, // Size in bytes of this section as found in the the file |
| 366 | load_cmd.flags)); // Flags for this section |
| 367 | segment_sp->SetIsFake(true); |
| 368 | m_sections_ap->AddSection(segment_sp); |
| 369 | } |
| 370 | } |
| 371 | assert (segment_sp.get()); |
| 372 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 373 | uint32_t mach_sect_type = sect64.flags & SectionFlagMaskSectionType; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 374 | static ConstString g_sect_name_objc_data ("__objc_data"); |
| 375 | static ConstString g_sect_name_objc_msgrefs ("__objc_msgrefs"); |
| 376 | static ConstString g_sect_name_objc_selrefs ("__objc_selrefs"); |
| 377 | static ConstString g_sect_name_objc_classrefs ("__objc_classrefs"); |
| 378 | static ConstString g_sect_name_objc_superrefs ("__objc_superrefs"); |
| 379 | static ConstString g_sect_name_objc_const ("__objc_const"); |
| 380 | static ConstString g_sect_name_objc_classlist ("__objc_classlist"); |
| 381 | static ConstString g_sect_name_cfstring ("__cfstring"); |
Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 382 | |
| 383 | static ConstString g_sect_name_dwarf_debug_abbrev ("__debug_abbrev"); |
| 384 | static ConstString g_sect_name_dwarf_debug_aranges ("__debug_aranges"); |
| 385 | static ConstString g_sect_name_dwarf_debug_frame ("__debug_frame"); |
| 386 | static ConstString g_sect_name_dwarf_debug_info ("__debug_info"); |
| 387 | static ConstString g_sect_name_dwarf_debug_line ("__debug_line"); |
| 388 | static ConstString g_sect_name_dwarf_debug_loc ("__debug_loc"); |
| 389 | static ConstString g_sect_name_dwarf_debug_macinfo ("__debug_macinfo"); |
| 390 | static ConstString g_sect_name_dwarf_debug_pubnames ("__debug_pubnames"); |
| 391 | static ConstString g_sect_name_dwarf_debug_pubtypes ("__debug_pubtypes"); |
| 392 | static ConstString g_sect_name_dwarf_debug_ranges ("__debug_ranges"); |
| 393 | static ConstString g_sect_name_dwarf_debug_str ("__debug_str"); |
| 394 | static ConstString g_sect_name_eh_frame ("__eh_frame"); |
| 395 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 396 | SectionType sect_type = eSectionTypeOther; |
| 397 | |
Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 398 | |
| 399 | if (section_name == g_sect_name_dwarf_debug_abbrev) |
| 400 | sect_type = eSectionTypeDWARFDebugAbbrev; |
| 401 | else if (section_name == g_sect_name_dwarf_debug_aranges) |
| 402 | sect_type = eSectionTypeDWARFDebugAranges; |
| 403 | else if (section_name == g_sect_name_dwarf_debug_frame) |
| 404 | sect_type = eSectionTypeDWARFDebugFrame; |
| 405 | else if (section_name == g_sect_name_dwarf_debug_info) |
| 406 | sect_type = eSectionTypeDWARFDebugInfo; |
| 407 | else if (section_name == g_sect_name_dwarf_debug_line) |
| 408 | sect_type = eSectionTypeDWARFDebugLine; |
| 409 | else if (section_name == g_sect_name_dwarf_debug_loc) |
| 410 | sect_type = eSectionTypeDWARFDebugLoc; |
| 411 | else if (section_name == g_sect_name_dwarf_debug_macinfo) |
| 412 | sect_type = eSectionTypeDWARFDebugMacInfo; |
| 413 | else if (section_name == g_sect_name_dwarf_debug_pubnames) |
| 414 | sect_type = eSectionTypeDWARFDebugPubNames; |
| 415 | else if (section_name == g_sect_name_dwarf_debug_pubtypes) |
| 416 | sect_type = eSectionTypeDWARFDebugPubTypes; |
| 417 | else if (section_name == g_sect_name_dwarf_debug_ranges) |
| 418 | sect_type = eSectionTypeDWARFDebugRanges; |
| 419 | else if (section_name == g_sect_name_dwarf_debug_str) |
| 420 | sect_type = eSectionTypeDWARFDebugStr; |
| 421 | else if (section_name == g_sect_name_objc_selrefs) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 422 | sect_type = eSectionTypeDataCStringPointers; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 423 | else if (section_name == g_sect_name_objc_msgrefs) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 424 | sect_type = eSectionTypeDataObjCMessageRefs; |
Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 425 | else if (section_name == g_sect_name_eh_frame) |
| 426 | sect_type = eSectionTypeEHFrame; |
| 427 | else if (section_name == g_sect_name_cfstring) |
| 428 | sect_type = eSectionTypeDataObjCCFStrings; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 429 | else if (section_name == g_sect_name_objc_data || |
| 430 | section_name == g_sect_name_objc_classrefs || |
| 431 | section_name == g_sect_name_objc_superrefs || |
| 432 | section_name == g_sect_name_objc_const || |
| 433 | section_name == g_sect_name_objc_classlist) |
| 434 | { |
| 435 | sect_type = eSectionTypeDataPointers; |
| 436 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 437 | |
| 438 | if (sect_type == eSectionTypeOther) |
| 439 | { |
| 440 | switch (mach_sect_type) |
| 441 | { |
| 442 | // TODO: categorize sections by other flags for regular sections |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 443 | case SectionTypeRegular: sect_type = eSectionTypeOther; break; |
| 444 | case SectionTypeZeroFill: sect_type = eSectionTypeZeroFill; break; |
| 445 | case SectionTypeCStringLiterals: sect_type = eSectionTypeDataCString; break; // section with only literal C strings |
| 446 | case SectionType4ByteLiterals: sect_type = eSectionTypeData4; break; // section with only 4 byte literals |
| 447 | case SectionType8ByteLiterals: sect_type = eSectionTypeData8; break; // section with only 8 byte literals |
| 448 | case SectionTypeLiteralPointers: sect_type = eSectionTypeDataPointers; break; // section with only pointers to literals |
| 449 | case SectionTypeNonLazySymbolPointers: sect_type = eSectionTypeDataPointers; break; // section with only non-lazy symbol pointers |
| 450 | case SectionTypeLazySymbolPointers: sect_type = eSectionTypeDataPointers; break; // section with only lazy symbol pointers |
| 451 | case SectionTypeSymbolStubs: sect_type = eSectionTypeCode; break; // section with only symbol stubs, byte size of stub in the reserved2 field |
| 452 | case SectionTypeModuleInitFunctionPointers: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for initialization |
| 453 | case SectionTypeModuleTermFunctionPointers: sect_type = eSectionTypeDataPointers; break; // section with only function pointers for termination |
| 454 | case SectionTypeCoalesced: sect_type = eSectionTypeOther; break; |
| 455 | case SectionTypeZeroFillLarge: sect_type = eSectionTypeZeroFill; break; |
| 456 | case SectionTypeInterposing: sect_type = eSectionTypeCode; break; // section with only pairs of function pointers for interposing |
| 457 | case SectionType16ByteLiterals: sect_type = eSectionTypeData16; break; // section with only 16 byte literals |
| 458 | case SectionTypeDTraceObjectFormat: sect_type = eSectionTypeDebug; break; |
| 459 | case SectionTypeLazyDylibSymbolPointers: sect_type = eSectionTypeDataPointers; break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 460 | default: break; |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | SectionSP section_sp(new Section(segment_sp.get(), |
| 465 | GetModule(), |
| 466 | ++sectID, |
| 467 | section_name, |
| 468 | sect_type, |
| 469 | sect64.addr - segment_sp->GetFileAddress(), |
| 470 | sect64.size, |
| 471 | sect64.offset, |
| 472 | sect64.offset == 0 ? 0 : sect64.size, |
| 473 | sect64.flags)); |
| 474 | segment_sp->GetChildren().AddSection(section_sp); |
| 475 | |
| 476 | if (segment_sp->IsFake()) |
| 477 | { |
| 478 | segment_sp.reset(); |
| 479 | segment_name.Clear(); |
| 480 | } |
| 481 | } |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 482 | if (m_header.filetype == HeaderFileTypeDSYM) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 483 | { |
| 484 | if (first_segment_sectID <= sectID) |
| 485 | { |
| 486 | lldb::user_id_t sect_uid; |
| 487 | for (sect_uid = first_segment_sectID; sect_uid <= sectID; ++sect_uid) |
| 488 | { |
| 489 | SectionSP curr_section_sp(segment_sp->GetChildren().FindSectionByID (sect_uid)); |
| 490 | SectionSP next_section_sp; |
| 491 | if (sect_uid + 1 <= sectID) |
| 492 | next_section_sp = segment_sp->GetChildren().FindSectionByID (sect_uid+1); |
| 493 | |
| 494 | if (curr_section_sp.get()) |
| 495 | { |
| 496 | if (curr_section_sp->GetByteSize() == 0) |
| 497 | { |
| 498 | if (next_section_sp.get() != NULL) |
| 499 | curr_section_sp->SetByteSize ( next_section_sp->GetFileAddress() - curr_section_sp->GetFileAddress() ); |
| 500 | else |
| 501 | curr_section_sp->SetByteSize ( load_cmd.vmsize ); |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | } |
| 508 | } |
| 509 | } |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 510 | else if (load_cmd.cmd == LoadCommandDynamicSymtabInfo) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 511 | { |
| 512 | m_dysymtab.cmd = load_cmd.cmd; |
| 513 | m_dysymtab.cmdsize = load_cmd.cmdsize; |
| 514 | m_data.GetU32 (&offset, &m_dysymtab.ilocalsym, (sizeof(m_dysymtab) / sizeof(uint32_t)) - 2); |
| 515 | } |
| 516 | |
| 517 | offset = load_cmd_offset + load_cmd.cmdsize; |
| 518 | } |
| 519 | // if (dump_sections) |
| 520 | // { |
| 521 | // StreamFile s(stdout); |
| 522 | // m_sections_ap->Dump(&s, true); |
| 523 | // } |
| 524 | return sectID; // Return the number of sections we registered with the module |
| 525 | } |
| 526 | |
| 527 | class MachSymtabSectionInfo |
| 528 | { |
| 529 | public: |
| 530 | |
| 531 | MachSymtabSectionInfo (SectionList *section_list) : |
| 532 | m_section_list (section_list), |
| 533 | m_section_infos() |
| 534 | { |
| 535 | // Get the number of sections down to a depth of 1 to include |
| 536 | // all segments and their sections, but no other sections that |
| 537 | // may be added for debug map or |
| 538 | m_section_infos.resize(section_list->GetNumSections(1)); |
| 539 | } |
| 540 | |
| 541 | |
| 542 | Section * |
| 543 | GetSection (uint8_t n_sect, addr_t file_addr) |
| 544 | { |
| 545 | if (n_sect == 0) |
| 546 | return NULL; |
| 547 | if (n_sect < m_section_infos.size()) |
| 548 | { |
| 549 | if (m_section_infos[n_sect].section == NULL) |
| 550 | { |
| 551 | Section *section = m_section_list->FindSectionByID (n_sect).get(); |
| 552 | m_section_infos[n_sect].section = section; |
| 553 | assert (section != NULL); |
| 554 | m_section_infos[n_sect].vm_range.SetBaseAddress (section->GetFileAddress()); |
| 555 | m_section_infos[n_sect].vm_range.SetByteSize (section->GetByteSize()); |
| 556 | } |
| 557 | if (m_section_infos[n_sect].vm_range.Contains(file_addr)) |
| 558 | return m_section_infos[n_sect].section; |
| 559 | } |
| 560 | return m_section_list->FindSectionContainingFileAddress(file_addr).get(); |
| 561 | } |
| 562 | |
| 563 | protected: |
| 564 | struct SectionInfo |
| 565 | { |
| 566 | SectionInfo () : |
| 567 | vm_range(), |
| 568 | section (NULL) |
| 569 | { |
| 570 | } |
| 571 | |
| 572 | VMRange vm_range; |
| 573 | Section *section; |
| 574 | }; |
| 575 | SectionList *m_section_list; |
| 576 | std::vector<SectionInfo> m_section_infos; |
| 577 | }; |
| 578 | |
| 579 | |
| 580 | |
| 581 | size_t |
| 582 | ObjectFileMachO::ParseSymtab (bool minimize) |
| 583 | { |
| 584 | Timer scoped_timer(__PRETTY_FUNCTION__, |
| 585 | "ObjectFileMachO::ParseSymtab () module = %s", |
| 586 | m_file.GetFilename().AsCString("")); |
| 587 | struct symtab_command symtab_load_command; |
| 588 | uint32_t offset = MachHeaderSizeFromMagic(m_header.magic); |
| 589 | uint32_t i; |
| 590 | for (i=0; i<m_header.ncmds; ++i) |
| 591 | { |
| 592 | const uint32_t cmd_offset = offset; |
| 593 | // Read in the load command and load command size |
| 594 | if (m_data.GetU32(&offset, &symtab_load_command, 2) == NULL) |
| 595 | break; |
| 596 | // Watch for the symbol table load command |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 597 | if (symtab_load_command.cmd == LoadCommandSymtab) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 598 | { |
| 599 | // Read in the rest of the symtab load command |
Jason Molenda | ea84e76 | 2010-07-06 22:38:03 +0000 | [diff] [blame] | 600 | if (m_data.GetU32(&offset, &symtab_load_command.symoff, 4)) // fill in symoff, nsyms, stroff, strsize fields |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 601 | { |
| 602 | Symtab *symtab = m_symtab_ap.get(); |
| 603 | SectionList *section_list = GetSectionList(); |
| 604 | assert(section_list); |
| 605 | const size_t addr_size = m_data.GetAddressByteSize(); |
| 606 | const ByteOrder endian = m_data.GetByteOrder(); |
| 607 | bool bit_width_32 = addr_size == 4; |
| 608 | const size_t nlist_size = bit_width_32 ? sizeof(struct nlist) : sizeof(struct nlist_64); |
| 609 | |
| 610 | DataBufferSP symtab_data_sp(m_file.ReadFileContents(m_offset + symtab_load_command.symoff, symtab_load_command.nsyms * nlist_size)); |
| 611 | DataBufferSP strtab_data_sp(m_file.ReadFileContents(m_offset + symtab_load_command.stroff, symtab_load_command.strsize)); |
| 612 | |
| 613 | const char *strtab_data = (const char *)strtab_data_sp->GetBytes(); |
| 614 | // DataExtractor symtab_data(symtab_data_sp, endian, addr_size); |
| 615 | // DataExtractor strtab_data(strtab_data_sp, endian, addr_size); |
| 616 | |
| 617 | static ConstString g_segment_name_TEXT ("__TEXT"); |
| 618 | static ConstString g_segment_name_DATA ("__DATA"); |
| 619 | static ConstString g_segment_name_OBJC ("__OBJC"); |
| 620 | static ConstString g_section_name_eh_frame ("__eh_frame"); |
| 621 | SectionSP text_section_sp(section_list->FindSectionByName(g_segment_name_TEXT)); |
| 622 | SectionSP data_section_sp(section_list->FindSectionByName(g_segment_name_DATA)); |
| 623 | SectionSP objc_section_sp(section_list->FindSectionByName(g_segment_name_OBJC)); |
| 624 | SectionSP eh_frame_section_sp; |
| 625 | if (text_section_sp.get()) |
| 626 | eh_frame_section_sp = text_section_sp->GetChildren().FindSectionByName (g_section_name_eh_frame); |
| 627 | else |
| 628 | eh_frame_section_sp = section_list->FindSectionByName (g_section_name_eh_frame); |
| 629 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 630 | uint8_t TEXT_eh_frame_sectID = eh_frame_section_sp.get() ? eh_frame_section_sp->GetID() : NListSectionNoSection; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 631 | //uint32_t symtab_offset = 0; |
| 632 | const uint8_t* nlist_data = symtab_data_sp->GetBytes(); |
| 633 | assert (symtab_data_sp->GetByteSize()/nlist_size >= symtab_load_command.nsyms); |
| 634 | |
| 635 | |
| 636 | if (endian != eByteOrderHost) |
| 637 | { |
| 638 | // ... |
| 639 | assert (!"UNIMPLEMENTED: Swap all nlist entries"); |
| 640 | } |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 641 | uint32_t N_SO_index = UINT32_MAX; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 642 | |
| 643 | MachSymtabSectionInfo section_info (section_list); |
| 644 | std::vector<uint32_t> N_FUN_indexes; |
| 645 | std::vector<uint32_t> N_NSYM_indexes; |
| 646 | std::vector<uint32_t> N_INCL_indexes; |
| 647 | std::vector<uint32_t> N_BRAC_indexes; |
| 648 | std::vector<uint32_t> N_COMM_indexes; |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 649 | typedef std::map <uint64_t, uint32_t> ValueToSymbolIndexMap; |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 650 | typedef std::map <uint32_t, uint32_t> NListIndexToSymbolIndexMap; |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 651 | ValueToSymbolIndexMap N_FUN_addr_to_sym_idx; |
| 652 | ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx; |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 653 | // Any symbols that get merged into another will get an entry |
| 654 | // in this map so we know |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 655 | NListIndexToSymbolIndexMap m_nlist_idx_to_sym_idx; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 656 | uint32_t nlist_idx = 0; |
| 657 | Symbol *symbol_ptr = NULL; |
| 658 | |
| 659 | uint32_t sym_idx = 0; |
| 660 | Symbol *sym = symtab->Resize (symtab_load_command.nsyms + m_dysymtab.nindirectsyms); |
| 661 | uint32_t num_syms = symtab->GetNumSymbols(); |
| 662 | |
| 663 | //symtab->Reserve (symtab_load_command.nsyms + m_dysymtab.nindirectsyms); |
| 664 | for (nlist_idx = 0; nlist_idx < symtab_load_command.nsyms; ++nlist_idx) |
| 665 | { |
| 666 | struct nlist_64 nlist; |
| 667 | if (bit_width_32) |
| 668 | { |
| 669 | struct nlist* nlist32_ptr = (struct nlist*)(nlist_data + (nlist_idx * nlist_size)); |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 670 | nlist.n_strx = nlist32_ptr->n_strx; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 671 | nlist.n_type = nlist32_ptr->n_type; |
| 672 | nlist.n_sect = nlist32_ptr->n_sect; |
| 673 | nlist.n_desc = nlist32_ptr->n_desc; |
| 674 | nlist.n_value = nlist32_ptr->n_value; |
| 675 | } |
| 676 | else |
| 677 | { |
| 678 | nlist = *((struct nlist_64*)(nlist_data + (nlist_idx * nlist_size))); |
| 679 | } |
| 680 | |
| 681 | SymbolType type = eSymbolTypeInvalid; |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 682 | const char* symbol_name = &strtab_data[nlist.n_strx]; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 683 | if (symbol_name[0] == '\0') |
| 684 | symbol_name = NULL; |
| 685 | Section* symbol_section = NULL; |
| 686 | bool add_nlist = true; |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 687 | bool is_debug = ((nlist.n_type & NlistMaskStab) != 0); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 688 | |
| 689 | assert (sym_idx < num_syms); |
| 690 | |
| 691 | sym[sym_idx].SetDebug (is_debug); |
| 692 | |
| 693 | if (is_debug) |
| 694 | { |
| 695 | switch (nlist.n_type) |
| 696 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 697 | case StabGlobalSymbol: |
| 698 | // N_GSYM -- global symbol: name,,NO_SECT,type,0 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 699 | // Sometimes the N_GSYM value contains the address. |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 700 | sym[sym_idx].SetExternal(true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 701 | if (nlist.n_value != 0) |
| 702 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 703 | type = eSymbolTypeData; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 704 | break; |
| 705 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 706 | case StabFunctionName: |
| 707 | // N_FNAME -- procedure name (f77 kludge): name,,NO_SECT,0,0 |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 708 | type = eSymbolTypeCompiler; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 709 | break; |
| 710 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 711 | case StabFunction: |
| 712 | // N_FUN -- procedure: name,,n_sect,linenumber,address |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 713 | if (symbol_name) |
| 714 | { |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 715 | type = eSymbolTypeCode; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 716 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 717 | |
| 718 | N_FUN_addr_to_sym_idx[nlist.n_value] = sym_idx; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 719 | // We use the current number of symbols in the symbol table in lieu of |
| 720 | // using nlist_idx in case we ever start trimming entries out |
| 721 | N_FUN_indexes.push_back(sym_idx); |
| 722 | } |
| 723 | else |
| 724 | { |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 725 | type = eSymbolTypeCompiler; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 726 | |
| 727 | if ( !N_FUN_indexes.empty() ) |
| 728 | { |
| 729 | // Copy the size of the function into the original STAB entry so we don't have |
| 730 | // to hunt for it later |
| 731 | symtab->SymbolAtIndex(N_FUN_indexes.back())->SetByteSize(nlist.n_value); |
| 732 | N_FUN_indexes.pop_back(); |
Jason Molenda | ea84e76 | 2010-07-06 22:38:03 +0000 | [diff] [blame] | 733 | // We don't really need the end function STAB as it contains the size which |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 734 | // we already placed with the original symbol, so don't add it if we want a |
| 735 | // minimal symbol table |
| 736 | if (minimize) |
| 737 | add_nlist = false; |
| 738 | } |
| 739 | } |
| 740 | break; |
| 741 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 742 | case StabStaticSymbol: |
| 743 | // N_STSYM -- static symbol: name,,n_sect,type,address |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 744 | N_STSYM_addr_to_sym_idx[nlist.n_value] = sym_idx; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 745 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 746 | type = eSymbolTypeData; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 747 | break; |
| 748 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 749 | case StabLocalCommon: |
| 750 | // N_LCSYM -- .lcomm symbol: name,,n_sect,type,address |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 751 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
| 752 | type = eSymbolTypeCommonBlock; |
| 753 | break; |
| 754 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 755 | case StabBeginSymbol: |
| 756 | // N_BNSYM |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 757 | // We use the current number of symbols in the symbol table in lieu of |
| 758 | // using nlist_idx in case we ever start trimming entries out |
| 759 | if (minimize) |
| 760 | { |
| 761 | // Skip these if we want minimal symbol tables |
| 762 | add_nlist = false; |
| 763 | } |
| 764 | else |
| 765 | { |
| 766 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
| 767 | N_NSYM_indexes.push_back(sym_idx); |
| 768 | type = eSymbolTypeScopeBegin; |
| 769 | } |
| 770 | break; |
| 771 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 772 | case StabEndSymbol: |
| 773 | // N_ENSYM |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 774 | // Set the size of the N_BNSYM to the terminating index of this N_ENSYM |
| 775 | // so that we can always skip the entire symbol if we need to navigate |
| 776 | // more quickly at the source level when parsing STABS |
| 777 | if (minimize) |
| 778 | { |
| 779 | // Skip these if we want minimal symbol tables |
| 780 | add_nlist = false; |
| 781 | } |
| 782 | else |
| 783 | { |
| 784 | if ( !N_NSYM_indexes.empty() ) |
| 785 | { |
| 786 | symbol_ptr = symtab->SymbolAtIndex(N_NSYM_indexes.back()); |
| 787 | symbol_ptr->SetByteSize(sym_idx + 1); |
| 788 | symbol_ptr->SetSizeIsSibling(true); |
| 789 | N_NSYM_indexes.pop_back(); |
| 790 | } |
| 791 | type = eSymbolTypeScopeEnd; |
| 792 | } |
| 793 | break; |
| 794 | |
| 795 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 796 | case StabSourceFileOptions: |
| 797 | // N_OPT - emitted with gcc2_compiled and in gcc source |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 798 | type = eSymbolTypeCompiler; |
| 799 | break; |
| 800 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 801 | case StabRegisterSymbol: |
| 802 | // N_RSYM - register sym: name,,NO_SECT,type,register |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 803 | type = eSymbolTypeVariable; |
| 804 | break; |
| 805 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 806 | case StabSourceLine: |
| 807 | // N_SLINE - src line: 0,,n_sect,linenumber,address |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 808 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
| 809 | type = eSymbolTypeLineEntry; |
| 810 | break; |
| 811 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 812 | case StabStructureType: |
| 813 | // N_SSYM - structure elt: name,,NO_SECT,type,struct_offset |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 814 | type = eSymbolTypeVariableType; |
| 815 | break; |
| 816 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 817 | case StabSourceFileName: |
| 818 | // N_SO - source file name |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 819 | type = eSymbolTypeSourceFile; |
| 820 | if (symbol_name == NULL) |
| 821 | { |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 822 | if (minimize) |
| 823 | add_nlist = false; |
| 824 | if (N_SO_index != UINT32_MAX) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 825 | { |
| 826 | // Set the size of the N_SO to the terminating index of this N_SO |
| 827 | // so that we can always skip the entire N_SO if we need to navigate |
| 828 | // more quickly at the source level when parsing STABS |
| 829 | symbol_ptr = symtab->SymbolAtIndex(N_SO_index); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 830 | symbol_ptr->SetByteSize(sym_idx + (minimize ? 0 : 1)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 831 | symbol_ptr->SetSizeIsSibling(true); |
| 832 | } |
| 833 | N_NSYM_indexes.clear(); |
| 834 | N_INCL_indexes.clear(); |
| 835 | N_BRAC_indexes.clear(); |
| 836 | N_COMM_indexes.clear(); |
| 837 | N_FUN_indexes.clear(); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 838 | N_SO_index = UINT32_MAX; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 839 | } |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 840 | else |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 841 | { |
| 842 | // We use the current number of symbols in the symbol table in lieu of |
| 843 | // using nlist_idx in case we ever start trimming entries out |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 844 | if (symbol_name[0] == '/') |
| 845 | N_SO_index = sym_idx; |
| 846 | else if (minimize && (N_SO_index == sym_idx - 1)) |
| 847 | { |
| 848 | const char *so_path = sym[sym_idx - 1].GetMangled().GetDemangledName().AsCString(); |
| 849 | if (so_path && so_path[0]) |
| 850 | { |
| 851 | std::string full_so_path (so_path); |
| 852 | if (*full_so_path.rbegin() != '/') |
| 853 | full_so_path += '/'; |
| 854 | full_so_path += symbol_name; |
| 855 | sym[sym_idx - 1].GetMangled().SetValue(full_so_path.c_str(), false); |
| 856 | add_nlist = false; |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 857 | m_nlist_idx_to_sym_idx[nlist_idx] = sym_idx - 1; |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 858 | } |
| 859 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 860 | } |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 861 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 862 | break; |
| 863 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 864 | case StabObjectFileName: |
| 865 | // N_OSO - object file name: name,,0,0,st_mtime |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 866 | type = eSymbolTypeObjectFile; |
| 867 | break; |
| 868 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 869 | case StabLocalSymbol: |
| 870 | // N_LSYM - local sym: name,,NO_SECT,type,offset |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 871 | type = eSymbolTypeLocal; |
| 872 | break; |
| 873 | |
| 874 | //---------------------------------------------------------------------- |
| 875 | // INCL scopes |
| 876 | //---------------------------------------------------------------------- |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 877 | case StabBeginIncludeFileName: |
| 878 | // N_BINCL - include file beginning: name,,NO_SECT,0,sum |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 879 | // We use the current number of symbols in the symbol table in lieu of |
| 880 | // using nlist_idx in case we ever start trimming entries out |
| 881 | N_INCL_indexes.push_back(sym_idx); |
| 882 | type = eSymbolTypeScopeBegin; |
| 883 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 884 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 885 | case StabEndIncludeFile: |
| 886 | // N_EINCL - include file end: name,,NO_SECT,0,0 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 887 | // Set the size of the N_BINCL to the terminating index of this N_EINCL |
| 888 | // so that we can always skip the entire symbol if we need to navigate |
| 889 | // more quickly at the source level when parsing STABS |
| 890 | if ( !N_INCL_indexes.empty() ) |
| 891 | { |
| 892 | symbol_ptr = symtab->SymbolAtIndex(N_INCL_indexes.back()); |
| 893 | symbol_ptr->SetByteSize(sym_idx + 1); |
| 894 | symbol_ptr->SetSizeIsSibling(true); |
| 895 | N_INCL_indexes.pop_back(); |
| 896 | } |
| 897 | type = eSymbolTypeScopeEnd; |
| 898 | break; |
| 899 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 900 | case StabIncludeFileName: |
| 901 | // N_SOL - #included file name: name,,n_sect,0,address |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 902 | type = eSymbolTypeHeaderFile; |
Greg Clayton | 49bd1c8 | 2010-09-07 17:36:17 +0000 | [diff] [blame] | 903 | |
| 904 | // We currently don't use the header files on darwin |
| 905 | if (minimize) |
| 906 | add_nlist = false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 907 | break; |
| 908 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 909 | case StabCompilerParameters: |
| 910 | // N_PARAMS - compiler parameters: name,,NO_SECT,0,0 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 911 | type = eSymbolTypeCompiler; |
| 912 | break; |
| 913 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 914 | case StabCompilerVersion: |
| 915 | // N_VERSION - compiler version: name,,NO_SECT,0,0 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 916 | type = eSymbolTypeCompiler; |
| 917 | break; |
| 918 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 919 | case StabCompilerOptLevel: |
| 920 | // N_OLEVEL - compiler -O level: name,,NO_SECT,0,0 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 921 | type = eSymbolTypeCompiler; |
| 922 | break; |
| 923 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 924 | case StabParameter: |
| 925 | // N_PSYM - parameter: name,,NO_SECT,type,offset |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 926 | type = eSymbolTypeVariable; |
| 927 | break; |
| 928 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 929 | case StabAlternateEntry: |
| 930 | // N_ENTRY - alternate entry: name,,n_sect,linenumber,address |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 931 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
| 932 | type = eSymbolTypeLineEntry; |
| 933 | break; |
| 934 | |
| 935 | //---------------------------------------------------------------------- |
| 936 | // Left and Right Braces |
| 937 | //---------------------------------------------------------------------- |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 938 | case StabLeftBracket: |
| 939 | // N_LBRAC - left bracket: 0,,NO_SECT,nesting level,address |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 940 | // We use the current number of symbols in the symbol table in lieu of |
| 941 | // using nlist_idx in case we ever start trimming entries out |
| 942 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
| 943 | N_BRAC_indexes.push_back(sym_idx); |
| 944 | type = eSymbolTypeScopeBegin; |
| 945 | break; |
| 946 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 947 | case StabRightBracket: |
| 948 | // N_RBRAC - right bracket: 0,,NO_SECT,nesting level,address |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 949 | // Set the size of the N_LBRAC to the terminating index of this N_RBRAC |
| 950 | // so that we can always skip the entire symbol if we need to navigate |
| 951 | // more quickly at the source level when parsing STABS |
| 952 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
| 953 | if ( !N_BRAC_indexes.empty() ) |
| 954 | { |
| 955 | symbol_ptr = symtab->SymbolAtIndex(N_BRAC_indexes.back()); |
| 956 | symbol_ptr->SetByteSize(sym_idx + 1); |
| 957 | symbol_ptr->SetSizeIsSibling(true); |
| 958 | N_BRAC_indexes.pop_back(); |
| 959 | } |
| 960 | type = eSymbolTypeScopeEnd; |
| 961 | break; |
| 962 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 963 | case StabDeletedIncludeFile: |
| 964 | // N_EXCL - deleted include file: name,,NO_SECT,0,sum |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 965 | type = eSymbolTypeHeaderFile; |
| 966 | break; |
| 967 | |
| 968 | //---------------------------------------------------------------------- |
| 969 | // COMM scopes |
| 970 | //---------------------------------------------------------------------- |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 971 | case StabBeginCommon: |
| 972 | // N_BCOMM - begin common: name,,NO_SECT,0,0 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 973 | // We use the current number of symbols in the symbol table in lieu of |
| 974 | // using nlist_idx in case we ever start trimming entries out |
| 975 | type = eSymbolTypeScopeBegin; |
| 976 | N_COMM_indexes.push_back(sym_idx); |
| 977 | break; |
| 978 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 979 | case StabEndCommonLocal: |
| 980 | // N_ECOML - end common (local name): 0,,n_sect,0,address |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 981 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
| 982 | // Fall through |
| 983 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 984 | case StabEndCommon: |
| 985 | // N_ECOMM - end common: name,,n_sect,0,0 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 986 | // Set the size of the N_BCOMM to the terminating index of this N_ECOMM/N_ECOML |
| 987 | // so that we can always skip the entire symbol if we need to navigate |
| 988 | // more quickly at the source level when parsing STABS |
| 989 | if ( !N_COMM_indexes.empty() ) |
| 990 | { |
| 991 | symbol_ptr = symtab->SymbolAtIndex(N_COMM_indexes.back()); |
| 992 | symbol_ptr->SetByteSize(sym_idx + 1); |
| 993 | symbol_ptr->SetSizeIsSibling(true); |
| 994 | N_COMM_indexes.pop_back(); |
| 995 | } |
| 996 | type = eSymbolTypeScopeEnd; |
| 997 | break; |
| 998 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 999 | case StabLength: |
| 1000 | // N_LENG - second stab entry with length information |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1001 | type = eSymbolTypeAdditional; |
| 1002 | break; |
| 1003 | |
| 1004 | default: break; |
| 1005 | } |
| 1006 | } |
| 1007 | else |
| 1008 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1009 | //uint8_t n_pext = NlistMaskPrivateExternal & nlist.n_type; |
| 1010 | uint8_t n_type = NlistMaskType & nlist.n_type; |
| 1011 | sym[sym_idx].SetExternal((NlistMaskExternal & nlist.n_type) != 0); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1012 | |
| 1013 | if (symbol_name && ::strstr (symbol_name, ".objc") == symbol_name) |
| 1014 | { |
| 1015 | type = eSymbolTypeRuntime; |
| 1016 | } |
| 1017 | else |
| 1018 | { |
| 1019 | switch (n_type) |
| 1020 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1021 | case NListTypeIndirect: // N_INDR - Fall through |
| 1022 | case NListTypePreboundUndefined:// N_PBUD - Fall through |
| 1023 | case NListTypeUndefined: // N_UNDF |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1024 | type = eSymbolTypeExtern; |
| 1025 | break; |
| 1026 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1027 | case NListTypeAbsolute: // N_ABS |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1028 | type = eSymbolTypeAbsolute; |
| 1029 | break; |
| 1030 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1031 | case NListTypeSection: // N_SECT |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1032 | symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); |
| 1033 | |
| 1034 | assert(symbol_section != NULL); |
| 1035 | if (TEXT_eh_frame_sectID == nlist.n_sect) |
| 1036 | { |
| 1037 | type = eSymbolTypeException; |
| 1038 | } |
| 1039 | else |
| 1040 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1041 | uint32_t section_type = symbol_section->GetAllFlagBits() & SectionFlagMaskSectionType; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1042 | |
| 1043 | switch (section_type) |
| 1044 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1045 | case SectionTypeRegular: break; // regular section |
| 1046 | //case SectionTypeZeroFill: type = eSymbolTypeData; break; // zero fill on demand section |
| 1047 | case SectionTypeCStringLiterals: type = eSymbolTypeData; break; // section with only literal C strings |
| 1048 | case SectionType4ByteLiterals: type = eSymbolTypeData; break; // section with only 4 byte literals |
| 1049 | case SectionType8ByteLiterals: type = eSymbolTypeData; break; // section with only 8 byte literals |
| 1050 | case SectionTypeLiteralPointers: type = eSymbolTypeTrampoline; break; // section with only pointers to literals |
| 1051 | case SectionTypeNonLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only non-lazy symbol pointers |
| 1052 | case SectionTypeLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only lazy symbol pointers |
| 1053 | case SectionTypeSymbolStubs: type = eSymbolTypeTrampoline; break; // section with only symbol stubs, byte size of stub in the reserved2 field |
| 1054 | case SectionTypeModuleInitFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for initialization |
| 1055 | case SectionTypeModuleTermFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for termination |
| 1056 | //case SectionTypeCoalesced: type = eSymbolType; break; // section contains symbols that are to be coalesced |
| 1057 | //case SectionTypeZeroFillLarge: type = eSymbolTypeData; break; // zero fill on demand section (that can be larger than 4 gigabytes) |
| 1058 | case SectionTypeInterposing: type = eSymbolTypeTrampoline; break; // section with only pairs of function pointers for interposing |
| 1059 | case SectionType16ByteLiterals: type = eSymbolTypeData; break; // section with only 16 byte literals |
| 1060 | case SectionTypeDTraceObjectFormat: type = eSymbolTypeInstrumentation; break; |
| 1061 | case SectionTypeLazyDylibSymbolPointers: type = eSymbolTypeTrampoline; break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1062 | default: break; |
| 1063 | } |
| 1064 | |
| 1065 | if (type == eSymbolTypeInvalid) |
| 1066 | { |
| 1067 | const char *symbol_sect_name = symbol_section->GetName().AsCString(); |
| 1068 | if (symbol_section->IsDescendant (text_section_sp.get())) |
| 1069 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1070 | if (symbol_section->IsClear(SectionAttrUserPureInstructions | |
| 1071 | SectionAttrUserSelfModifyingCode | |
| 1072 | SectionAttrSytemSomeInstructions)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1073 | type = eSymbolTypeData; |
| 1074 | else |
| 1075 | type = eSymbolTypeCode; |
| 1076 | } |
| 1077 | else |
| 1078 | if (symbol_section->IsDescendant(data_section_sp.get())) |
| 1079 | { |
| 1080 | if (symbol_sect_name && ::strstr (symbol_sect_name, "__objc") == symbol_sect_name) |
| 1081 | { |
| 1082 | type = eSymbolTypeRuntime; |
| 1083 | } |
| 1084 | else |
| 1085 | if (symbol_sect_name && ::strstr (symbol_sect_name, "__gcc_except_tab") == symbol_sect_name) |
| 1086 | { |
| 1087 | type = eSymbolTypeException; |
| 1088 | } |
| 1089 | else |
| 1090 | { |
| 1091 | type = eSymbolTypeData; |
| 1092 | } |
| 1093 | } |
| 1094 | else |
| 1095 | if (symbol_sect_name && ::strstr (symbol_sect_name, "__IMPORT") == symbol_sect_name) |
| 1096 | { |
| 1097 | type = eSymbolTypeTrampoline; |
| 1098 | } |
| 1099 | else |
| 1100 | if (symbol_section->IsDescendant(objc_section_sp.get())) |
| 1101 | { |
| 1102 | type = eSymbolTypeRuntime; |
| 1103 | } |
| 1104 | } |
| 1105 | } |
| 1106 | break; |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1107 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1108 | } |
| 1109 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1110 | if (add_nlist) |
| 1111 | { |
| 1112 | bool symbol_name_is_mangled = false; |
| 1113 | if (symbol_name && symbol_name[0] == '_') |
| 1114 | { |
| 1115 | symbol_name_is_mangled = symbol_name[1] == '_'; |
| 1116 | symbol_name++; // Skip the leading underscore |
| 1117 | } |
| 1118 | uint64_t symbol_value = nlist.n_value; |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1119 | |
| 1120 | if (symbol_name) |
| 1121 | sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1122 | if (is_debug == false) |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1123 | { |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1124 | if (type == eSymbolTypeCode) |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1125 | { |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1126 | // See if we can find a N_FUN entry for any code symbols. |
| 1127 | // If we do find a match, and the name matches, then we |
| 1128 | // can merge the two into just the function symbol to avoid |
| 1129 | // duplicate entries in the symbol table |
| 1130 | ValueToSymbolIndexMap::const_iterator pos = N_FUN_addr_to_sym_idx.find (nlist.n_value); |
| 1131 | if (pos != N_FUN_addr_to_sym_idx.end()) |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1132 | { |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1133 | if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || |
| 1134 | (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) |
| 1135 | { |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1136 | m_nlist_idx_to_sym_idx[nlist_idx] = pos->second; |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1137 | // We just need the flags from the linker symbol, so put these flags |
| 1138 | // into the N_FUN flags to avoid duplicate symbols in the symbol table |
| 1139 | sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); |
| 1140 | sym[sym_idx].Clear(); |
| 1141 | continue; |
| 1142 | } |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1143 | } |
| 1144 | } |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1145 | else if (type == eSymbolTypeData) |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1146 | { |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1147 | // See if we can find a N_STSYM entry for any data symbols. |
| 1148 | // If we do find a match, and the name matches, then we |
| 1149 | // can merge the two into just the Static symbol to avoid |
| 1150 | // duplicate entries in the symbol table |
| 1151 | ValueToSymbolIndexMap::const_iterator pos = N_STSYM_addr_to_sym_idx.find (nlist.n_value); |
| 1152 | if (pos != N_STSYM_addr_to_sym_idx.end()) |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1153 | { |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1154 | if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || |
| 1155 | (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) |
| 1156 | { |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1157 | m_nlist_idx_to_sym_idx[nlist_idx] = pos->second; |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1158 | // We just need the flags from the linker symbol, so put these flags |
| 1159 | // into the N_STSYM flags to avoid duplicate symbols in the symbol table |
| 1160 | sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); |
| 1161 | sym[sym_idx].Clear(); |
| 1162 | continue; |
| 1163 | } |
Greg Clayton | 928d829 | 2010-09-08 16:38:06 +0000 | [diff] [blame] | 1164 | } |
| 1165 | } |
| 1166 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1167 | if (symbol_section != NULL) |
| 1168 | symbol_value -= symbol_section->GetFileAddress(); |
| 1169 | |
| 1170 | sym[sym_idx].SetID (nlist_idx); |
| 1171 | sym[sym_idx].SetType (type); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1172 | sym[sym_idx].GetAddressRangeRef().GetBaseAddress().SetSection (symbol_section); |
| 1173 | sym[sym_idx].GetAddressRangeRef().GetBaseAddress().SetOffset (symbol_value); |
| 1174 | sym[sym_idx].SetFlags (nlist.n_type << 16 | nlist.n_desc); |
| 1175 | |
| 1176 | ++sym_idx; |
| 1177 | } |
| 1178 | else |
| 1179 | { |
| 1180 | sym[sym_idx].Clear(); |
| 1181 | } |
| 1182 | |
| 1183 | } |
| 1184 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1185 | // STAB N_GSYM entries end up having a symbol type eSymbolTypeGlobal and when the symbol value |
| 1186 | // is zero, the address of the global ends up being in a non-STAB entry. Try and fix up all |
| 1187 | // such entries by figuring out what the address for the global is by looking up this non-STAB |
| 1188 | // entry and copying the value into the debug symbol's value to save us the hassle in the |
| 1189 | // debug symbol parser. |
| 1190 | |
| 1191 | Symbol *global_symbol = NULL; |
| 1192 | for (nlist_idx = 0; |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1193 | nlist_idx < symtab_load_command.nsyms && (global_symbol = symtab->FindSymbolWithType (eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, nlist_idx)) != NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1194 | nlist_idx++) |
| 1195 | { |
| 1196 | if (global_symbol->GetValue().GetFileAddress() == 0) |
| 1197 | { |
| 1198 | std::vector<uint32_t> indexes; |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1199 | if (symtab->AppendSymbolIndexesWithName (global_symbol->GetMangled().GetName(), indexes) > 0) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1200 | { |
| 1201 | std::vector<uint32_t>::const_iterator pos; |
| 1202 | std::vector<uint32_t>::const_iterator end = indexes.end(); |
| 1203 | for (pos = indexes.begin(); pos != end; ++pos) |
| 1204 | { |
| 1205 | symbol_ptr = symtab->SymbolAtIndex(*pos); |
| 1206 | if (symbol_ptr != global_symbol && symbol_ptr->IsDebug() == false) |
| 1207 | { |
| 1208 | global_symbol->SetValue(symbol_ptr->GetValue()); |
| 1209 | break; |
| 1210 | } |
| 1211 | } |
| 1212 | } |
| 1213 | } |
| 1214 | } |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1215 | |
| 1216 | // Trim our symbols down to just what we ended up with after |
| 1217 | // removing any symbols. |
| 1218 | if (sym_idx < num_syms) |
| 1219 | { |
| 1220 | num_syms = sym_idx; |
| 1221 | sym = symtab->Resize (num_syms); |
| 1222 | } |
| 1223 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1224 | // Now synthesize indirect symbols |
| 1225 | if (m_dysymtab.nindirectsyms != 0) |
| 1226 | { |
| 1227 | DataBufferSP indirect_symbol_indexes_sp(m_file.ReadFileContents(m_offset + m_dysymtab.indirectsymoff, m_dysymtab.nindirectsyms * 4)); |
| 1228 | |
| 1229 | if (indirect_symbol_indexes_sp && indirect_symbol_indexes_sp->GetByteSize()) |
| 1230 | { |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1231 | NListIndexToSymbolIndexMap::const_iterator end_index_pos = m_nlist_idx_to_sym_idx.end(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1232 | DataExtractor indirect_symbol_index_data (indirect_symbol_indexes_sp, m_data.GetByteOrder(), m_data.GetAddressByteSize()); |
| 1233 | |
| 1234 | for (uint32_t sect_idx = 1; sect_idx < m_mach_sections.size(); ++sect_idx) |
| 1235 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1236 | if ((m_mach_sections[sect_idx].flags & SectionFlagMaskSectionType) == SectionTypeSymbolStubs) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1237 | { |
| 1238 | uint32_t symbol_stub_byte_size = m_mach_sections[sect_idx].reserved2; |
| 1239 | if (symbol_stub_byte_size == 0) |
| 1240 | continue; |
| 1241 | |
| 1242 | const uint32_t num_symbol_stubs = m_mach_sections[sect_idx].size / symbol_stub_byte_size; |
| 1243 | |
| 1244 | if (num_symbol_stubs == 0) |
| 1245 | continue; |
| 1246 | |
| 1247 | const uint32_t symbol_stub_index_offset = m_mach_sections[sect_idx].reserved1; |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1248 | uint32_t synthetic_stub_sym_id = symtab_load_command.nsyms; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1249 | for (uint32_t stub_idx = 0; stub_idx < num_symbol_stubs; ++stub_idx) |
| 1250 | { |
| 1251 | const uint32_t symbol_stub_index = symbol_stub_index_offset + stub_idx; |
| 1252 | const lldb::addr_t symbol_stub_addr = m_mach_sections[sect_idx].addr + (stub_idx * symbol_stub_byte_size); |
| 1253 | uint32_t symbol_stub_offset = symbol_stub_index * 4; |
| 1254 | if (indirect_symbol_index_data.ValidOffsetForDataOfSize(symbol_stub_offset, 4)) |
| 1255 | { |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1256 | const uint32_t stub_sym_id = indirect_symbol_index_data.GetU32 (&symbol_stub_offset); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1257 | |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1258 | NListIndexToSymbolIndexMap::const_iterator index_pos = m_nlist_idx_to_sym_idx.find (stub_sym_id); |
| 1259 | Symbol *stub_symbol = NULL; |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 1260 | if (index_pos != end_index_pos) |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1261 | { |
| 1262 | // We have a remapping from the original nlist index to |
| 1263 | // a current symbol index, so just look this up by index |
| 1264 | stub_symbol = symtab->SymbolAtIndex (index_pos->second); |
| 1265 | } |
| 1266 | else |
| 1267 | { |
| 1268 | // We need to lookup a symbol using the original nlist |
| 1269 | // symbol index since this index is coming from the |
| 1270 | // S_SYMBOL_STUBS |
| 1271 | stub_symbol = symtab->FindSymbolByID (stub_sym_id); |
| 1272 | } |
Greg Clayton | 49bd1c8 | 2010-09-07 17:36:17 +0000 | [diff] [blame] | 1273 | |
| 1274 | assert (stub_symbol); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1275 | if (stub_symbol) |
| 1276 | { |
| 1277 | Address so_addr(symbol_stub_addr, section_list); |
| 1278 | |
| 1279 | if (stub_symbol->GetType() == eSymbolTypeExtern) |
| 1280 | { |
| 1281 | // Change the external symbol into a trampoline that makes sense |
| 1282 | // These symbols were N_UNDF N_EXT, and are useless to us, so we |
| 1283 | // can re-use them so we don't have to make up a synthetic symbol |
| 1284 | // for no good reason. |
| 1285 | stub_symbol->SetType (eSymbolTypeTrampoline); |
| 1286 | stub_symbol->SetExternal (false); |
| 1287 | stub_symbol->GetAddressRangeRef().GetBaseAddress() = so_addr; |
| 1288 | stub_symbol->GetAddressRangeRef().SetByteSize (symbol_stub_byte_size); |
| 1289 | } |
| 1290 | else |
| 1291 | { |
| 1292 | // Make a synthetic symbol to describe the trampoline stub |
| 1293 | if (sym_idx >= num_syms) |
Greg Clayton | 0c38b0d | 2010-09-12 05:25:16 +0000 | [diff] [blame] | 1294 | sym = symtab->Resize (++num_syms); |
| 1295 | sym[sym_idx].SetID (synthetic_stub_sym_id++); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1296 | sym[sym_idx].GetMangled() = stub_symbol->GetMangled(); |
| 1297 | sym[sym_idx].SetType (eSymbolTypeTrampoline); |
| 1298 | sym[sym_idx].SetIsSynthetic (true); |
| 1299 | sym[sym_idx].GetAddressRangeRef().GetBaseAddress() = so_addr; |
| 1300 | sym[sym_idx].GetAddressRangeRef().SetByteSize (symbol_stub_byte_size); |
| 1301 | ++sym_idx; |
| 1302 | } |
| 1303 | } |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | } |
| 1308 | } |
| 1309 | } |
| 1310 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1311 | return symtab->GetNumSymbols(); |
| 1312 | } |
| 1313 | } |
| 1314 | offset = cmd_offset + symtab_load_command.cmdsize; |
| 1315 | } |
| 1316 | return 0; |
| 1317 | } |
| 1318 | |
| 1319 | |
| 1320 | void |
| 1321 | ObjectFileMachO::Dump (Stream *s) |
| 1322 | { |
| 1323 | lldb_private::Mutex::Locker locker(m_mutex); |
| 1324 | s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); |
| 1325 | s->Indent(); |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1326 | if (m_header.magic == HeaderMagic64 || m_header.magic == HeaderMagic64Swapped) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1327 | s->PutCString("ObjectFileMachO64"); |
| 1328 | else |
| 1329 | s->PutCString("ObjectFileMachO32"); |
| 1330 | |
Greg Clayton | 41f9232 | 2010-06-11 03:25:34 +0000 | [diff] [blame] | 1331 | ArchSpec header_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1332 | |
| 1333 | *s << ", file = '" << m_file << "', arch = " << header_arch.AsCString() << "\n"; |
| 1334 | |
| 1335 | if (m_sections_ap.get()) |
| 1336 | m_sections_ap->Dump(s, NULL, true); |
| 1337 | |
| 1338 | if (m_symtab_ap.get()) |
| 1339 | m_symtab_ap->Dump(s, NULL); |
| 1340 | } |
| 1341 | |
| 1342 | |
| 1343 | bool |
| 1344 | ObjectFileMachO::GetUUID (UUID* uuid) |
| 1345 | { |
| 1346 | lldb_private::Mutex::Locker locker(m_mutex); |
| 1347 | struct uuid_command load_cmd; |
| 1348 | uint32_t offset = MachHeaderSizeFromMagic(m_header.magic); |
| 1349 | uint32_t i; |
| 1350 | for (i=0; i<m_header.ncmds; ++i) |
| 1351 | { |
| 1352 | const uint32_t cmd_offset = offset; |
| 1353 | if (m_data.GetU32(&offset, &load_cmd, 2) == NULL) |
| 1354 | break; |
| 1355 | |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1356 | if (load_cmd.cmd == LoadCommandUUID) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1357 | { |
| 1358 | const uint8_t *uuid_bytes = m_data.PeekData(offset, 16); |
| 1359 | if (uuid_bytes) |
| 1360 | { |
| 1361 | uuid->SetBytes (uuid_bytes); |
| 1362 | return true; |
| 1363 | } |
| 1364 | return false; |
| 1365 | } |
| 1366 | offset = cmd_offset + load_cmd.cmdsize; |
| 1367 | } |
| 1368 | return false; |
| 1369 | } |
| 1370 | |
| 1371 | |
| 1372 | uint32_t |
| 1373 | ObjectFileMachO::GetDependentModules (FileSpecList& files) |
| 1374 | { |
| 1375 | lldb_private::Mutex::Locker locker(m_mutex); |
| 1376 | struct load_command load_cmd; |
| 1377 | uint32_t offset = MachHeaderSizeFromMagic(m_header.magic); |
| 1378 | uint32_t count = 0; |
| 1379 | uint32_t i; |
| 1380 | for (i=0; i<m_header.ncmds; ++i) |
| 1381 | { |
| 1382 | const uint32_t cmd_offset = offset; |
| 1383 | if (m_data.GetU32(&offset, &load_cmd, 2) == NULL) |
| 1384 | break; |
| 1385 | |
| 1386 | switch (load_cmd.cmd) |
| 1387 | { |
Greg Clayton | e1a916a | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 1388 | case LoadCommandDylibLoad: |
| 1389 | case LoadCommandDylibLoadWeak: |
| 1390 | case LoadCommandDylibReexport: |
| 1391 | case LoadCommandDynamicLinkerLoad: |
| 1392 | case LoadCommandFixedVMShlibLoad: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1393 | { |
| 1394 | uint32_t name_offset = cmd_offset + m_data.GetU32(&offset); |
| 1395 | const char *path = m_data.PeekCStr(name_offset); |
| 1396 | // Skip any path that starts with '@' since these are usually: |
| 1397 | // @executable_path/.../file |
| 1398 | // @rpath/.../file |
| 1399 | if (path && path[0] != '@') |
| 1400 | { |
| 1401 | FileSpec file_spec(path); |
| 1402 | if (files.AppendIfUnique(file_spec)) |
| 1403 | count++; |
| 1404 | } |
| 1405 | } |
| 1406 | break; |
| 1407 | |
| 1408 | default: |
| 1409 | break; |
| 1410 | } |
| 1411 | offset = cmd_offset + load_cmd.cmdsize; |
| 1412 | } |
| 1413 | return count; |
| 1414 | } |
| 1415 | |
| 1416 | bool |
| 1417 | ObjectFileMachO::GetTargetTriple (ConstString &target_triple) |
| 1418 | { |
| 1419 | lldb_private::Mutex::Locker locker(m_mutex); |
| 1420 | std::string triple(GetModule()->GetArchitecture().AsCString()); |
| 1421 | triple += "-apple-darwin"; |
| 1422 | target_triple.SetCString(triple.c_str()); |
| 1423 | if (target_triple) |
| 1424 | return true; |
| 1425 | return false; |
| 1426 | } |
| 1427 | |
| 1428 | |
| 1429 | //------------------------------------------------------------------ |
| 1430 | // PluginInterface protocol |
| 1431 | //------------------------------------------------------------------ |
| 1432 | const char * |
| 1433 | ObjectFileMachO::GetPluginName() |
| 1434 | { |
| 1435 | return "ObjectFileMachO"; |
| 1436 | } |
| 1437 | |
| 1438 | const char * |
| 1439 | ObjectFileMachO::GetShortPluginName() |
| 1440 | { |
| 1441 | return GetPluginNameStatic(); |
| 1442 | } |
| 1443 | |
| 1444 | uint32_t |
| 1445 | ObjectFileMachO::GetPluginVersion() |
| 1446 | { |
| 1447 | return 1; |
| 1448 | } |
| 1449 | |
| 1450 | void |
| 1451 | ObjectFileMachO::GetPluginCommandHelp (const char *command, Stream *strm) |
| 1452 | { |
| 1453 | } |
| 1454 | |
| 1455 | Error |
| 1456 | ObjectFileMachO::ExecutePluginCommand (Args &command, Stream *strm) |
| 1457 | { |
| 1458 | Error error; |
| 1459 | error.SetErrorString("No plug-in command are currently supported."); |
| 1460 | return error; |
| 1461 | } |
| 1462 | |
| 1463 | Log * |
| 1464 | ObjectFileMachO::EnablePluginLogging (Stream *strm, Args &command) |
| 1465 | { |
| 1466 | return NULL; |
| 1467 | } |
| 1468 | |
| 1469 | |
| 1470 | |
| 1471 | |