llvm-project/lld/ELF
Fangrui Song d45df09435 [ELF] Place SHT_NOTE sections with the same alignment into one PT_NOTE
Summary:
While the generic ABI requires notes to be 8-byte aligned in ELF64, many
vendor-specific notes (from Linux, NetBSD, Solaris, etc) use 4-byte
alignment.

In a PT_NOTE segment, if 4-byte aligned notes are followed by an 8-byte
aligned note, the possible 4-byte padding may make consumers fail to
parse the 8-byte aligned note. See PR41000 for a recent report about
.note.gnu.property (NT_GNU_PROPERTY_TYPE_0).
(Note, for NT_GNU_PROPERTY_TYPE_0, the consumers should probably migrate
to PT_GNU_PROPERTY, but the alignment issue affects other notes as well.)

To fix the issue, don't mix notes with different alignments in one
PT_NOTE. If compilers emit 4-byte aligned notes before 8-byte aligned
notes, we'll create at most 2 segments.

sh_size%sh_addralign=0 is actually implied by the rule for linking
unrecognized sections (in generic ABI), so we don't have to check that.
Notes that match in name, type and attribute flags are concatenated into
a single output section. The compilers have to ensure
sh_size%sh_addralign=0 to make concatenated notes parsable.

An alternative approach is to create a PT_NOTE for each SHT_NOTE, but
we'll have to incur the sizeof(Elf64_Phdr)=56 overhead every time a new
note section is introduced.

Reviewers: ruiu, jakehehrlich, phosek, jhenderson, pcc, espindola

Subscribers: emaste, arichardson, krytarowski, fedor.sergeev, llvm-commits

Tags: #llvm

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

llvm-svn: 359853
2019-05-03 00:35:49 +00:00
..
Arch [PPC64] Consider localentry offset when computing branch distance 2019-04-24 14:03:30 +00:00
AArch64ErrataFix.cpp Use llvm::stable_sort 2019-04-23 02:42:06 +00:00
AArch64ErrataFix.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt Fail early if an output file is not writable 2019-03-11 16:30:55 +00:00
CallGraphSort.cpp Use llvm::stable_sort 2019-04-23 02:42:06 +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] Dump symbols ordered by profiled guided section layout to file. 2019-03-27 23:52:22 +00:00
DWARF.cpp [ELF] Use llvm::bsearch. NFC 2019-04-17 08:00:46 +00:00
DWARF.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Driver.cpp Discard debuginfo for object files empty after GC 2019-04-10 10:37:10 +00:00
Driver.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DriverUtils.cpp Remove a function from header and move the implementation to a .cpp file. NFC. 2019-02-22 23:59:43 +00:00
EhFrame.cpp [ELF][MachO][wasm] Simplify range-style std::find{,_if} with STLExtras.h utilities. NFC 2019-03-29 16:21:16 +00:00
EhFrame.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ICF.cpp Use llvm::stable_sort 2019-04-23 02:42:06 +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 Rename a variable and add a comment. 2019-04-10 06:32:05 +00:00
InputFiles.h [ELF] Fix typo: .symtab_shndxr -> .symtab_shndx 2019-04-12 02:20:52 +00:00
InputSection.cpp [ELF] Change std::max<uint64_t> to uint32_t for section alignment 2019-04-26 04:07:58 +00:00
InputSection.h [ELF] Place SectionPiece::{Live,Hash} bit fields together 2019-04-18 07:46:09 +00:00
LTO.cpp [ELF] --plugin-opt=thinlto-index-only: create empty index files even if all bitcode files are lazy 2019-05-02 14:05:20 +00:00
LTO.h [ELF] --plugin-opt=thinlto-index-only: create empty index files even if all bitcode files are lazy 2019-05-02 14:05:20 +00:00
LinkerScript.cpp [LLD][ELF] /DISCARD/ output sections should not be orphans 2019-04-30 14:31:22 +00:00
LinkerScript.h Replace `typedef A B` with `using B = A`. NFC. 2019-04-01 00:11:24 +00:00
MapFile.cpp Use llvm::stable_sort 2019-04-23 02:42:06 +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 Discard debuginfo for object files empty after GC 2019-04-10 10:37:10 +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] Dump symbols ordered by profiled guided section layout to file. 2019-03-27 23:52:22 +00:00
OutputSections.cpp Use llvm::stable_sort 2019-04-23 02:42:06 +00:00
OutputSections.h [LLD][ELF] - Do not remove empty sections referenced in LOADADDR/ADDR commands. 2019-04-26 06:59:30 +00:00
README.md Update the documents of the new LLD. 2016-03-12 06:06:40 +00:00
Relocations.cpp [LLD] Emit dynamic relocations for references to script symbols in -pie links 2019-05-01 14:07:31 +00:00
Relocations.h [ELF][X86] Allow R_386_TLS_LDO_32 and R_X86_64_DTPOFF{32,64} to preemptable local-dynamic symbols 2019-04-22 03:10:40 +00:00
ScriptLexer.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScriptLexer.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScriptParser.cpp [LLD][ELF] - Do not remove empty sections referenced in LOADADDR/ADDR commands. 2019-04-26 06:59:30 +00:00
ScriptParser.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SymbolTable.cpp [ELF] --plugin-opt=thinlto-index-only: create empty index files even if all bitcode files are lazy 2019-05-02 14:05:20 +00:00
SymbolTable.h De-template SymbolTable::addShared. 2019-04-09 08:52:00 +00:00
Symbols.cpp [ELF] Emit weak-undef symbols in .dynsym of a PIE binary only if linked against shared libs. 2019-03-18 15:32:57 +00:00
Symbols.h ELF: De-template SharedFile. NFCI. 2019-04-08 17:35:55 +00:00
SyntheticSections.cpp Use llvm::stable_sort 2019-04-23 02:42:06 +00:00
SyntheticSections.h [ELF] Place SectionPiece::{Live,Hash} bit fields together 2019-04-18 07:46:09 +00:00
Target.cpp De-template X86_64TargetInfo. NFC. 2019-03-28 17:31:12 +00:00
Target.h Create an instance of Target after reading all input files. NFC. 2019-03-28 17:38:53 +00:00
Thunks.cpp [mips] Remove redundant setup of less-significant bit. NFC 2019-03-13 16:00:35 +00:00
Thunks.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Writer.cpp [ELF] Place SHT_NOTE sections with the same alignment into one PT_NOTE 2019-05-03 00:35:49 +00:00
Writer.h [ELF] Delete unused forward declarations and unused DynamicReloc::getInputSec(). NFC 2019-03-15 07:16:39 +00:00

README.md

See docs/NewLLD.rst