diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-02-26 22:32:15 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-02-26 22:32:15 +0000 |
| commit | 79c23eec04499933479874c0b06bc8d51914bde4 (patch) | |
| tree | 49d9331cefbdcca8e14834cc8b2d514cec1df20a /lld/ELF/LinkerScript.cpp | |
| parent | 6dcbc1dbb387cf465090cffece6fccc1564233ab (diff) | |
| download | bcm5719-llvm-79c23eec04499933479874c0b06bc8d51914bde4.tar.gz bcm5719-llvm-79c23eec04499933479874c0b06bc8d51914bde4.zip | |
Keep flags from phantom synthetic sections.
This fixes pr36475.
I think this code can be simplified a bit, but I would like to check
in the more direct fix if we are in agreement on the direction and
then refactor.
This is not something that bfd does. The issue is not noticed in bfd
because it keeps fewer sections from the linkerscript in the output.
The reasons why it seems reasonable to do this:
- As George noticed, we would still keep the flags if the output
section had both an empty synthetic section and a regular section
- We need an heuristic to find the flags of output sections. Using the
flags of a synthetic section that would have been there seems a
reasonable heuristic.
llvm-svn: 326137
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 2b72a5b24bf..f1f4ca4782a 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -752,25 +752,6 @@ void LinkerScript::assignOffsets(OutputSection *Sec) { } } -static bool isAllSectionDescription(const OutputSection &Cmd) { - // We do not remove empty sections that are explicitly - // assigned to any segment. - if (!Cmd.Phdrs.empty()) - return false; - - // We do not want to remove sections that have custom address or align - // expressions set even if them are empty. We keep them because we - // want to be sure that any expressions can be evaluated and report - // an error otherwise. - if (Cmd.AddrExpr || Cmd.AlignExpr || Cmd.LMAExpr) - return false; - - for (BaseCommand *Base : Cmd.SectionCommands) - if (!isa<InputSectionDescription>(*Base)) - return false; - return true; -} - void LinkerScript::adjustSectionsBeforeSorting() { // If the output section contains only symbol assignments, create a // corresponding output section. The issue is what to do with linker script @@ -803,7 +784,7 @@ void LinkerScript::adjustSectionsBeforeSorting() { continue; } - if (!isAllSectionDescription(*Sec)) + if (!Sec->isAllSectionDescription()) Sec->Flags = Flags; else Cmd = nullptr; |

