summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/ELFObjectWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Write section and section table entries in the same order.Rafael Espindola2015-04-151-50/+15
| | | | | | We had two different orders, which has no value. llvm-svn: 235004
* Use the ability to pwrite to simplify the ELF writer.Rafael Espindola2015-04-141-44/+31
| | | | | | | | | | | | Now we don't have to do 2 synchronized passes to compute offsets and then write the file. This also includes a fix for the corner case of seeking in /dev/null. It is not an error, but on some systems (Linux) the returned offset is always 0. An error is signaled by returning -1. This is checked by the existing tests now that "clang -o /dev/null ..." seeks. llvm-svn: 234952
* Use raw_pwrite_stream in the object writer/streamer.Rafael Espindola2015-04-141-2/+2
| | | | | | The ELF object writer will take advantage of that in the next commit. llvm-svn: 234950
* Re-enable target-specific relocation table sorting and use it for MipsPetar Jovanovic2015-04-141-31/+3
| | | | | | | | | | | | | | Some targets (ie. Mips) have additional rules for ordering the relocation table entries. Allow them to override generic sortRelocs(), which sorts entries by Offset. Then override this function for Mips, to emit HI16 and GOT16 relocations against the local symbol in pair with the corresponding LO16 relocation. Patch by Vladimir Stefanovic. Differential Revision: http://reviews.llvm.org/D7414 llvm-svn: 234883
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-1/+1
| | | | | | | | | | | | | | The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' \ -j=32 -fix -format http://reviews.llvm.org/D8925 llvm-svn: 234679
* Remove unused variable.Rafael Espindola2015-04-081-2/+0
| | | | llvm-svn: 234426
* Write the section header in the end.Rafael Espindola2015-04-081-27/+4
| | | | | | | | One could make the argument for writing it immediately after the ELF header, but writing it in the middle of the sections like we were doing just makes it harder for no reason. llvm-svn: 234400
* ELFObjectWriter.cpp: Prune obsolete \param since r234342. [-Wdocumentation]NAKAMURA Takumi2015-04-081-1/+0
| | | | llvm-svn: 234377
* Delete commented code. Don't repeat name in comment.Rafael Espindola2015-04-071-7/+1
| | | | llvm-svn: 234370
* Don't subtract the header size just to add it back.Rafael Espindola2015-04-071-5/+4
| | | | llvm-svn: 234362
* Remove intermediate variables.Rafael Espindola2015-04-071-7/+1
| | | | | | | The name of these variables was completely out of date with the information stored in them. llvm-svn: 234345
* Remove unused argument.Rafael Espindola2015-04-071-9/+6
| | | | llvm-svn: 234342
* Be consistent when deciding if a relocation is needed.Rafael Espindola2015-04-061-9/+8
| | | | | | | | | | | | | | Before when deciding if we needed a relocation in A-B, we wore only checking if A was weak. This fixes the asymmetry. The "InSet" argument should probably be renamed to "ForValue", since InSet is very MachO specific, but doing so in this patch would make it hard to read. This fixes PR22815. llvm-svn: 234165
* Store the sh_link of ARM_EXIDX directly in MCSectionELF.Rafael Espindola2015-04-061-13/+2
| | | | | | This avoids some pretty horrible and broken name based section handling. llvm-svn: 234142
* Simplify this function a bit. NFC.Rafael Espindola2015-04-061-20/+4
| | | | | | | | | The case values are not a tidy enum we can fully cover. They even ovelap over the various extension. Just use a default: llvm-svn: 234140
* Simplify mapping from relocation sections to relocated sections.Rafael Espindola2015-04-061-39/+21
| | | | | | | | Just store the section in MCSectionELF. This avoids multiple hash lookups. This will also be used by ARM_EXIDX. llvm-svn: 234139
* Special case the creation of relocation sections.Rafael Espindola2015-03-301-6/+3
| | | | | | | | | | | These sections are never looked up and we know when have to create them. Use that to save adding them to the regular map and avoid a symbol->string->symbol conversion for the group symbol. This also makes the implementation independent of the details of how unique sections are implemented. llvm-svn: 233539
* Fix fixup evaluation when deciding what to relocate with.Rafael Espindola2015-03-251-2/+8
| | | | | | | | | | | | | | The previous logic was to first try without relocations at all and failing that stop on the first defined symbol. That was inefficient and incorrect in the case part of the expression could be simplified and another part could not (see included test). We now stop the evaluation when we get to a variable whose value can change (i.e. is weak). llvm-svn: 233187
* Don't be over eager in evaluating a subtraction with a weak symbol.Rafael Espindola2015-03-241-1/+9
| | | | | | | In a subtraction of the form A - B, if B is weak, there is no way to represent that on ELF since all relocations add the value of a symbol. llvm-svn: 233139
* Add missing ELFObjectWriter::reset() override, like other MC classes.Yaron Keren2015-03-231-0/+14
| | | | | | | | | | | | | See detailed discussion at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140915/235418.html and r217907, r217948: http://llvm.org/viewvc/llvm-project?view=revision&revision=217907 http://llvm.org/viewvc/llvm-project?view=revision&revision=217948 llvm-svn: 232982
* Fix uses of reserved identifiers starting with an underscore followed by an ↵David Blaikie2015-03-161-2/+2
| | | | | | | | | uppercase letter This covers essentially all of llvm's headers and libs. One or two weird cases I wasn't sure were worth/appropriate to fix. llvm-svn: 232394
* Recommit r232027 with PR22883 fixed: Add infrastructure for support of ↵Daniel Sanders2015-03-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | multiple memory constraints. The operand flag word for ISD::INLINEASM nodes now contains a 15-bit memory constraint ID when the operand kind is Kind_Mem. This constraint ID is a numeric equivalent to the constraint code string and is converted with a target specific hook in TargetLowering. This patch maps all memory constraints to InlineAsm::Constraint_m so there is no functional change at this point. It just proves that using these previously unused bits in the encoding of the flag word doesn't break anything. The next patch will make each target preserve the current mapping of everything to Constraint_m for itself while changing the target independent implementation of the hook to return Constraint_Unknown appropriately. Each target will then be adapted in separate patches to use appropriate Constraint_* values. PR22883 was caused the matching operands copying the whole of the operand flags for the matched operand. This included the constraint id which needed to be replaced with the operand number. This has been fixed with a conversion function. Following on from this, matching operands also used the operand number as the constraint id. This has been fixed by looking up the matched operand and taking it from there. llvm-svn: 232165
* Make some non-constant static variables non-static or fully const.Benjamin Kramer2015-03-011-1/+1
| | | | | | Otherwise we have to emit thread-safe initialization for them. NFC. llvm-svn: 230894
* Fix UTF8 chars to ASCII.NAKAMURA Takumi2015-02-251-1/+1
| | | | llvm-svn: 230479
* Add r228980 back.Rafael Espindola2015-02-171-1/+1
| | | | | | | | | | Add support for having multiple sections with the same name and comdat. Using this in combination with -ffunction-sections allows LLVM to output a .o file with mulitple sections named .text. This saves space by avoiding long unique names of the form .text.<C++ mangled name>. llvm-svn: 229541
* Add r228889 back.Rafael Espindola2015-02-171-31/+26
| | | | | | | | | | Original message: Invert the section relocation map. It now points from rel section to section. Use it to set sh_info, avoiding a brittle name lookup. llvm-svn: 229539
* Add r228888 back.Rafael Espindola2015-02-171-7/+3
| | | | | | | | Original message: Use the existing SymbolTableIndex instead of doing a lookup. NFC. llvm-svn: 229538
* Add r228886 back now that r229530 fixed the issue lldb was hitting.Rafael Espindola2015-02-171-47/+45
| | | | | | | | | | Original message: Create the Seciton -> Rel Section map when it is first needed. NFC. Saves a walk over every section. llvm-svn: 229536
* Revert a series of commits starting at r228886 which is triggering someChandler Carruth2015-02-131-71/+82
| | | | | | | | | | | | | | | | regressions for LLDB on Linux. Rafael indicated on lldb-dev that we should just go ahead and revert these but that he wasn't at a computer. The patches backed out are as follows: r228980: Add support for having multiple sections with the name and ... r228889: Invert the section relocation map. r228888: Use the existing SymbolTableIndex intsead of doing a lookup. r228886: Create the Section -> Rel Section map when it is first needed. These patches look pretty nice to me, so hoping its not too hard to get them re-instated. =D llvm-svn: 229080
* Add support for having multiple sections with the same name and comdat.Rafael Espindola2015-02-121-1/+1
| | | | | | | | Using this in combination with -ffunction-sections allows LLVM to output a .o file with mulitple sections named .text. This saves space by avoiding long unique names of the form .text.<C++ mangled name>. llvm-svn: 228980
* Invert the section relocation map.Rafael Espindola2015-02-111-31/+26
| | | | | | | It now points from rel section to section. Use it to set sh_info, avoiding a brittle name lookup. llvm-svn: 228889
* Use the existing SymbolTableIndex instead of doing a lookup. NFC.Rafael Espindola2015-02-111-7/+3
| | | | llvm-svn: 228888
OpenPOWER on IntegriCloud