summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] Convert StringTableSection to input sectionEugene Leviant2016-11-141-53/+23
| | | | | | Differential revision: https://reviews.llvm.org/D26549 llvm-svn: 286799
* [ELF] Convert .got section to input sectionEugene Leviant2016-11-111-279/+5
| | | | | | Differential revision: https://reviews.llvm.org/D26498 llvm-svn: 286580
* Parse relocations only once.Rafael Espindola2016-11-101-5/+4
| | | | | | | | | | | | | | | | Relocations are the last thing that we wore storing a raw section pointer to and parsing on demand. With this patch we parse it only once and store a pointer to the actual data. The patch also changes where we store it. It is now in InputSectionBase. Not all sections have relocations, but most do and this simplifies the logic. It also means that we now only support one relocation section per section. Given that that constraint is maintained even with -r with gold bfd and lld, I think it is OK. llvm-svn: 286459
* [ELF] Convert .got.plt section to input sectionEugene Leviant2016-11-101-35/+5
| | | | | | Differential revision: https://reviews.llvm.org/D26349 llvm-svn: 286443
* [ELF] - Implemented --symbol-ordering-file option.George Rimar2016-11-101-10/+17
| | | | | | | | | | | | | | | | | | | | | | | Patch allows to pass a symbols file to linker. LLD will map symbols to sections and sort sections in output according to symbol ordering file. That can help to reduce the startup time and/or amount of pagefaults during startup. Also, interesting benchmark result was produced by Rafael Espíndola. After applying the symbols file for clang he timed compiling X86MCTargetDesc.ii to an object file. The page faults went from just 56,988 to 56,946 since most faults are not in the binary. Running time went from 4.403053515 to 4.178112244. The speedup seems to be because of better cache locality. Differential revision: https://reviews.llvm.org/D26130 llvm-svn: 286440
* Make OutputSectionBase a class instead of class template.Rafael Espindola2016-11-091-40/+38
| | | | | | | | The disadvantage is that we use uint64_t instad of uint32_t for some value in 32 bit files. The advantage is a substantially simpler code, faster builds and less code duplication. llvm-svn: 286414
* Split OutputSection ctor. NFC.Rui Ueyama2016-11-091-11/+18
| | | | llvm-svn: 286405
* [ELF][MIPS] Convert .MIPS.abiflags section to synthetic input sectionSimon Atanasyan2016-11-091-48/+2
| | | | | | | | | | | | | | Previously, we have both input and output section for .MIPS.abiflags. Now we have only one class for .MIPS.abiflags, which is MipsAbiFlagsSection. This class is a synthetic input section. .MIPS.abiflags sections are handled as regular sections until the control reaches Writer. Writer then aggregates all sections whose type is SHT_MIPS_ABIFLAGS to create a single synthesized input section. The synthesized section is then processed normally as if it came from an input file. llvm-svn: 286398
* [ELF][MIPS] Convert .reginfo and .MIPS.options sections to synthetic input ↵Simon Atanasyan2016-11-091-74/+5
| | | | | | | | | | | | | | | | | | | sections Previously, we have both input and output sections for .reginfo and .MIPS.options. Now for each such sections we have one synthetic input sections: MipsReginfoSection and MipsOptionsSection respectively. Both sections are handled as regular sections until the control reaches Writer. Writer then aggregates all sections whose type is SHT_MIPS_REGINFO or SHT_MIPS_OPTIONS to create a single synthesized input section. In that moment Writer also save GP0 value to the MipsGp0 field of the corresponding ObjectFile. This value required for R_MIPS_GPREL16 and R_MIPS_GPREL32 relocations calculation. Differential revision: https://reviews.llvm.org/D26444 llvm-svn: 286397
* Split Header into individual fields.Rafael Espindola2016-11-091-110/+113
| | | | | | | | | This is similar to what was done for InputSection. With this the various fields are stored in host order and only converted to target order when writing. llvm-svn: 286327
* Store the size the same way as any other OutputSection. NFC.Rafael Espindola2016-11-081-4/+7
| | | | llvm-svn: 286286
* [ELF] Use the SystemV hash in libObject instead of rolling our own.Davide Italiano2016-11-071-14/+2
| | | | llvm-svn: 286158
* Rewrite CommonInputSection as a synthetic input section.Rui Ueyama2016-11-051-1/+2
| | | | | | | | | | | | A CommonInputSection is a section containing all common symbols. That was an input section but was abstracted in a different way than the synthetic input sections because it was written before the synthetic input section was invented. This patch rewrites CommonInputSection as a synthetic input section so that it behaves better with other sections. llvm-svn: 286053
* Revert r285968: Always use parallel_for_each because it falls back to ↵Rui Ueyama2016-11-041-2/+7
| | | | | | | | | | std::for_each. It turned ou that we actually want to call std::for_each even if threading is supported. Unless --thread is given, LLD shouldn't use more than one threads. llvm-svn: 286004
* Always use parallel_for_each because it falls back to std::for_each.Rui Ueyama2016-11-031-7/+2
| | | | | | | If multi-threading is disabled, parallel_for_each will automatically fall back to std::for_each, so we don't have to do that ourselves. llvm-svn: 285968
* Now that the ELFFile constructor does nothing, create it when needed.Rafael Espindola2016-11-031-1/+1
| | | | | | This avoids duplicating the buffer in InputFile. llvm-svn: 285965
* Update for llvm change.Rafael Espindola2016-11-031-2/+2
| | | | llvm-svn: 285956
* Convert Out::InterpSection to In::InterpSection.Rui Ueyama2016-11-021-16/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D26225 llvm-svn: 285851
* Add strings to .dynstr early.Rui Ueyama2016-11-021-36/+39
| | | | | | | | | | | | | | | | | Previously, we added strings from DynamicSection::finalize(). It was a bit tricky because finalize() is supposed to fix the final size of the section, but adding new strings would change the size of .dynstr section. So there was a dependency between finalize functions of .dynamic and .dynstr. However, I noticed that we can elimiante the dependency by simply add strings early; we don't have to do that in finalize() but can do from DynamicSection's ctor. This patch defines a new function, DynamicSection::addEntries, to add .dynamic entries that doesn't depend on other sections. llvm-svn: 285784
* Remove Out::Pool and use make() instead.Rui Ueyama2016-11-011-7/+7
| | | | llvm-svn: 285763
* Convert BuildIdSection to input sectionEugene Leviant2016-11-011-90/+0
| | | | | | Differential revision: https://reviews.llvm.org/D25627 llvm-svn: 285682
* Delete trivial getters. NFC.Rafael Espindola2016-10-261-9/+8
| | | | llvm-svn: 285190
* Read section headers upfront.Rafael Espindola2016-10-261-1/+1
| | | | | | | | | | | | | | | | | | Instead of storing a pointer, store the members we need. The reason for doing this is that it makes it far easier to create synthetic sections. It also avoids reading data from files multiple times., which might help with cross endian linking and host architectures with slow unaligned access. There are obvious compacting opportunities, but this already has mixed results even on native x86_64 linking. There is also the possibility of better refactoring the code for handling common symbols, but this already shows that a custom class is not necessary. llvm-svn: 285148
* Delete getSectionHdr.Rafael Espindola2016-10-251-9/+8
| | | | | | | | | | | We were fairly inconsistent as to what information should be accessed with getSectionHdr and what information (like alignment) was stored elsewhere. Now all section info has a dedicated getter. The code is also a bit more compact. llvm-svn: 285079
* [ELF] Add sh_link field to .ARM.exidx sections for relocatable linksPeter Smith2016-10-211-3/+15
| | | | | | | | | | | | | | | When doing a relocatable link the .ARM.exidx sections with the SHF_LINK_ORDER flag set need to set the sh_link field to the executable section they describe. We find the appropriate OutputSection by following the sh_link field of the .ARM.exidx InputSections. The getOutputSectionName() function rules make sure that when there are multiple .ARM.exidx InputSections in an OutputSection they all have the same sh_link field. Differential revision: https://reviews.llvm.org/D25825 llvm-svn: 284820
* [ELF][MIPS] Put local GOT entries accessed via a 16-bit index firstSimon Atanasyan2016-10-211-2/+12
| | | | | | | | | | | | | | | | | | | | | | Some MIPS relocations used to access GOT entries are able to manipulate 16-bit index. The other ones like R_MIPS_CALL_HI16/LO16 can handle 32-bit indexes. 16-bit relocations are generated by default. The 32-bit relocations are generated by -mxgot flag passed to compiler. Usually these relocation are not mixed in the same code but files like crt*.o contain 16-bit relocations so even if all "user's" code compiled with -mxgot flag a few 16-bit relocations might come to the linking phase. Now LLD does not differentiate local GOT entries accessed via a 16-bit and 32-bit indexes. That might lead to relocation's overflow if 16-bit entries are allocated to far from the beginning of the GOT. The patch introduces new "part" of MIPS GOT dedicated to the local GOT entries accessed by 32-bit relocations. That allows to put local GOT entries accessed via a 16-bit index first and escape relocation's overflow. Differential revision: https://reviews.llvm.org/D25833 llvm-svn: 284809
* [ELF][MIPS] Use getMipsLocalEntriesNum() everywhere we need number of ↵Simon Atanasyan2016-10-201-3/+2
| | | | | | `local` GOT entries. NFC llvm-svn: 284751
* [ELF][MIPS] Separate calculation of MIPS GOT index and offset of the ↵Simon Atanasyan2016-10-201-7/+12
| | | | | | | | | | | corresponding part of the GOT. NFC MIPS GOT consists of some parts: local, global, TLS entries. This change separates calculation of MIPS GOT index and offset of the corresponding part of the GOT. That makes code a bit clear and allow to extend number of parts in the future. llvm-svn: 284750
* Compact SectionPiece.Rafael Espindola2016-10-201-4/+8
| | | | | | | We allocate a lot of these when linking debug info. This speeds up the link of debug programs by 1% to 2%. llvm-svn: 284716
* [ELF] - Partial support of --gdb-index command line option (Part 1).George Rimar2016-10-201-0/+50
| | | | | | | | | | | | | | | In this patch partial gdb_index section is created. For costructing the .gdb_index section 6 steps should be performed (details are in SplitDebugInfo.cpp file header), this patch do first 3: Creates proper section header. Fills list of compilation units. Types CU list area is not supposed to be supported, so it is ignored and therefore can be treated as implemented either. Differential revision: https://reviews.llvm.org/D24706 llvm-svn: 284708
* [ELF] - Applied clang format. NFC.George Rimar2016-10-201-5/+3
| | | | llvm-svn: 284705
* Fix narrowing conversion error in 32-bit MSVC buildsReid Kleckner2016-10-201-1/+1
| | | | | | | | Use size_t instead of ELFT::uint for the string table offset. If the linker is built 32-bit, it can't write an output file larger than 2GB. Other code in this area uses size_t as well. llvm-svn: 284680
* Fix build failure.Rui Ueyama2016-10-201-1/+1
| | | | llvm-svn: 284675
* [ELF] Replace std::pair with a struct so we have proper names. NFC.Michael J. Spencer2016-10-191-32/+29
| | | | llvm-svn: 284670
* [ELF] Add `const` qualifier to functions. NFCSimon Atanasyan2016-10-191-1/+1
| | | | llvm-svn: 284614
* [ADT] Move CachedHashString to its own header in ADT, and rename to ↵Justin Lebar2016-10-171-2/+2
| | | | | | | | | | | | | | | | CachedHashStringRef. Summary: Reclaiming the name 'CachedHashString' will let us add a type with that name that owns its value. Reviewers: timshen Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25644 llvm-svn: 284434
* Move a utility function to Strings.cpp.Rui Ueyama2016-10-131-5/+1
| | | | | | So that we can use the function from anywhere. llvm-svn: 284092
* [ELF][ARM] Initial implentation of ARM exceptions supportPeter Smith2016-10-101-0/+3
| | | | | | | | | | | | | | | | | | | The .ARM.exidx sections contain a table. Each entry has two fields: - PREL31 offset to the function the table entry describes - Action to take, either cantunwind, inline unwind, or PREL31 offset to .ARM.extab section The table entries must be sorted in order of the virtual addresses the first entry of the table describes. Traditionally this is implemented by the SHF_LINK_ORDER dependency. Instead of implementing this directly we sort the table entries post relocation. The .ARM.exidx OutputSection is described by the PT_ARM_EXIDX program header Differential revision: https://reviews.llvm.org/D25127 llvm-svn: 283730
* Store the hash in SectionPiece.Rafael Espindola2016-10-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This spreads out computing the hash and using it in a hash table. The speedups are: firefox master 6.811232891 patch 6.559280249 1.03841162939x faster chromium master 4.369323666 patch 4.33171853 1.00868134338x faster chromium fast master 1.856679971 patch 1.850617741 1.00327578725x faster the gold plugin master 0.32917962 patch 0.325711944 1.01064645023x faster clang master 0.558015452 patch 0.550284165 1.01404962652x faster llvm-as master 0.032563515 patch 0.032152077 1.01279662275x faster the gold plugin fsds master 0.356221362 patch 0.352772162 1.00977741549x faster clang fsds master 0.635096494 patch 0.627249229 1.01251060127x faster llvm-as fsds master 0.030183188 patch 0.029889544 1.00982430511x faster scylla master 3.071448906 patch 2.938484138 1.04524944215x faster This seems to be because we don't stall as much. When linking firefox stalled-cycles-frontend goes from 57.56% to 55.55%. With -O2 the difference is even more significant since we avoid recomputing the hash. For firefox we go from 9.990295265 to 9.149627521 seconds (1.09x faster). llvm-svn: 283367
* Compact SectionPiece.Rafael Espindola2016-10-051-2/+2
| | | | | | | | | It is pretty easy to get the data from the InputSection, so we don't have to store it. This opens the way for storing the hash instead. llvm-svn: 283357
* Remove redundant check. NFC.Rafael Espindola2016-10-051-3/+1
| | | | llvm-svn: 283328
* [ELF] Do not merge sections in case of relocatable object generationSimon Atanasyan2016-10-051-1/+9
| | | | | | | | | | | | | Do not merge sections if generating a relocatable object. It makes the code simpler because we do not need to update relocations addends to reflect changes introduced by merging. Instead of that we write such "merge" sections into separate OutputSections and keep SHF_MERGE / SHF_STRINGS flags and sh_entsize value to be able to perform merging later during a final linking. Differential Revision: http://reviews.llvm.org/D25066 llvm-svn: 283300
* Update for llvm change.Rafael Espindola2016-10-041-9/+3
| | | | llvm-svn: 283267
* [ELF][MIPS] Set GP0 value to zero in case of relocatable object generationSimon Atanasyan2016-09-291-2/+8
| | | | | | | | | | LLD does not update relocations addends when generate a relocatable object. That is why we should not write a non-zero GP0 value into the .reginfo and .MIPS.options sections. And we should not accept input object files with non-zero GP0 value because we cannot handle them properly. llvm-svn: 282716
* [ELF][MIPS] Setup STO_MIPS_PIC flag for PIC symbols when generate a ↵Simon Atanasyan2016-09-291-7/+13
| | | | | | | | | | relocatable object In case of linking PIC and non-PIC code together and generation of a relocatable object, all PIC symbols should have STO_MIPS_PIC flag in the symbol table of the ouput file. llvm-svn: 282714
* Use xxhash for fast --build-id.Rafael Espindola2016-09-271-50/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The speed improvements I got were: firefox master 7.050784981 patch 6.842361079 0.970439617353 chromium master 4.260626249 patch 4.183148025 0.981815296749 chromium fast master 1.829028591 patch 1.806439277 0.987649556649 the gold plugin master 0.336154128 patch 0.331893374 0.987324998728 clang master 0.561869781 patch 0.558640828 0.994253200458 llvm-as master 0.034025959 patch 0.033984389 0.99877828572 the gold plugin fsds master 0.360710529 patch 0.356483564 0.988281559145 clang fsds master 0.640518422 patch 0.632329874 0.987215749432 llvm-as fsds master 0.031569416 patch 0.030822055 0.976326423017 scylla master 3.154770529 patch 3.11982016 0.988921422754 llvm-svn: 282505
* [ELF] - Linkerscript: implemented BYTE/SHORT/LONG/QUAD commands.George Rimar2016-09-261-0/+3
| | | | | | | | | | | | | | | | | | | The BYTE, SHORT, LONG, and QUAD commands store one, two, four, and eight bytes (respectively). After storing the bytes, the location counter is incremented by the number of bytes stored. Previously our scripts handles these commands incorrectly. For example: SECTIONS { .foo : { *(.foo.1) BYTE(0x11) ... We accepted the script above treating BYTE as input section description. These commands are used in the wild though. Differential revision: https://reviews.llvm.org/D24830 llvm-svn: 282429
* [ELF] - Linkerscript: implemented SORT_BY_INIT_PRIORITY.George Rimar2016-09-151-13/+0
| | | | | | | | | | | This is PR30386, SORT_BY_INIT_PRIORITY is a keyword can be used to sort sections by numerical value of the GCC init_priority attribute encoded in the section name. Differential revision: https://reviews.llvm.org/D24611 llvm-svn: 281646
* Use murmurhash2 instead of fnv.Rafael Espindola2016-09-141-11/+54
| | | | | | It is substantially faster by processing 8 bytes at a time. llvm-svn: 281454
* Simplify InputFile ownership management.Rui Ueyama2016-09-141-4/+2
| | | | | | | | | | | | | | | | | | | | Previously, all input files were owned by the symbol table. Files were created at various places, such as the Driver, the lazy symbols, or the bitcode compiler, and the ownership of new files was transferred to the symbol table using std::unique_ptr. All input files were then free'd when the symbol table is freed which is on program exit. I think we don't have to transfer ownership just to free all instance at once on exit. In this patch, all instances are automatically collected to a vector and freed on exit. In this way, we no longer have to use std::unique_ptr. Differential Revision: https://reviews.llvm.org/D24493 llvm-svn: 281425
OpenPOWER on IntegriCloud