summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
Commit message (Collapse)AuthorAgeFilesLines
...
* Change how we iterate over relocations on ELF.Rafael Espindola2013-05-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | For COFF and MachO, sections semantically have relocations that apply to them. That is not the case on ELF. In relocatable objects (.o), a section with relocations in ELF has offsets to another section where the relocations should be applied. In dynamic objects and executables, relocations don't have an offset, they have a virtual address. The section sh_info may or may not point to another section, but that is not actually used for resolving the relocations. This patch exposes that in the ObjectFile API. It has the following advantages: * Most (all?) clients can handle this more efficiently. They will normally walk all relocations, so doing an effort to iterate in a particular order doesn't save time. * llvm-readobj now prints relocations in the same way the native readelf does. * probably most important, relocations that don't point to any section are now visible. This is the case of relocations in the rela.dyn section. See the updated relocation-executable.test for example. llvm-svn: 182908
* Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.Michael J. Spencer2013-05-241-1/+1
| | | | llvm-svn: 182680
* Convert obj2yaml to use yamlio.Rafael Espindola2013-05-172-0/+280
| | | | llvm-svn: 182169
* 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-092-11/+0
| | | | | | | It was only implemented for ELF where it collected the Addend, so this patch also renames it to getRelocationAddend. llvm-svn: 181502
* This patch breaks up Wrap.h so that it does not have to include all of Filip Pizlo2013-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | the things, and renames it to CBindingWrapping.h. I also moved CBindingWrapping.h into Support/. This new file just contains the macros for defining different wrap/unwrap methods. The calls to those macros, as well as any custom wrap/unwrap definitions (like for array of Values for example), are put into corresponding C++ headers. Doing this required some #include surgery, since some .cpp files relied on the fact that including Wrap.h implicitly caused the inclusion of a bunch of other things. This also now means that the C++ headers will include their corresponding C API headers; for example Value.h must include llvm-c/Core.h. I think this is harmless, since the C API headers contain just external function declarations and some C types, so I don't believe there should be any nasty dependency issues here. llvm-svn: 180881
* 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-292-2/+25
| | | | | | | | | | | | | 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-263-452/+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-252-17/+2
| | | | | | | | | | 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
* Move C++ code out of the C headers and into either C++ headersEric Christopher2013-04-221-0/+39
| | | | | | | or the C++ files themselves. This enables people to use just a C compiler to interoperate with LLVM. llvm-svn: 180063
* 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
* Make the host endianness check an integer constant expression.Rafael Espindola2013-04-151-1/+1
| | | | | | | | | | | | | | | I will remove the isBigEndianHost function once I update clang. The ifdef logic is designed to * not use configure/cmake to avoid breaking -arch i686 -arch ppc. * default to little endian * be as small as possible It looks like sys/endian.h is the preferred header on most modern BSD systems, but it is better to change this in a followup patch as machine/endian.h is available on FreeBSD, OpenBSD, NetBSD and OS X. llvm-svn: 179527
* 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-073-3/+3
| | | | 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
OpenPOWER on IntegriCloud