summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Make OutputSections and OutputSectionCommands globals.Rafael Espindola2017-06-131-0/+2
| | | | | | | This is similar to what we do for InputSections and makes them easier to access. llvm-svn: 305337
* [ELF] - Do not merge relocation sections by name when using --emit-relocs.George Rimar2017-06-071-0/+5
| | | | | | | | | | | | Previously we would merge relocation sections by name. That did not work in some cases, like testcase shows. Patch implements logic to merge relocation sections if their target sections were merged into the same output section. Differential revision: https://reviews.llvm.org/D33824 llvm-svn: 304886
* Move finalize to OutputSectionCommands. NFC.Rafael Espindola2017-06-061-1/+0
| | | | | | | This removes a mapping from OutputSection to OutputSectionCommand and is another step in moving clearOutputSections earlier. llvm-svn: 304821
* Run fabricateDefaultCommands before fixSectionAlignments.Rafael Espindola2017-06-021-4/+0
| | | | | | | This allows us to remove the PageAlign field. It will also allow moving fabricateDefaultCommands earlier. llvm-svn: 304513
* Move maybeCompress to OutputSectionCommand.Rafael Espindola2017-06-011-1/+0
| | | | | | | This removes a call to getCmd and allows us to move clearOutputSections earlier. llvm-svn: 304439
* Check Live instead of the section type.Rafael Espindola2017-05-301-0/+1
| | | | | | | By the time we get here all live sections should have been combined into InputSections. llvm-svn: 304243
* Move writeTo to OutputSectionCommand.Rafael Espindola2017-05-241-2/+0
| | | | | | | | | | | | This reduces how many times we have to map from OutputSection to OutputSectionCommand. It is a required step to moving clearOutputSections earlier. In order to always use writeTo in OutputSectionCommand we have to call fabricateDefaultCommands for -r links and move section compression after it. llvm-svn: 303784
* Optimize orphan placement in a general way.Rafael Espindola2017-05-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | We used to place orphans by just using compareSectionsNonScript. Then we noticed that since linker scripts can use another order, we should first try match the section to a given PT_LOAD. But there is nothing special about PT_LOAD. The same issue can show up for PT_GNU_RELRO for example. In general, we have to search for the most similar section and put the orphan next to it. Most similar being defined as how long they follow the same code path in compareSecitonsNonScript. That is what this patch does. We now compute a rank for each output section, with a bit for each branch in what was compareSectionsNonScript. With this findOrphanPos is now fully general and orphan placement can be optimized by placing every section with the same rank at once. The included testcase is a variation of many-sections.s that uses allocatable sections to avoid the fast path in the existing code. Without threads it goes form 46 seconds to 0.9 seconds. llvm-svn: 302903
* Create an OutputSection for each non-empty OutputSectionCommand.Rafael Espindola2017-04-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were already pretty close, the one exception was when a name was reused in another SECTIONS directive: SECTIONS { .text : { *(.text) } .data : { *(.data) } } SECTIONS { .data : { *(other) } } In this case we would create a single .data and magically output "other" while looking at the first OutputSectionCommand. We now create two .data sections. This matches what gold does. If we really want to create a single one, we should change the parser so that the above is parsed as if the user had written SECTIONS { .text : { *(.text) } .data : { *(.data) *(other)} } That is, there should be only one OutputSectionCommand for .data and it would have two InputSectionDescriptions. By itself this patch makes the code a bit more complicated, but is an important step in allowing assignAddresses to operate just on the linker script. llvm-svn: 301484
* Rename CompressedHeader ZDebugHeader.Rui Ueyama2017-04-191-1/+1
| | | | | | | `CompressedHeader` is a header for compressed data, and the header itself is not compressed. So the previous name was confusing. llvm-svn: 300675
* [ELF] - Implemented --compress-debug-sections option.George Rimar2017-04-171-0/+5
| | | | | | | | | | | | | | Patch implements --compress-debug-sections=zlib. In compare with D20211 (a year old patch, abandoned), it implementation uses streaming and fully reimplemented, does not support zlib-gnu for simplification. This is PR32308. Differential revision: https://reviews.llvm.org/D31941 llvm-svn: 300444
* Call getFiller only when filler is not zero.Rui Ueyama2017-04-111-1/+1
| | | | llvm-svn: 300004
* [ELF] Recommit r299635 to pad x86 executable sections with 0xccJames Henderson2017-04-071-0/+1
| | | | | | This follows r299748 which fixed a latent bug the original commit exposed. llvm-svn: 299755
* Move a cast out of a function. NFC.Rafael Espindola2017-04-071-1/+1
| | | | | | The argument was always casted, so cast it in the caller. llvm-svn: 299742
* Revert r299635 because it exposed a latent bug.James Henderson2017-04-061-1/+0
| | | | llvm-svn: 299655
* [ELF] Pad x86 executable sections with 0xcc int3 instructionsJames Henderson2017-04-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Executable sections should not be padded with zero by default. On some architectures, 0x00 is the start of a valid instruction sequence, so can confuse disassembly between InputSections (and indeed the start of the next InputSection in some situations). Further, in the case of misjumps into padding, padding may start to be executed silently. On x86, the "0xcc" byte represents the int3 trap instruction. It is a single byte long so can serve well as padding. This change switches x86 (and x86_64) to use this value for padding in executable sections, if no linker script directive overrides it. It also puts the behaviour into place making it easy to change the behaviour of other targets when desired. I do not know the relevant instruction sequences for trap instructions on other targets however, so somebody should add this separately. Because the old behaviour simply wrote padding in the whole section before overwriting most of it, this change also modifies the padding algorithm to write padding only where needed. This in turn has caused a small behaviour change with regards to what values are written via Fill commands in linker scripts, bringing it into line with ld.bfd. The fill value is now written starting from the end of the previous block, which means that it always starts from the first byte of the fill, whereas the old behaviour meant that the padding sometimes started mid-way through the fill value. See the test changes for more details. Reviewed by: ruiu Differential Revision: https://reviews.llvm.org/D30886 Bugzilla: http://bugs.llvm.org/show_bug.cgi?id=32227 llvm-svn: 299635
* [ELF] - Recommit "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."George Rimar2017-03-171-2/+0
| | | | | | | | | | | | | | | | | | Was fixed, details on review page. Original commit message: That removes CopyRelSection class completely, making Bss/BssRelRo to be just regular synthetics. This is splitted from D30541 and polished. Difference from D30541 that all logic of SharedSymbol converting to DefinedRegular was removed for now and probably will be posted as separate patch. Differential revision: https://reviews.llvm.org/D30892 llvm-svn: 298062
* [ELF] - Detemplate OutputSection::assignOffsets. NFC.George Rimar2017-03-161-1/+1
| | | | llvm-svn: 297937
* [ELF] - Remove unnecessary template #4. NFC.George Rimar2017-03-141-1/+0
| | | | | | OutputSectionFactory has no ELFT templates anymore. llvm-svn: 297720
* [ELF] - Remove unnecessary template. NFC.George Rimar2017-03-131-5/+1
| | | | llvm-svn: 297622
* Remove DefinedSynthetic.Rafael Espindola2017-03-081-9/+6
| | | | | | | | | | | | | With this we have a single section hierarchy. It is a bit less code, but the main advantage will be in a future patch being able to handle foo = symbol_in_obj; in a linker script. Currently that fails since we try to find the output section of symbol_in_obj. With this we should be able to just return an InputSection from the expression. llvm-svn: 297313
* Use uint32_t for alignment in more places, NFC.Rafael Espindola2017-03-081-1/+1
| | | | llvm-svn: 297305
* Revert r297008: [ELF] - Make Bss and BssRelRo sections to be synthetic (#2).Rui Ueyama2017-03-081-0/+2
| | | | | | | This reverts commit r297008 because it's reported that that change broke AArch64 bots. llvm-svn: 297297
* Use 32 bits for alignment.Rafael Espindola2017-03-071-2/+2
| | | | | | This is consistent with what we do for input sections. llvm-svn: 297152
* Rename Addralign to Alignment.Rafael Espindola2017-03-071-4/+4
| | | | | | It now matches the name used in InputSectionBase. llvm-svn: 297144
* Detemplate EhInputSection. NFC.Rafael Espindola2017-03-061-1/+1
| | | | llvm-svn: 297077
* Detemplate merge (input and synthetic) sections. NFC.Rafael Espindola2017-03-061-1/+1
| | | | llvm-svn: 297061
* [ELF] - Make Bss and BssRelRo sections to be synthetic (#2).George Rimar2017-03-061-2/+0
| | | | | | | | | | | | | | | In compare with D30458, this makes Bss/BssRelRo to be pure synthetic sections. That removes CopyRelSection class completely, making Bss/BssRelRo to be just regular synthetics. SharedSymbols involved in creating copy relocations are converted to DefinedRegular, what also simplifies things. Differential revision: https://reviews.llvm.org/D30541 llvm-svn: 297008
* De-template DefinedRegular.Rui Ueyama2017-02-281-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D30348 llvm-svn: 296508
* De-template OutputSectionFactory.Rui Ueyama2017-02-271-4/+3
| | | | | | | Since OutputSection is no longer a template, it doesn't make much sense to tempalte its factory class. llvm-svn: 296308
* Remove useless template so that Out<ELFT> becomes just Out.Rui Ueyama2017-02-271-18/+3
| | | | llvm-svn: 296307
* De-template SharedSymbol.Rui Ueyama2017-02-261-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D30351 llvm-svn: 296303
* Merge OutputSectionBase and OutputSection. NFC.Rafael Espindola2017-02-241-62/+30
| | | | | | | Now that all special sections are SyntheticSections, we only need one OutputSection class. llvm-svn: 296127
* Delete trivial setter.Rafael Espindola2017-02-241-1/+0
| | | | llvm-svn: 296124
* Delete trivial getter.Rafael Espindola2017-02-241-1/+0
| | | | llvm-svn: 296123
* Delete unused enum values.Rafael Espindola2017-02-241-2/+0
| | | | llvm-svn: 296118
* Convert EhOutputSection to be a synthetic section.Rafael Espindola2017-02-231-48/+0
| | | | | | | | With this we complete the transition out of special output sections, and with the previous patches it should be possible to merge OutputSectionBase and OuputSection. llvm-svn: 296023
* Make InputSection a class. NFC.Rafael Espindola2017-02-231-2/+2
| | | | | | | | | With the current design an InputSection is basically anything that goes directly in a OutputSection. That includes plain input section but also synthetic sections, so this should probably not be a template. llvm-svn: 295993
* Merge InputSectionData and InputSectionBase.Rafael Espindola2017-02-231-7/+7
| | | | | | | Now that InputSectionBase is not a template there is no reason to have the two. llvm-svn: 295924
* Convert InputSectionBase to a class.Rafael Espindola2017-02-231-2/+2
| | | | | | | Removing this template is not a big win by itself, but opens the way for removing more templates. llvm-svn: 295923
* Reduce templating a bit. NFC.Rafael Espindola2017-02-231-1/+1
| | | | llvm-svn: 295909
* Move specialization to try to fix the bots.Rafael Espindola2017-02-161-0/+13
| | | | | | | I cannot reproduce the issue locally, but for some reason some bots want to instantiate this from the header. llvm-svn: 295365
* Share more output section creation code.Rafael Espindola2017-02-161-3/+4
| | | | | | | We can do this now that the linker script and the writer agree on which sections should be combined. llvm-svn: 295341
* Simplify. NFC.Rafael Espindola2017-02-031-3/+0
| | | | llvm-svn: 294057
* Replace MergeOutputSection with a synthetic section.Rafael Espindola2017-02-031-24/+0
| | | | | | | | | | | | | | With a synthetic merge section we can have, for example, a single .rodata section with stings, fixed sized constants and non merge constants. I can be simplified further by not setting Entsize, but that is probably better done is a followup patch. This should allow some cleanup in the linker script code now that every output section command maps to just one output section. llvm-svn: 294005
* Revert commits r293276 and r293278.Rafael Espindola2017-01-271-4/+4
| | | | | | | | | | | | | | [ELF] Fixed formatting. NFC and [ELF] Bypass section type check Differential revision: https://reviews.llvm.org/D28761 They do the opposite of what was asked for in the code review. llvm-svn: 293320
* [ELF] Bypass section type checkEugene Leviant2017-01-271-4/+4
| | | | | | Differential revision: https://reviews.llvm.org/D28761 llvm-svn: 293276
* Implement -Map.Rafael Espindola2017-01-131-0/+3
| | | | | | | The format is not exactly the same as the one in bfd since bfd always follows a linker script and prints it along. llvm-svn: 291958
* ELF: Reserve space for copy relocations of read-only symbols in relro.Peter Collingbourne2017-01-101-0/+2
| | | | | | | | | | | | | | When reserving copy relocation space for a shared symbol, scan the DSO's program headers to see if the symbol is in a read-only segment. If so, reserve space for that symbol in a new synthetic section named .bss.rel.ro which will be covered by the relro program header. This fixes the security issue disclosed on the binutils mailing list at: https://sourceware.org/ml/libc-alpha/2016-12/msg00914.html Differential Revision: https://reviews.llvm.org/D28272 llvm-svn: 291524
* Move code to the .cpp file. NFC.Rafael Espindola2017-01-051-9/+2
| | | | llvm-svn: 291113
OpenPOWER on IntegriCloud