hanchenye-llvm-project/lld/ELF
Fangrui Song d8bc6a48ea [ELF] Do not ICF two sections with different output sections (by SECTIONS commands)
Fixes PR39418. Complements D47241 (the non-linker-script case).

processSectionCommands() assigns input sections to output sections.
ICF is called before it, so .text.foo and .text.bar may be folded even if
their output sections are made different by SECTIONS commands.

```
markLive<ELFT>()
doIcf<ELFT>()                      // During ICF, we don't know the output sections
writeResult()
  combineEhSections<ELFT>()
  script->processSectionCommands() // InputSection -> OutputSection assignment
```

This patch splits processSectionCommands() into processSectionCommands() and
processSymbolAssignments(), and moves processSectionCommands() before ICF:

```
markLive<ELFT>()
combineEhSections<ELFT>()
script->processSectionCommands()
doIcf<ELFT>()                      // should remove folded input sections
writeResult()
  script->processSymbolAssignments()
```

An alternative approach is to unfold a section `sec` in
processSectionCommands() when we find `sec` and `sec->repl` belong to
different output sections. I feel this patch is superior because this
can fold more sections and the decouple of
SectionCommand/SymbolAssignment gives flexibility:

* An ExprValue can't be evaluated before its section is assigned to an
  output section -> we can delete getOutputSectionVA and simplify
  another place where we had to check if the output section is null.
  Moreover, a case in linkerscript/early-assign-symbol.s can be handled
  now.
* processSectionCommands/processSymbolAssignments can be freely moved
  around.

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D66717

llvm-svn: 370635
2019-09-02 10:33:58 +00:00
..
Arch [ELF][Hexagon] Improve error message for unknown relocations 2019-08-19 14:07:14 +00:00
AArch64ErrataFix.cpp [ELF] Fix variable names in comments after VariableName -> variableName change 2019-07-16 05:50:45 +00:00
AArch64ErrataFix.h [ELF] Fix variable names in comments after VariableName -> variableName change 2019-07-16 05:50:45 +00:00
CMakeLists.txt Fail early if an output file is not writable 2019-03-11 16:30:55 +00:00
CallGraphSort.cpp Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFC 2019-08-05 05:43:48 +00:00
CallGraphSort.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Config.h [ELF] Consistently prioritize non-* wildcards overs "*" in version scripts 2019-08-05 14:31:39 +00:00
DWARF.cpp gdb-index: Wire up str_offsets section to avoid incorrect error message about offsets_base 2019-08-07 22:49:14 +00:00
DWARF.h gdb-index: Wire up str_offsets section to avoid incorrect error message about offsets_base 2019-08-07 22:49:14 +00:00
Driver.cpp [ELF] Do not ICF two sections with different output sections (by SECTIONS commands) 2019-09-02 10:33:58 +00:00
Driver.h [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
DriverUtils.cpp Re-submit r367649: Improve raw_ostream so that you can "write" colors using operator<< 2019-08-07 08:08:17 +00:00
EhFrame.cpp [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
EhFrame.h [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
ICF.cpp [ELF] Do not ICF two sections with different output sections (by SECTIONS commands) 2019-09-02 10:33:58 +00:00
ICF.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
InputFiles.cpp [ELF] Set `referenced` bit of Undefined created by BitcodeFile 2019-08-30 07:10:30 +00:00
InputFiles.h [ELF] Fix variable names in comments after VariableName -> variableName change 2019-07-16 05:50:45 +00:00
InputSection.cpp [ELF][PPC] Allow PT_LOAD to have overlapping p_offset ranges 2019-08-20 08:34:25 +00:00
InputSection.h [ELF] Fix variable names in comments after VariableName -> variableName change 2019-07-16 05:50:45 +00:00
LTO.cpp [LLD] Migrate llvm::make_unique to std::make_unique 2019-08-14 22:28:17 +00:00
LTO.h [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
LinkerScript.cpp [ELF] Do not ICF two sections with different output sections (by SECTIONS commands) 2019-09-02 10:33:58 +00:00
LinkerScript.h [ELF] Do not ICF two sections with different output sections (by SECTIONS commands) 2019-09-02 10:33:58 +00:00
MapFile.cpp Fight a bit against global initializers. NFC. 2019-08-22 19:43:27 +00:00
MapFile.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MarkLive.cpp ELF: Move sections referred to by __start_/__stop_ symbols into the main partition. 2019-08-09 00:57:54 +00:00
MarkLive.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Options.td [ELF] Mention contents of reproduce archive and add help description. 2019-08-23 14:41:25 +00:00
OutputSections.cpp [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
OutputSections.h [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
README.md
Relocations.cpp [ELF] Make LinkerScript::assignAddresses iterative 2019-08-26 10:23:31 +00:00
Relocations.h [ELF][Hexagon] Replace R_HEXAGON_GOT with R_GOTPLT 2019-08-16 17:01:56 +00:00
ScriptLexer.cpp [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
ScriptLexer.h [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
ScriptParser.cpp [ELF] Consistently prioritize non-* wildcards overs "*" in version scripts 2019-08-05 14:31:39 +00:00
ScriptParser.h [ELF] Fix variable names in comments after VariableName -> variableName change 2019-07-16 05:50:45 +00:00
SymbolTable.cpp [ELF] Initialize 2 fields of Symbol in SymbolTable::insert 2019-08-14 01:52:47 +00:00
SymbolTable.h [ELF] Rename odd variable names "New" after r365730. NFC 2019-08-13 06:19:39 +00:00
Symbols.cpp [ELF] Simplify handling of exportDynamic and isPreemptible 2019-08-13 09:12:52 +00:00
Symbols.h [ELF] Initialize 2 fields of Symbol in SymbolTable::insert 2019-08-14 01:52:47 +00:00
SyntheticSections.cpp [ELF][RISCV] Assign st_shndx of __global_pointer$ to 1 if .sdata does not exist 2019-08-28 09:01:03 +00:00
SyntheticSections.h [ELF][RISCV] Assign st_shndx of __global_pointer$ to 1 if .sdata does not exist 2019-08-28 09:01:03 +00:00
Target.cpp [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
Target.h [ELF] Fix variable names in comments after VariableName -> variableName change 2019-07-16 05:50:45 +00:00
Thunks.cpp [ELF] Fix variable names in comments after VariableName -> variableName change 2019-07-16 05:50:45 +00:00
Thunks.h [Coding style change] Rename variables so that they start with a lowercase letter 2019-07-10 05:00:37 +00:00
Writer.cpp [ELF] Do not ICF two sections with different output sections (by SECTIONS commands) 2019-09-02 10:33:58 +00:00
Writer.h [ELF] Do not ICF two sections with different output sections (by SECTIONS commands) 2019-09-02 10:33:58 +00:00

README.md

See docs/NewLLD.rst