summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.h
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] Do not omit debug sections when computing build-idPetr Hosek2016-09-011-6/+6
| | | | | | | | | | The primary use of build-id is in debugging, hence omitting debug sections when computing it significantly reduces its usability as changes in debug section content wouldn't alter the build-id. Differential Revision: https://reviews.llvm.org/D24120 llvm-svn: 280421
* Use getSize to find the size of a section. NFC.Rafael Espindola2016-08-311-1/+0
| | | | llvm-svn: 280305
* Add DT_REL(A)COUNT tag to .dynamic sectionEugene Leviant2016-08-311-0/+2
| | | | | | | | | | This patch groups relative relocations in a single block in combrelocs mode and adds DT_RELCOUNT or DT_RELACOUNT tag to .dynamic section Differential revision: https://reviews.llvm.org/D23661 llvm-svn: 280210
* Implement support for --build-id=uuid switchEugene Leviant2016-08-261-0/+6
| | | | | | Differential revision: https://reviews.llvm.org/D23349 llvm-svn: 279810
* [ELF] - Linkerscript: set correct dynamic tag entries values when LS is used.George Rimar2016-08-191-3/+3
| | | | | | | | | | | | Previously DT_PREINIT_ARRAYSZ, DT_INIT_ARRAYSZ and DT_FINI_ARRAYSZ were set to zero when lincerscript was used becase sections sizes are calculated later that were taken. Patch delays values calculation for these entries. Testcase is provided. Differential revision: https://reviews.llvm.org/D23663 llvm-svn: 279258
* [ELF][MIPS] Support .MIPS.abiflags sectionSimon Atanasyan2016-08-121-0/+19
| | | | | | | This section supersedes .reginfo and .MIPS.options sections. But for now we have to support all three sections for ABI transition period. llvm-svn: 278482
* Simplify output section ownership management.Rui Ueyama2016-08-121-1/+6
| | | | | | | | | One reason why we are (ab)using OutputSectionFactory class is because it owns output sections. Technically there's no need to have it own sections. So, this patch transfers the ownership to Out<ELFT>. llvm-svn: 278452
* [ELF] Support LLVM-style casting for OutputSectionBase<ELFT> derived classesEugene Leviant2016-08-101-0/+97
| | | | llvm-svn: 278261
* [ELF] - Removed dead code. NFC.George Rimar2016-08-091-2/+0
| | | | llvm-svn: 278115
* Remove redundant variable.Rui Ueyama2016-08-091-2/+0
| | | | llvm-svn: 278094
* Separate {Preinit,Init,Fini}Arrays from Out<ELFT>::Dynamic.Rui Ueyama2016-08-091-4/+7
| | | | | | | | Even if an output is not a dynamic object, the output may have .{preinit,init,fini} sections. Therefore, managing these sections as Out<ELFT>::Dynamic's members is not correct. llvm-svn: 278093
* Make toPhdrFlags a member function. NFC.Rafael Espindola2016-07-271-0/+1
| | | | llvm-svn: 276868
* Fix PR28575.Rafael Espindola2016-07-211-7/+7
| | | | | | | | | | Not all relocations from a .eh_frame that point to an executable section should be ignored. In particular, the relocation finding the personality function should not. This is a reduction from trying to bootstrap a static lld on linux. llvm-svn: 276329
* Simplify output section ownership.Rui Ueyama2016-07-201-0/+1
| | | | | | | | | This patch simplifies output section management by making Factory class have ownership of sections that creates. Differential Revision: https://reviews.llvm.org/D22575 llvm-svn: 276141
* Rename Version VersionDefinition.Rui Ueyama2016-07-161-1/+0
| | | | | | | | | | | The identifier `Version` was used too often in the code to handle symbol versions. The struct that contains version definitions is named `Version`. Local variables for version ID are named `Version`. Local varaible for version string are named `Version`. This patch give them different names. llvm-svn: 275673
* Remove redundant variable.Rui Ueyama2016-07-161-2/+0
| | | | llvm-svn: 275667
* Make Verdef and Verdaux adjacent in the version definition section.Rui Ueyama2016-07-161-2/+5
| | | | | | | | Previously, Verdefs and Verdauxs are separated in the section. The new layout is easier to write as we do not have to maintain two pointers and can avoid passing a reference to a pointer. llvm-svn: 275665
* Set sh_addralign to 1 instead of 0.Rui Ueyama2016-07-141-5/+2
| | | | | | | | ELF spec says that alignment of 0 is equivalent to 1. Previously, we arbitrary set to 0 or 1, but always setting to 1 makes our program simpler. llvm-svn: 275374
* Recommit r275161 "[ELF] - Move section factory out from writer to make it ↵George Rimar2016-07-121-1/+41
| | | | | | | | | | | | | | | | | | reusable." With fix: * fixed compilation error under linux: template <class ELFT> class OutputSectionFactory { ... typedef typename SectionKey<ELFT::Is64Bits> Key; changed to: template <class ELFT> class OutputSectionFactory { ... typedef typename elf::SectionKey<ELFT::Is64Bits> Key; llvm-svn: 275166
* Revert r275161 "[ELF] - Move section factory out from writer to make it ↵George Rimar2016-07-121-41/+1
| | | | | | | | | reusable." It broke build bot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-debian-fast/builds/39652 llvm-svn: 275163
* [ELF] - Move section factory out from writer to make it reusable.George Rimar2016-07-121-1/+41
| | | | | | | | | | | Since linkerscript should create sections by itself (if SECTIONS command is present), then we might want to reuse the OutputSectionFactory (D19976 already do that now), so this patch moves it out from writer cpp file for that purpose. Differential revision: http://reviews.llvm.org/D19977 llvm-svn: 275161
* Remove duplicate declaration.Rui Ueyama2016-07-021-2/+0
| | | | llvm-svn: 274429
* Move getAddend to Relocations.h.Rui Ueyama2016-07-021-10/+0
| | | | | | | Because the function works on relocations, it should be in Relocations.h instead of OutputSections.h. llvm-svn: 274428
* [ELF][MIPS] Support MIPS TLS relocationsSimon Atanasyan2016-06-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | The patch adds one more partition to the MIPS GOT. This time it is for TLS related GOT entries. Such entries are located after 'local' and 'global' ones. We cannot get a final offset for these entries at the time of creation because we do not know size of 'local' and 'global' partitions. So we have to adjust the offset later using `getMipsTlsOffset()` method. All MIPS TLS relocations which need GOT entries operates MIPS style GOT offset - 'offset from the GOT's beginning' - MipsGPOffset constant. That is why I add new types of relocation expressions. One more difference from othe ABIs is that the MIPS ABI does not support any TLS relocation relaxations. I decided to make a separate function `handleMipsTlsRelocation` and put MIPS TLS relocation handling code there. It is similar to `handleTlsRelocation` routine and duplicates its code. But it allows to make the code cleaner and prevent pollution of the `handleTlsRelocation` by MIPS 'if' statements. Differential Revision: http://reviews.llvm.org/D21606 llvm-svn: 273569
* Fix a bug that MIPS thunks can overwrite other section contents.Rui Ueyama2016-06-231-14/+24
| | | | | | | | | | | | | | | Peter Smith found while trying to support thunk creation for ARM that LLD sometimes creates broken thunks for MIPS. The cause of the bug is that we assign file offsets to input sections too early. We need to create all sections and then assign section offsets because appending thunks changes file offsets for all following sections. This patch separates the pass to assign file offsets from thunk creation pass. This effectively reverts r265673. Differential Revision: http://reviews.llvm.org/D21598 llvm-svn: 273532
* [ELF] - Recommit r273143("[ELF] - Basic versioned symbols support implemented.")George Rimar2016-06-201-4/+26
| | | | | | | | | | | | | | | | | | With fix: -soname flag was not set in testcase. Hash calculated for base def was different on local and bot machines because filename fos used for calculating. Initial commit message: Patch implements basic support of versioned symbols. There is no wildcards patterns matching except local: *; There is no support for hierarchies. There is no support for symbols overrides (@ vs @@ not handled). This patch allows programs that using simple scripts to link and run. Differential revision: http://reviews.llvm.org/D21018 llvm-svn: 273152
* Revert r273143 "[ELF] - Basic versioned symbols support implemented."George Rimar2016-06-201-26/+4
| | | | | | | It broke buildbot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast llvm-svn: 273146
* [ELF] - Basic versioned symbols support implemented.George Rimar2016-06-201-4/+26
| | | | | | | | | | | | | Patch implements basic support of versioned symbols. There is no wildcards patterns matching except local: *; There is no support for hierarchies. There is no support for symbols overrides (@ vs @@ not handled). This patch allows programs that using simple scripts to link and run. Differential revision: http://reviews.llvm.org/D21018 llvm-svn: 273143
* [ELF][MIPS] Support GOT entries for non-preemptible symbols with different ↵Simon Atanasyan2016-06-191-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | addends There are two motivations for this patch. The first one is a preparation for support MIPS TLS relocations. It might sound like a joke but for GOT entries related to TLS relocations MIPS ABI uses almost regular approach with creation of dynamic relocations for each GOT enty etc. But we need to separate these 'regular' TLS related entries from MIPS specific local and global parts of GOT. ABI declare simple solution - all TLS related entries allocated at the end of GOT after local/global parts. The second motivation it to support GOT relocations for non-preemptible symbols with addends. If we have more than one GOT relocations against symbol S with different addends we need to create GOT entries for each unique Symbol/Addend pairs. So we store all MIPS GOT entries in separate containers. For non-preemptible symbols we have to maintain two data structures. The first one is MipsLocal vector. Each entry corresponds to the GOT entry from the 'local' part of the GOT contains the symbol's address plus addend. The second one is MipsLocalMap. It is a map from Symbol/Addend pair to the GOT index. Differential Revision: http://reviews.llvm.org/D21297 llvm-svn: 273127
* Rename Align -> Alignment.Rui Ueyama2016-06-171-4/+4
| | | | | | | | I think it is me who named these variables, but I always find that they are slightly confusing because align is a verb. Adding four letters is worth it. llvm-svn: 272984
* Avoid doing binary search.Rui Ueyama2016-05-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MergedInputSection::getOffset is the busiest function in LLD if string merging is enabled and input files have lots of mergeable sections. It is usually the case when creating executable with debug info, so it is pretty common. The reason why it is slow is because it has to do faily complex computations. For non-mergeable sections, section contents are contiguous in output, so in order to compute an output offset, we only have to add the output section's base address to an input offset. But for mergeable strings, section contents are split for merging, so they are not contigous. We've got to do some lookups. We used to do binary search on the list of section pieces. It is slow because I think it's hostile to branch prediction. This patch replaces it with hash table lookup. Seems it's working pretty well. Below is "perf stat -r10" output when linking clang with debug info. In this case this patch speeds up about 4%. Before: 6584.153205 task-clock (msec) # 1.001 CPUs utilized ( +- 0.09% ) 238 context-switches # 0.036 K/sec ( +- 6.59% ) 0 cpu-migrations # 0.000 K/sec ( +- 50.92% ) 1,067,675 page-faults # 0.162 M/sec ( +- 0.15% ) 18,369,931,470 cycles # 2.790 GHz ( +- 0.09% ) 9,640,680,143 stalled-cycles-frontend # 52.48% frontend cycles idle ( +- 0.18% ) <not supported> stalled-cycles-backend 21,206,747,787 instructions # 1.15 insns per cycle # 0.45 stalled cycles per insn ( +- 0.04% ) 3,817,398,032 branches # 579.786 M/sec ( +- 0.04% ) 132,787,249 branch-misses # 3.48% of all branches ( +- 0.02% ) 6.579106511 seconds time elapsed ( +- 0.09% ) After: 6312.317533 task-clock (msec) # 1.001 CPUs utilized ( +- 0.19% ) 221 context-switches # 0.035 K/sec ( +- 4.11% ) 1 cpu-migrations # 0.000 K/sec ( +- 45.21% ) 1,280,775 page-faults # 0.203 M/sec ( +- 0.37% ) 17,611,539,150 cycles # 2.790 GHz ( +- 0.19% ) 10,285,148,569 stalled-cycles-frontend # 58.40% frontend cycles idle ( +- 0.30% ) <not supported> stalled-cycles-backend 18,794,779,900 instructions # 1.07 insns per cycle # 0.55 stalled cycles per insn ( +- 0.03% ) 3,287,450,865 branches # 520.799 M/sec ( +- 0.03% ) 72,259,605 branch-misses # 2.20% of all branches ( +- 0.01% ) 6.307411828 seconds time elapsed ( +- 0.19% ) Differential Revision: http://reviews.llvm.org/D20645 llvm-svn: 270999
* Do not start over relocation search from beginning.Rui Ueyama2016-05-241-2/+2
| | | | | | | | | | This patch addresses a post-commit review for r270325. r270325 introduced getReloc function that searches a relocation for a given range. It always started searching from beginning of relocation vector, so it was slower than before. Previously, we used to use the fact that the relocations are sorted. This patch restore it. llvm-svn: 270572
* Do not pass the symbol table. NFC.Rui Ueyama2016-05-241-8/+2
| | | | | | | Since the symbol table is a singleton class and globally accessible, we don't need to pass it around. llvm-svn: 270533
* Rename EHInputSection -> EhInputSection.Rui Ueyama2016-05-241-5/+5
| | | | llvm-svn: 270532
* Make scanReloc and related functions non-member functions.Rui Ueyama2016-05-241-0/+4
| | | | | | | scanReloc does not depend on Writer, so it doesn't have to be in the class. llvm-svn: 270530
* Make getFdeEncoding a non-member function.Rui Ueyama2016-05-241-3/+0
| | | | | | This function does not depend on EhOutputSection class. llvm-svn: 270522
* Remove dead code.Rui Ueyama2016-05-231-4/+0
| | | | | | | The dead declarations made MSVC to warn on explicit template instantiations of the classes. llvm-svn: 270471
* Remove EhFrameHeader<ELFT>::reserveFde. NFC.Rui Ueyama2016-05-231-3/+3
| | | | llvm-svn: 270448
* Make .eh_frame a singleton output object.Rui Ueyama2016-05-231-4/+3
| | | | | | | | .eh_frame_hdr assumes that there is only one .eh_frame and ensures it by assertions. This patch makes .eh_frame a real singleton object to simplify. llvm-svn: 270445
* Do not propagate section name and attributes to .eh_frame.Rui Ueyama2016-05-231-2/+3
| | | | | | | | .eh_frame is always ".eh_frame" and its attribute is fixed. No need to copy from inputs to outputs. GNU gold also sets SHT_PROGBITS. llvm-svn: 270443
* Rename EHOutputSection -> EhOutputSection for consistency.Rui Ueyama2016-05-231-4/+4
| | | | llvm-svn: 270442
* Refactor EhFrameHdr.Rui Ueyama2016-05-231-6/+7
| | | | | | | | | | | | | Previously, EhFrameHdr section computed addresses to which FDEs are applied to. This is not an ideal design because EhFrameHdr does not know much about FDEs unless EhFrame passes the information to EhFrameHdr. It is what we did. This patch simplifies the code by making EhFrame to compute the values and pass the cooked information to EhFrameHdr. EhFrameHdr no longer have to know about the details of FDEs such as FDE encodings. llvm-svn: 270393
* Attempt to unbreak buildbots.Rui Ueyama2016-05-221-1/+1
| | | | | | | | My last commit made Clang to fail with an assertion failure. https://llvm.org/bugs/show_bug.cgi?id=27835 This is a patch to avoid that. llvm-svn: 270384
* Refactor EHOutputSection.Rui Ueyama2016-05-221-18/+22
| | | | | | | | | | | | | | This patch refactors EHOutputSection using SectionPiece struct. EHRegion class was removed since we can now directly use SectionPiece. An incomplete support of large CIE/FDE record (> 2^32 bytes) was removed because it silently created broken executable. There are several places in the existing code that "size" field is always 4 bytes and at offset 4 in the record, which is not true for 64-bit size records. We will have to support that in future, but it is better to error out instead of creating malformed eh_frame sections. llvm-svn: 270382
* Use slightly longer names. NFC.Rui Ueyama2016-05-221-5/+5
| | | | | | | We generally prefer short names, but this code went probably a bit too far. This patch renames single letter local/member varables. llvm-svn: 270342
* Use ArrayRef<uint8_t> for binary data instead of StringRef. NFC.Rui Ueyama2016-05-221-1/+1
| | | | llvm-svn: 270341
* Use uintX_t instead of unsigned.Rui Ueyama2016-05-211-1/+1
| | | | | | | | This fixes a potential bug when cross linking very large executables on LLP64 machines such as Windows. On such platform, uintX_t is 64 bits while unsigned is 32 bits. llvm-svn: 270327
* Add `explicit`.Rui Ueyama2016-05-161-1/+1
| | | | llvm-svn: 269703
* Support --build-id=0x<hexstring>.Rui Ueyama2016-05-131-0/+7
| | | | | | | | If you specify the option in the form of --build-id=0x<hexstring>, that hexstring is set as a build ID. We observed that the feature is actually in use in some builds, so we want this feature. llvm-svn: 269495
* [ELF] - Implemented -z combrelocs/nocombreloc.George Rimar2016-05-101-1/+2
| | | | | | | | | | | | | | | | | This is the option which sorts relocs to optimize dynamic linker performance. -z combelocs is the default in gold, also it ignores -z nocombreloc, this patch do the same. Patch sorts relocations by symbols only and do not create any DT_REL[A]COUNT entries. That is different with what gold/bfd do. More information about option is here: http://www.airs.com/blog/archives/186 http://people.redhat.com/jakub/prelink.pdf, p.2 Differential revision: http://reviews.llvm.org/D19528 llvm-svn: 269066
OpenPOWER on IntegriCloud