summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/ELFObjectWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Produce a single string table in a ELF .oRafael Espindola2015-05-221-43/+39
| | | | | | | | | | | | | | | | | | | | Normally an ELF .o has two string tables, one for symbols, one for section names. With the scheme of naming sections like ".text.foo" where foo is a symbol, there is a big potential saving in using a single one. Building llvm+clang+lld with master and with this patch the results were: master: 193,267,008 bytes patch: 186,107,952 bytes master non unique section names: 183,260,192 bytes patch non unique section names: 183,118,632 bytes So using non usique saves 10,006,816 bytes, and the patch saves 7,159,056 while still using distinct names for the sections. llvm-svn: 238073
* MC: Lift MCSymbolData::Index up to MCSymbol::Index, NFCDuncan P. N. Exon Smith2015-05-221-5/+5
| | | | | | | Lift `MCSymbolData::Index` up a level to `MCSymbol`, as preparation for packing it into the bitfield in `MCSymbol`. llvm-svn: 238001
* Stop forwarding (get|set)Aligment from MCSectionData to MCSection.Rafael Espindola2015-05-211-1/+1
| | | | llvm-svn: 237956
* Stop creating MCSectionData is the ELF writer.Rafael Espindola2015-05-211-35/+45
| | | | | | | Now is is just its use of MCSymbolData that requires it to take a non const MCAssembler. llvm-svn: 237951
* writeSymbolTable now only needs a MCContext.Rafael Espindola2015-05-211-12/+7
| | | | | | It used to use an MCAssembler just to record the alignment of the sections. llvm-svn: 237944
* Pass a const MCAssembler to writeSectionHeader.Rafael Espindola2015-05-211-5/+9
| | | | | | | It never creates sections, so it can use Asm.getSectionData instead of Asm.getOrCreateSectionData. llvm-svn: 237943
* Remove unused argument. NFC.Rafael Espindola2015-05-211-8/+5
| | | | llvm-svn: 237940
* Fetch alignment directly out of MCSection. NFC.Rafael Espindola2015-05-211-7/+5
| | | | llvm-svn: 237938
* Move alignment from MCSectionData to MCSection.Rafael Espindola2015-05-211-18/+16
| | | | | | | | | | | | | | | | | | | | | | | | This starts merging MCSection and MCSectionData. There are a few issues with the current split between MCSection and MCSectionData. * It optimizes the the not as important case. We want the production of .o files to be really fast, but the split puts the information used for .o emission in a separate data structure. * The ELF/COFF/MachO hierarchy is not represented in MCSectionData, leading to some ad-hoc ways to represent the various flags. * It makes it harder to remember where each item is. The attached patch starts merging the two by moving the alignment from MCSectionData to MCSection. Most of the patch is actually just dropping 'const', since MCSectionData is mutable, but MCSection was not. llvm-svn: 237936
* MC: Use MCSymbol in MCObjectWriter::isWeak(), NFCDuncan P. N. Exon Smith2015-05-201-3/+3
| | | | | | Continue to prefer `MCSymbol` when we need both. llvm-svn: 237798
* MC: Use MCSymbol in most of ELFObjectWriter, NFCDuncan P. N. Exon Smith2015-05-201-36/+36
| | | | | | Stop using MCSymbolData where we also need MCSymbol. llvm-svn: 237770
* MC: Use MCSymbol in MCAsmLayout::getSymbolOffset(), NFCDuncan P. N. Exon Smith2015-05-191-5/+4
| | | | | | | Continue to canonicalize on MCSymbol instead of MCSymbolData when both are needed. llvm-svn: 237749
* MC: Clean up method names in MCContext.Jim Grosbach2015-05-181-5/+5
| | | | | | | The naming was a mish-mash of old and new style. Update to be consistent with the new. NFC. llvm-svn: 237594
* MC: Use MCSymbol in MCObject::IsSymbolRefDifferenceFullyResolvedImpl()Duncan P. N. Exon Smith2015-05-161-9/+8
| | | | | | | | Transition one API from `MCSymbolData` to `MCSymbol`. The function needs both, and the backpointer from `MCSymbolData` to `MCSymbol` is going away. llvm-svn: 237498
* MC: Change MCAssembler::Symbols to store MCSymbol, NFCDuncan P. N. Exon Smith2015-05-161-4/+4
| | | | | | | | Instead of storing a list of the `MCSymbolData` in use, store the `MCSymbol`s. Churning in the direction of removing the back pointer from `MCSymbolData`. llvm-svn: 237496
* Update ELFObjectWriter::reset() following r236255.Yaron Keren2015-05-131-0/+2
| | | | llvm-svn: 237261
* Remove unnecessary break.Rafael Espindola2015-04-301-1/+0
| | | | llvm-svn: 236275
* Simplify the creation of compressed debug sections.Rafael Espindola2015-04-301-106/+33
| | | | | | | | | | This is actually fairly simple in the current code layout: Check if we should compress just before writing out and everything else just works. This removes the last case in which the object writer was creating a fragment. llvm-svn: 236267
* Replace unreachable code with llvm_unreachable.Rafael Espindola2015-04-301-1/+1
| | | | llvm-svn: 236261
* Don't create a MCSectionData when we don't have to.Rafael Espindola2015-04-301-11/+7
| | | | llvm-svn: 236260
* Avoid an extra loop over the sections.Rafael Espindola2015-04-301-7/+1
| | | | | | Add string to the section header string table as we add sections. llvm-svn: 236257
* Make the section table a member of ELFObjectWriter.Rafael Espindola2015-04-301-52/+43
| | | | | | | This avoids passing it around and lets us build a small helper to add a section to the table. llvm-svn: 236255
* Nothing inherits from this, drop the protected:Rafael Espindola2015-04-301-2/+0
| | | | llvm-svn: 236253
* Write sections mostly in one pass.Rafael Espindola2015-04-301-143/+93
| | | | | | | | | | | During ELF writing, there is no need to further relax the sections, so we should not be creating fragments. This patch avoids doing so in all cases but debug section compression (that is next). Also, the ELF format is fairly simple to write. We can do a single pass over the sections to write them out and compute the section header table. llvm-svn: 236235
* Silencing an "enumeral and non-enumeral type in conditional expression" ↵Aaron Ballman2015-04-301-1/+1
| | | | | | warning; NFC. llvm-svn: 236234
* Store relocations in a map from MCSectionELF.Rafael Espindola2015-04-301-25/+21
| | | | | | Saves finding the MCSectionData just to do a map lookup. llvm-svn: 236189
* Write relocations directly to the output stream. NFC.Rafael Espindola2015-04-301-46/+29
| | | | llvm-svn: 236187
* Inline FragmentWriter into the only user.Rafael Espindola2015-04-291-18/+4
| | | | llvm-svn: 236158
* Write the symbol table directly to the output file.Rafael Espindola2015-04-291-79/+85
| | | | | | There is no need to first accumulate it in fragments. llvm-svn: 236157
* Use pwrite to write the number of sections.Rafael Espindola2015-04-291-10/+15
| | | | | | | This avoids having to compute the number upfront, which will be used in the next patch. llvm-svn: 236153
* Write the string table directly to the output file.Rafael Espindola2015-04-291-14/+22
| | | | | | There is no need to accumulate it in fragments first. llvm-svn: 236148
* Write the section header string table directly to the output stream.Rafael Espindola2015-04-291-30/+38
| | | | | | | | | | Instead of accumulating the content in a fragment first, just write it to the output stream. Also put it first in the section table, so that we never have to worry about its index being >= SHN_LORESERVE. llvm-svn: 236145
* Avoid a few const_cast.Rafael Espindola2015-04-291-13/+12
| | | | llvm-svn: 236141
* Map directly from signature symbol to group index. NFC.Rafael Espindola2015-04-281-10/+13
| | | | llvm-svn: 236058
* Remove redundant temporary std::vector.Rafael Espindola2015-04-281-25/+7
| | | | | | | New sections are added to the end of the list, so the RelSections array was redundant. llvm-svn: 236053
* Avoid one more walk over all sections. NFC.Rafael Espindola2015-04-281-9/+3
| | | | | | Set the group section index as they are created. llvm-svn: 236049
* Use a range loop. NFC.Rafael Espindola2015-04-281-3/+2
| | | | llvm-svn: 236047
* Avoid an extra walk over the sections just to assign sections to groups.Rafael Espindola2015-04-281-30/+41
| | | | | | Assign the sections in the same pass we compute the index. llvm-svn: 236045
* Remove the GroupMapTy DenseMap. NFC.Rafael Espindola2015-04-281-18/+10
| | | | | | Instead use the Group symbol of MCSectionELF. llvm-svn: 236033
* Use range loops. NFC.Rafael Espindola2015-04-281-7/+3
| | | | llvm-svn: 236028
* Avoid adding to SectionIndexMap sections that we never lookup. NFC.Rafael Espindola2015-04-281-33/+28
| | | | llvm-svn: 236026
* Use a range loop. NFC.Rafael Espindola2015-04-281-3/+2
| | | | llvm-svn: 236015
* Use a std::vector to record the offsets of the sections. NFC.Rafael Espindola2015-04-281-10/+8
| | | | llvm-svn: 235995
* Avoid an extra loop for computing the section size. NFC.Rafael Espindola2015-04-281-29/+13
| | | | llvm-svn: 235994
* Look past locals in comdats.Rafael Espindola2015-04-201-9/+8
| | | | | | | | | | | We have to avoid converting a reference to a global into a reference to a local, but it is fine to look past a local. Patch by Vasileios Kalintiris. I just moved the comment and added thet test. llvm-svn: 235300
* Compute A-B when A or B is weak.Rafael Espindola2015-04-171-8/+9
| | | | | | | | | | | | | | | | | | | | Similar to r235222, but for the weak symbol case. In an "ideal" assembler/object format an expression would always refer to the final value and A-B would only be computed from a section in the same comdat as A and B with A and B strong. Unfortunately that is not the case with debug info on ELF, so we need an heuristic. Since we need an heuristic, we may as well use the same one as gas: * call weak_sym : produces a relocation, even if in the same section. * A - weak_sym and weak_sym -A: don't produce a relocation if we can compute it. This fixes pr23272 and changes the fix of pr22815 to match what gas does. llvm-svn: 235227
* Compute A-B if both A and B are in the same comdat section.Rafael Espindola2015-04-171-18/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of pr23272. A small annoyance with the assembly syntax we implement is that given an expression there is no way to know if what is desired is the value of that expression for the symbols in this file or for the final values of those symbols in a link. The first case is useful for use in sections that get discarded or ignored if the section they are describing is discarded. For axample, consider A-B where A and B are in the same comdat section. We can compute the value of the difference in the section that is present in the current .o and if that section survives to the final DSO the value will still will be correct. But the section is in a comdat. Another section from another object file might be used istead. We know that that section will define A and B, but we have no idea what the value of A-B might be. In practice we have to assume that the intention is to compute the value in the current section since otherwise the is no way to create something like the debug aranges section. llvm-svn: 235222
* [mc] Clean up emission of byte sequencesBenjamin Kramer2015-04-171-4/+1
| | | | | | No functional change intended. llvm-svn: 235178
* Don't walk aliases from global to local symbols in comdats.Rafael Espindola2015-04-171-1/+30
| | | | | | This fixes pr23196. llvm-svn: 235167
* Write relocation sections contiguously.Rafael Espindola2015-04-171-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linkers normally read all the relocations upfront to compute the references between sections. Putting them together is a bit more cache friendly. I benchmarked linking a Release+Asserts clang with gold on a vm. I tried all 4 combinations of --gc-sections/no --gc-section hot and cold cache. I cleared the cache with echo 3 > /proc/sys/vm/drop_caches and warmed it up by running the link once before timing the subsequent ones. With cold cache and --gc-sections the time goes from 1.86130781665 +- 0.01713126697463843 seconds to 1.82370735105 +- 0.014127522318814516 seconds With cold cache and no --gc-sections the time goes from 1.6087245435500002 +- 0.012999066825178644 seconds to 1.5687122041500001 +- 0.013145850126026619 seconds With hot cache and no --gc-sections the time goes from 0.926200939 ( +- 0.33% ) seconds to 0.907200079 ( +- 0.31% ) seconds With hot cache and gc sections the time goes from 1.183038049 ( +- 0.34% ) seconds to 1.147355862 ( +- 0.39% ) seconds llvm-svn: 235165
OpenPOWER on IntegriCloud