summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify a few uses of remove_filename by using parent_path instead.Rafael Espindola2015-07-151-3/+2
| | | | llvm-svn: 242334
* Handle the error of trying to convert a regular archive to a thin one.Rafael Espindola2015-07-151-0/+3
| | | | | | While at it, test that we can add to a thin archive. llvm-svn: 242330
* Initial support for writing thin archives.Rafael Espindola2015-07-151-13/+24
| | | | llvm-svn: 242269
* Use a range loop.Rafael Espindola2015-07-141-4/+2
| | | | llvm-svn: 242250
* Add support for reading members out of thin archives.Rafael Espindola2015-07-141-1/+22
| | | | | | | | | | For now the Archive owns the buffers of the thin archive members. This makes for a simple API, but all the buffers are destructed only when the archive is destructed. This should be fine since we close the files after mmap so we should not hit an open file limit. llvm-svn: 242215
* Add a herper function. NFC.Rafael Espindola2015-07-141-8/+7
| | | | llvm-svn: 242100
* Fix reading archive members with / in the name.Rafael Espindola2015-07-131-3/+3
| | | | | | This is important for thin archives. llvm-svn: 242082
* Add support deterministic output in llvm-ar and make it the default.Rafael Espindola2015-07-131-17/+43
| | | | llvm-svn: 242061
* llvm-ar: Pad the symbol table to 4 bytes.Rafael Espindola2015-07-091-2/+5
| | | | | | | It looks like ld64 requires it. With this we seem to be able to bootstrap using llvm-ar+/usr/bin/true instead of ar+ranlib (currently on stage2). llvm-svn: 241842
* Basic support for BSD symbol tables in archives.Rafael Espindola2015-07-091-17/+39
| | | | | | | This could be optimized and for now we only produce __.SYMDEF and not "__.SYMDEF SORTED". llvm-svn: 241814
* Remove redundant variable. NFC.Rafael Espindola2015-07-091-2/+1
| | | | llvm-svn: 241810
* Add a helper to printing BE of LE depending on the format.Rafael Espindola2015-07-091-6/+10
| | | | | | | The gnu ar format uses BE numbers. The BSD one uses LE. Add a helper for one or the other. NFC for now, just removes some noise from the following patch. llvm-svn: 241808
* Extract printBSDMemberHeader.Rafael Espindola2015-07-091-22/+25
| | | | | | | It will get another use in the following patch. Also rename the other helper to printGNUSmallMemberHeader for consistency. llvm-svn: 241805
* Don't reject an archive with just a symbol table.Rafael Espindola2015-07-081-1/+1
| | | | | | It is pretty unambiguous how to interpret it and gnu ar accepts it too. llvm-svn: 241750
* Disallow Archive::child_iterator that don't point to an archive.Rafael Espindola2015-07-082-3/+2
| | | | | | NFC, just less error prone. llvm-svn: 241747
* Use a raw_svector_ostream and simplify a loop. NFC.Rafael Espindola2015-07-081-6/+3
| | | | llvm-svn: 241727
* Start adding support for writing archives in BSD format.Rafael Espindola2015-07-081-10/+30
| | | | | | | | No support for the symbol table yet (but will hopefully add it today). We always use the long filename format so that we can align the member, which is an advantage of the BSD format. llvm-svn: 241721
* Inline function into only use.Rafael Espindola2015-07-081-12/+6
| | | | llvm-svn: 241692
* Add a helper function to reduce a bit of code duplication.Rafael Espindola2015-07-081-25/+22
| | | | llvm-svn: 241691
* Use a range loop. NFC.Rafael Espindola2015-07-081-8/+6
| | | | llvm-svn: 241685
* Delete UnknownAddress. It is a perfectly valid symbol value.Rafael Espindola2015-07-073-11/+12
| | | | | | | | | | | getSymbolValue now returns a value that in convenient for most callers: * 0 for undefined * symbol size for common symbols * offset/address for symbols the rest Code that needs something more specific can check getSymbolFlags. llvm-svn: 241605
* Common symbols don't have a value.Rafael Espindola2015-07-071-3/+2
| | | | | | | | | | | | | At least not in the interface exposed by ObjectFile. This matches what ELF and COFF implement. Adjust existing code that was expecting them to have values. No overall functionality change intended. Another option would be to change the interface and the ELF and COFF implementations to say that the value of a common symbol is its size. llvm-svn: 241593
* Common symbols are not undefined, at least for ObjectFile.Rafael Espindola2015-07-071-3/+2
| | | | | | | | | They are implemented like that in some object formats, but for the interface provided by lib/Object, SF_Undefined and SF_Common are different things. This matches the ELF and COFF implementation and fixes llvm-nm for MachO. llvm-svn: 241587
* Simplify, NFC.Rafael Espindola2015-07-071-3/+2
| | | | | | | | In these two contexts we really just want the raw n_value. No need to use getSymbolValue which checks for special cases where, semantically, the symbol has no value. llvm-svn: 241584
* Remove getRelocationAddress.Rafael Espindola2015-07-063-20/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally added in r139314. Back then it didn't actually get the address, it got whatever value the relocation used: address or offset. The values in different object formats are: * MachO: Always an offset. * COFF: Always an address, but when talking about the virtual address of sections it says: "for simplicity, compilers should set this to zero". * ELF: An offset for .o files and and address for .so files. In the case of the .so, the relocation in not linked to any section (sh_info is 0). We can't really compute an offset. Some API mappings would be: * Use getAddress for everything. It would be quite cumbersome. To compute the address elf has to follow sh_info, which can be corrupted and therefore the method has to return an ErrorOr. The address of the section is also the same for every relocation in a section, so we shouldn't have to check the error and fetch the value for every relocation. * Use a getValue and make it up to the user to know what it is getting. * Use a getOffset and: * Assert for dynamic ELF objects. That is a very peculiar case and it is probably fair to ask any tool that wants to support it to use ELF.h. The only tool we have that reads those (llvm-readobj) already does that. The only other use case I can think of is a dynamic linker. * Check that COFF .obj files have sections with zero virtual address spaces. If it turns out that some assembler/compiler produces these, we can change COFFObjectFile::getRelocationOffset to subtract it. Given COFF format, this can be done without the need for ErrorOr. The getRelocationAddress method was never implemented for COFF. It also had exactly one use in a very peculiar case: a shortcut for adding the section value to a pcrel reloc on MachO. Given that, I don't expect that there is any use out there of the C API. If that is not the case, let me know and I will add it back with the implementation inlined and do a proper deprecation. llvm-svn: 241450
* Check that COFF .obj files have sections with zero virtual address spaces.Rafael Espindola2015-07-061-0/+2
| | | | | | | | | | | | | When talking about the virtual address of sections the coff spec says: ... for simplicity, compilers should set this to zero. Otherwise, it is an arbitrary value that is subtracted from offsets during relocation. We don't currently subtract it, so check that it is zero. If some producer does create such files, we can change getRelocationOffset instead. llvm-svn: 241447
* Object/COFF: Do not rely on VirtualSize being 0 in object files.Rui Ueyama2015-07-041-8/+4
| | | | llvm-svn: 241387
* [ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj toolsSimon Atanasyan2015-07-031-0/+10
| | | | | | | | | | SHT_NOBITS sections do not have content in an object file. Now the yaml2obj tool does not accept `Content` field for such sections, and the obj2yaml tool does not attempt to read the section content from a file. Restore r241350 and r241352. llvm-svn: 241377
* Return ErrorOr from getSymbolAddress.Rafael Espindola2015-07-033-13/+10
| | | | | | | It can fail trying to get the section on ELF and COFF. This makes sure the error is handled. llvm-svn: 241366
* Use getValue instead of getAddress in a few MachO only cases.Rafael Espindola2015-07-031-5/+2
| | | | | | | In MachO the value of the symbol is always the address, so we can use the simpler function. llvm-svn: 241364
* This reverts commit r241350 and r241352.Rafael Espindola2015-07-031-10/+0
| | | | | | | | | | | r241350 broke lld tests. r241352 depends on r241350. Original messages: "[ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj tools" "[ELFYAML] Make the Size field for .bss section optional" llvm-svn: 241354
* [ELFYAML] Make the Size field for .bss section optionalSimon Atanasyan2015-07-031-1/+1
| | | | | | It's a common case to have a zero-size .bss section in an object file. llvm-svn: 241352
* [ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj toolsSimon Atanasyan2015-07-031-0/+10
| | | | | | | | SHT_NOBITS sections do not have content in an object file. Now yaml2obj tool does not accept `Content` field for such sections, and obj2yaml tool does not attempt to read the section content from a file. llvm-svn: 241350
* Return ErrorOr from SymbolRef::getName.Rafael Espindola2015-07-024-14/+15
| | | | | | | | | | | | This function can really fail since the string table offset can be out of bounds. Using ErrorOr makes sure the error is checked. Hopefully a lot of the boilerplate code in tools/* can go away once we have a diagnostic manager in Object. llvm-svn: 241297
* Return ErrorOr from getSection.Rafael Espindola2015-07-011-0/+2
| | | | | | | | | | | | | | This also improves the logic of what is an error: * getSection(uint_32): only return an error if the index is out of bounds. The index 0 corresponds to a perfectly valid entry. * getSection(Elf_Sym): Returns null for symbols that normally don't have sections and error for out of bound indexes. In many places this just moves the report_fatal_error up the stack, but those can then be fixed in smaller patches. llvm-svn: 241156
* Use ErrorOr in getRelocationAdress.Rafael Espindola2015-06-303-10/+7
| | | | | | | We can probably do better in this method, but this is an improvement and enables further ErrorOr cleanups. llvm-svn: 241114
* Implement containsSymbol with other lower level methods.Rafael Espindola2015-06-303-23/+7
| | | | llvm-svn: 241112
* Don't return error_code from a function that doesn't fail.Rafael Espindola2015-06-303-11/+5
| | | | llvm-svn: 241042
* Move function to the only file that uses it.Rafael Espindola2015-06-301-24/+0
| | | | llvm-svn: 241040
* Don't return error_code from a function that doesn't fail.Rafael Espindola2015-06-301-7/+5
| | | | llvm-svn: 241039
* Don't return error_code from a function that doesn't fail.Rafael Espindola2015-06-303-18/+8
| | | | llvm-svn: 241033
* Object/COFF: Define coff_symbol_generic.Rui Ueyama2015-06-301-6/+10
| | | | | | | | | | | | | | If you only need Name and Value fields in the COFF symbol, you don't need to distinguish 32 bit and 64 bit COFF symbols. These fields start at the same offsets and have the same size. This data strucutre is one pointer smaller than COFFSymbolRef thus slightly efficient. I'll use this class in LLD as we create millions of LLD symbol objects that currently contain COFFSymbolRef. Shaving off 8 byte (or 4 byte on 32 bit) from that class actually matters becasue of the number of objects we create in LLD. llvm-svn: 241024
* Don't return error_code from function that never fails.Rafael Espindola2015-06-293-18/+6
| | | | llvm-svn: 241021
* [SymbolSize] Skip sorting by index, just assign by index.Benjamin Kramer2015-06-291-7/+3
| | | | | | No functional change intended. llvm-svn: 240961
* Factor out the checking of string tables.Rafael Espindola2015-06-291-0/+2
| | | | | | | | | | This moves the error checking for string tables to getStringTable which returns an ErrorOr<StringRef>. This improves error checking, makes it uniform across all string tables and makes it possible to check them once instead of once per name. llvm-svn: 240950
* Simplify getSymbolType.Rafael Espindola2015-06-262-43/+26
| | | | | | | | This is still a really odd function. Most calls are in object format specific contexts and should probably be replaced with a more direct query, but at least now this is not too obnoxious to use. llvm-svn: 240777
* Add an ELFSymbolRef type.Rafael Espindola2015-06-251-2/+2
| | | | | | | This allows user code to say Sym.getSize() instead of having to manually fetch the object. llvm-svn: 240708
* Use computeSymbolSizes in llvm-symbolize.Rafael Espindola2015-06-251-1/+4
| | | | llvm-svn: 240646
* libObject/COFF: Add a function to get pointers to relocation entries.Rui Ueyama2015-06-251-0/+10
| | | | llvm-svn: 240610
* Make computeSymbolSizes never fail.Rafael Espindola2015-06-243-15/+45
| | | | | | | | | | | On ELF that was already the case since getting the size of a symbol never fails. On MachO and COFF we could fail trying to get the section of a symbol. But we don't really need the section, just the section number to know if two symbols are in the same section or not. llvm-svn: 240580
OpenPOWER on IntegriCloud