summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/MachOObjectFile.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Basic support for parsing Mach-O universal binaries in LLVMObject libraryAlexey Samsonov2013-06-181-2/+6
| | | | llvm-svn: 184191
* Teach llvm-objdump with the -macho parser how to use the data in code tableKevin Enderby2013-06-061-1/+45
| | | | | | | | | | | | | | | from the LC_DATA_IN_CODE load command. And when disassembling print the data in code formatted for the kind of data it and not disassemble those bytes. I added the format specific functionality to the derived class MachOObjectFile since these tables only appears in Mach-O object files. This is my first attempt to modify the libObject stuff so if folks have better suggestions how to fit this in or suggestions on the implementation please let me know. rdar://11791371 llvm-svn: 183424
* Handle relocations that don't point to symbols.Rafael Espindola2013-06-051-8/+5
| | | | | | | | In ELF (as in MachO), not all relocations point to symbols. Represent this properly by using a symbol_iterator instead of a SymbolRef. Update llvm-readobj ELF's dumper to handle relocatios without symbols. llvm-svn: 183284
* Object: Fix Mach-O relocation printing.Ahmed Bougacha2013-05-141-2/+3
| | | | | | | | | There were two problems that made llvm-objdump -r crash: - for non-scattered relocations, the symbol/section index is actually in the (aptly named) symbolnum field. - sections are 1-indexed. llvm-svn: 181843
* Change getRelocationAdditionalInfo to be ELF only.Rafael Espindola2013-05-091-6/+0
| | | | | | | It was only implemented for ELF where it collected the Addend, so this patch also renames it to getRelocationAddend. llvm-svn: 181502
* Fix Addend computation for non external relocations on Macho.Rafael Espindola2013-04-301-0/+10
| | | | llvm-svn: 180790
* Add getSymbolAlignment to the ObjectFile interface.Rafael Espindola2013-04-291-2/+19
| | | | | | | | | | | | | For regular object files this is only meaningful for common symbols. An object file format with direct support for atoms should be able to provide alignment information for all symbols. This replaces getCommonSymbolAlignment and fixes test-common-symbols-alignment.ll on darwin. This also includes a fix to MachOObjectFile::getSymbolFlags. It was marking undefined symbols as common (already tested by existing mcjit tests now that it is used). llvm-svn: 180736
* Use llvm/Object/MachO.h in macho-dumper. Drop the old macho parser.Rafael Espindola2013-04-261-29/+132
| | | | | | | | | | | | | | | | | | | | | For Mach-O there were 2 implementations for parsing object files. A standalone llvm/Object/MachOObject.h and llvm/Object/MachO.h which implements the generic interface in llvm/Object/ObjectFile.h. This patch adds the missing features to MachO.h, moves macho-dump to use MachO.h and removes ObjectFile.h. In addition to making sure that check-all is clean, I checked that the new version produces exactly the same output in all Mach-O files in a llvm+clang build directory (including executables and shared libraries). To test the performance, I ran macho-dump over all the files in a llvm+clang build directory again, but this time redirecting the output to /dev/null. Both the old and new versions take about 4.6 seconds (2.5 user) to finish. llvm-svn: 180624
* Use a pointer as the relocation iterator.Rafael Espindola2013-04-251-24/+29
| | | | | | | | Since the relocation iterator walks only the relocations in one section, we can just use a pointer and avoid fetching information about the section at every reference. llvm-svn: 180262
* Clarify getRelocationAddress x getRelocationOffset a bit.Rafael Espindola2013-04-251-15/+1
| | | | | | | | | | getRelocationAddress is for dynamic libraries and executables, getRelocationOffset for relocatable objects. Mark the getRelocationAddress of COFF and MachO as not implemented yet. Add a test of ELF's. llvm-readobj -r now prints the same values as readelf -r. llvm-svn: 180259
* Use pointers to iterate over symbols.Rafael Espindola2013-04-241-30/+36
| | | | | | | | While here, don't report a dummy symbol for relocations that don't have symbols. We used to says such relocations were for the first defined symbol, but now we return end_symbols(). The llvm-readobj output change agrees with otool. llvm-svn: 180214
* Revert r180189.Rafael Espindola2013-04-241-29/+24
| | | | | | | This should bring the ppc bots back. I will try to write a test that would have found the problem on a little endian system too. llvm-svn: 180194
* Formatting fixes.Rafael Espindola2013-04-241-31/+20
| | | | llvm-svn: 180190
* Use a pointer as the relocation iterator.Rafael Espindola2013-04-241-23/+28
| | | | | | | | Since the relocation iterator walks only the relocations in one section, we can just use a pointer and avoid fetching information about the section at every reference. llvm-svn: 180189
* refactor the struct byte swapping to a helper function.Rafael Espindola2013-04-191-70/+20
| | | | llvm-svn: 179851
* Don't read one command past the end.Rafael Espindola2013-04-191-2/+6
| | | | | | | | | Thanks to Evgeniy Stepanov for reporting this. It might be a good idea to add a command iterator abstraction to MachO.h, but this fixes the bug for now. llvm-svn: 179848
* At Jim Grosbach's request detemplate Object/MachO.h.Rafael Espindola2013-04-181-82/+1379
| | | | | | | We are still able to handle mixed endian objects by swapping one struct at a time. llvm-svn: 179778
* Finish templating MachObjectFile over endianness.Rafael Espindola2013-04-131-417/+15
| | | | | | | We are now able to handle big endian macho files in llvm-readobject. Thanks to David Fang for providing the object files. llvm-svn: 179440
* Add 179294 back, but don't use bit fields so that it works on big endian hosts.Rafael Espindola2013-04-121-8/+44
| | | | | | | | | | | | | | Original message: Print more information about relocations. With this patch llvm-readobj now prints if a relocation is pcrel, its length, if it is extern and if it is scattered. It also refactors the code a bit to use bit fields instead of shifts and masks all over the place. llvm-svn: 179345
* Revert my last two commits while I debug what is wrong in a big endian host.Rafael Espindola2013-04-111-44/+8
| | | | llvm-svn: 179303
* Print more information about relocations.Rafael Espindola2013-04-111-8/+44
| | | | | | | | | | With this patch llvm-readobj now prints if a relocation is pcrel, its length, if it is extern and if it is scattered. It also refactors the code a bit to use bit fields instead of shifts and masks all over the place. llvm-svn: 179294
* Fix MachO's getRelocationAdditionalInfo.Rafael Espindola2013-04-111-0/+6
| | | | | | | It was returning the loaded address of the section containing the relocation, which really doesn't seem to be the intent of this function. llvm-svn: 179255
* Template MachOObjectFile over endianness too.Rafael Espindola2013-04-101-9/+9
| | | | llvm-svn: 179179
* Template the MachO types over endianness.Rafael Espindola2013-04-101-6/+6
| | | | | | For now they are still only used as little endian. llvm-svn: 179147
* Convert MachOObjectFile to a template.Rafael Espindola2013-04-091-852/+110
| | | | | | | For now it is templated only on being 64 or 32 bits. I will add little/big endian next. llvm-svn: 179097
* More uses for SymbolTableEntryBase.Rafael Espindola2013-04-091-35/+9
| | | | llvm-svn: 179076
* Add a SymbolTableEntryBase.Rafael Espindola2013-04-091-47/+27
| | | | | | Use it when we don't need to know if we have a 32 or 64 bit SymbolTableEntry. llvm-svn: 179074
* Add a SectionBase struct.Rafael Espindola2013-04-081-24/+24
| | | | | | | Use it to share code and when we don't need to know if we have a 32 or 64 bit Section. llvm-svn: 179072
* Template the MachO types over the word size.Rafael Espindola2013-04-081-65/+86
| | | | llvm-svn: 179051
* Remove is64BitLoadCommand.Rafael Espindola2013-04-081-20/+10
| | | | llvm-svn: 179048
* Add all 4 MachO object types. Use the stored type to implement is64Bits().Rafael Espindola2013-04-081-5/+8
| | | | llvm-svn: 179021
* Make MachOObjectFile independent from MachOObject.Rafael Espindola2013-04-071-16/+9
| | | | llvm-svn: 178998
* Implement MachOObjectFile::getData directly.Rafael Espindola2013-04-071-1/+1
| | | | llvm-svn: 178997
* Implement MachOObjectFile::is64Bit directly.Rafael Espindola2013-04-071-1/+2
| | | | llvm-svn: 178996
* Implement MachOObjectFile::getHeaderSize directly.Rafael Espindola2013-04-071-1/+1
| | | | llvm-svn: 178995
* Implement MachOObjectFile::getHeader directly.Rafael Espindola2013-04-071-14/+15
| | | | llvm-svn: 178994
* Implement MachOObjectFile::getHeaderSize and MachOObjectFile::getData.Rafael Espindola2013-04-071-41/+44
| | | | | | | These were the last missing forwarding functions. Also consistently use the forwarding functions instead of using MachOObj directly. llvm-svn: 178992
* Remove LoadCommandInfo now that we always have a pointer to the command.Rafael Espindola2013-04-071-58/+27
| | | | | | | LoadCommandInfo was needed to keep a command and its offset in the file. Now that we always have a pointer to the command, we don't need the offset. llvm-svn: 178991
* Add MachOObjectFile::LoadCommandInfo.Rafael Espindola2013-04-071-8/+23
| | | | | | This avoids using MachOObject::getLoadCommandInfo. llvm-svn: 178990
* Use getLoadCommandInfo instead of MachOObj->getLoadCommandInfo.Rafael Espindola2013-04-071-18/+19
| | | | llvm-svn: 178989
* Construct MachOObject in MachOObjectFile's constructor.Rafael Espindola2013-04-071-16/+20
| | | | llvm-svn: 178988
* Remove unused argument.Rafael Espindola2013-04-071-1/+1
| | | | llvm-svn: 178987
* Remove MachOObjectFile::getObject.Rafael Espindola2013-04-071-0/+14
| | | | llvm-svn: 178986
* Remove two uses of getObject.Rafael Espindola2013-04-071-0/+3
| | | | llvm-svn: 178985
* Remove last use of InMemoryStruct in llvm-objdump.Rafael Espindola2013-04-071-0/+8
| | | | llvm-svn: 178979
* Remove last use of InMemoryStruct from MachOObjectFile.cpp.Rafael Espindola2013-04-061-4/+19
| | | | llvm-svn: 178948
* Don't use InMemoryStruct<macho::SymtabLoadCommand>.Rafael Espindola2013-04-061-20/+43
| | | | | | | This also required not using the RegisterStringTable API, which is also a good thing. llvm-svn: 178947
* Don't use InMemoryStruct in getSymbol64TableEntry.Rafael Espindola2013-04-061-24/+19
| | | | llvm-svn: 178946
* Don't use InMemoryStruct in getSymbolTableEntry.Rafael Espindola2013-04-061-23/+19
| | | | llvm-svn: 178945
* Don't use InMemoryStruct in getRelocation.Rafael Espindola2013-04-061-31/+21
| | | | llvm-svn: 178943
OpenPOWER on IntegriCloud