summaryrefslogtreecommitdiffstats
path: root/lld/ELF/OutputSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Delete LinkerScript::getSectionIndex.Rafael Espindola2017-05-051-2/+3
| | | | | | | | | We can set SectionIndex tentatively as we process the linker script instead of looking it repeatedly. In general we should try to have as few name lookups as possible. llvm-svn: 302299
* Create an OutputSection for each non-empty OutputSectionCommand.Rafael Espindola2017-04-261-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ELF] Improve error message for incompatible section flagsRui Ueyama2017-04-251-2/+4
| | | | | | | | | | | | | | | | | Previously we were not printing out the flags of the incompatible section which made it difficult to determine what the problem was. The error message format has been change to the following: error: incompatible section flags for .bar >>> /foo/bar/incompatible-section-flags.s.tmp.o:(.bar): 0x403 >>> output section .bar: 0x3 Patch by Alexander Richardson. Differential Revision: https://reviews.llvm.org/D32484 llvm-svn: 301319
* Fix buildbot failure.Rui Ueyama2017-04-191-1/+1
| | | | llvm-svn: 300681
* Rename CompressedHeader ZDebugHeader.Rui Ueyama2017-04-191-5/+5
| | | | | | | `CompressedHeader` is a header for compressed data, and the header itself is not compressed. So the previous name was confusing. llvm-svn: 300675
* Simplify createHeader and inline it.Rui Ueyama2017-04-191-42/+20
| | | | | | | | createHeader didn't use data members of Elf_Chdr type and write directly to a given buffer. That is not a good practice because the function had a knowledge of the struct layout. llvm-svn: 300674
* [ELF] - Implemented --compress-debug-sections option.George Rimar2017-04-171-0/+64
| | | | | | | | | | | | | | 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
* Remove useless namespaces.Rui Ueyama2017-04-131-6/+0
| | | | llvm-svn: 300284
* Remove big-endianness from =<fillexp> code.Rui Ueyama2017-04-111-6/+4
| | | | llvm-svn: 300005
* Call getFiller only when filler is not zero.Rui Ueyama2017-04-111-16/+14
| | | | llvm-svn: 300004
* [ELF] Recommit r299635 to pad x86 executable sections with 0xccJames Henderson2017-04-071-5/+35
| | | | | | 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-4/+3
| | | | | | 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-35/+5
| | | | llvm-svn: 299655
* [ELF] Pad x86 executable sections with 0xcc int3 instructionsJames Henderson2017-04-061-5/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make a helper function file-local.Rui Ueyama2017-04-031-1/+1
| | | | llvm-svn: 299377
* Rename forEach -> parallelForEach and forLoop -> parallelFor.Rui Ueyama2017-03-221-2/+2
| | | | | | | "Parallel" is the most important aspect of the functions, so we shouldn't omit that. llvm-svn: 298557
* [ELF] - Detemplate InputSection::getRelocatedSection(). NFC.George Rimar2017-03-211-1/+1
| | | | llvm-svn: 298353
* [ELF] - Detemplate InputSectionBase::getLinkOrderDep(). NFC.George Rimar2017-03-211-5/+4
| | | | llvm-svn: 298346
* [ELF] - Combine LinkerScriptBase and LinkerScript<ELFT>George Rimar2017-03-201-2/+2
| | | | | | | | | | | | Patch removes templated linkerscript class. Unfortunately that required 2 additional static methods findSymbol() and addRegularSymbol() because code depends on Symtab<ELFT>::X Differential revision: https://reviews.llvm.org/D30982 llvm-svn: 298241
* Compute Config member function return values only once.Rui Ueyama2017-03-171-1/+1
| | | | | | | | | | | We had a few Config member functions that returns configuration values. For example, we had is64() which returns true if the target is 64-bit. The return values of these functions are constant and never change. This patch is to compute them only once to make it clear that they'll never change. llvm-svn: 298168
* [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-7/+2
| | | | llvm-svn: 297937
* Revert r297813 "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."George Rimar2017-03-161-0/+2
| | | | | | | | | I suppose it is the reason of BB fail: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/921 https://bugs.llvm.org/show_bug.cgi?id=32167 llvm-svn: 297933
* [ELF] - Make Bss and BssRelRo sections to be synthetic (#3).George Rimar2017-03-151-2/+0
| | | | | | | | | | | | | | 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: 297814
* [ELF] - Remove unnecessary template #4. NFC.George Rimar2017-03-141-9/+0
| | | | | | OutputSectionFactory has no ELFT templates anymore. llvm-svn: 297720
* [ELF] - Remove unnecessary template #3. NFC.George Rimar2017-03-141-6/+3
| | | | llvm-svn: 297719
* [ELF] - Remove unnecessary template #2. NFC.George Rimar2017-03-141-3/+3
| | | | llvm-svn: 297718
* [ELF] - Remove unnecessary template. NFC.George Rimar2017-03-141-3/+2
| | | | llvm-svn: 297717
* [ELF] - Remove unnecessary template. NFC.George Rimar2017-03-131-0/+6
| | | | llvm-svn: 297622
* [ELF] Propely handle .eh_frame in linker scriptsPetr Hosek2017-03-101-6/+1
| | | | | | | | | | | Using .eh_frame input section pattern in linker script currently causes a crash; this is because .eh_frame input sections require special handling since they're all combined into a synthetic section rather than regular output section. Differential Revision: https://reviews.llvm.org/D30627 llvm-svn: 297501
* Remove DefinedSynthetic.Rafael Espindola2017-03-081-1/+3
| | | | | | | | | | | | | 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
* Remove unnecessary template. NFC.Rafael Espindola2017-03-081-1/+1
| | | | llvm-svn: 297287
* Use 32 bits for alignment.Rafael Espindola2017-03-071-1/+1
| | | | | | This is consistent with what we do for input sections. llvm-svn: 297152
* Rename Addralign to Alignment.Rafael Espindola2017-03-071-2/+2
| | | | | | It now matches the name used in InputSectionBase. llvm-svn: 297144
* [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
* [ELF] - Reset output section size when assigning offsets.George Rimar2017-03-011-2/+1
| | | | | | | | | | | | | | | | | In many places we reset Size to 0 before calling assignOffsets() manually. Sometimes we don't do that. It looks we can just always do that inside. Previous code had: template <class ELFT> void OutputSection::assignOffsets() { uint64_t Off = Size; And tests feels fine with Off = 0. I think Off = Size make no sence. Differential revision: https://reviews.llvm.org/D30463 llvm-svn: 296609
* Set output section's st_entsize based on input section's st_entsize.Rui Ueyama2017-03-011-39/+10
| | | | | | | Each input section knows its sh_entsize value, so we can set output section's sh_entsize based on input sections values. llvm-svn: 296577
* De-template SyntheticSection.Rui Ueyama2017-02-271-1/+1
| | | | | | This class didn't use ELFT. llvm-svn: 296313
* De-template OutputSectionFactory.Rui Ueyama2017-02-271-10/+13
| | | | | | | 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-0/+13
| | | | llvm-svn: 296307
* Merge OutputSectionBase and OutputSection. NFC.Rafael Espindola2017-02-241-46/+53
| | | | | | | Now that all special sections are SyntheticSections, we only need one OutputSection class. llvm-svn: 296127
* Remove unnecessary template. NFC.Rafael Espindola2017-02-241-6/+5
| | | | llvm-svn: 296117
* Convert EhOutputSection to be a synthetic section.Rafael Espindola2017-02-231-218/+1
| | | | | | | | 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-14/+12
| | | | | | | | | 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-8/+8
| | | | | | | 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-24/+25
| | | | | | | 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-3/+2
| | | | llvm-svn: 295909
* Do not use errs() or outs() directly. Instead use message(), log() or error()Rui Ueyama2017-02-211-2/+2
| | | | | | | | | LLD is a multi-threaded program. errs() or outs() are not guaranteed to be thread-safe (they are actually not). LLD's message(), log() or error() are thread-safe. We should use them. llvm-svn: 295787
OpenPOWER on IntegriCloud