llvm-project/lld/ELF
Fangrui Song fc0aa8424c [ELF] Check COMMON symbols for PROVIDE and don't redefine COMMON symbols edata/end/etext
In GNU ld, the definition precedence is: regular symbol assignment > relocatable object definition > `PROVIDE` symbol assignment.

GNU ld's internal linker scripts define the non-reserved (by C and C++)
edata/end/etext with `PROVIDE` so the relocatable object definition takes
precedence. This makes sense because `int end;` is valid.

We currently redefine such symbols if they are COMMON, but not if they are
regular definitions, so `int end;` with -fcommon is essentially a UB in ld.lld.
Fix this (also improve consistency and match GNU ld) by using the
`isDefined` code path for `isCommon`. In GNU ld, reserved identifiers like
`__ehdr_start` do not use `PROVIDE`, while we treat them all as `PROVIDE`, this
seems fine.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D120389
2022-02-23 10:15:42 -08:00
..
Arch [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
AArch64ErrataFix.cpp [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
AArch64ErrataFix.h [ELF] AArch64ErrataFix: replace std::map with DenseMap. NFC 2022-02-07 22:02:25 -08:00
ARMErrataFix.cpp [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
ARMErrataFix.h [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
CMakeLists.txt [ELF] Parallelize --compress-debug-sections=zlib 2022-01-25 10:29:04 -08:00
CallGraphSort.cpp [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
CallGraphSort.h
Config.h [ELF] Remove obscure -dp and GNU ld incompatible --[no-]define-common, ignore -d/-dc 2022-02-09 10:35:53 -08:00
DWARF.cpp [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
DWARF.h [ELF] --gdb-index: skip SHF_GROUP .debug_info 2020-08-13 09:11:01 -07:00
Driver.cpp [ELF] Move duplicate symbol check after input file parsing 2022-02-22 10:07:58 -08:00
Driver.h [ELF] Parse archives as --start-lib object files 2022-02-15 09:38:00 -08:00
DriverUtils.cpp [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
EhFrame.cpp [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
EhFrame.h [ELF] Simplify/optimize EhInputSection::split 2022-01-18 17:03:23 -08:00
ICF.cpp [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
ICF.h
InputFiles.cpp [ELF] Move duplicate symbol check after input file parsing 2022-02-22 10:07:58 -08:00
InputFiles.h [ELF] Move duplicate symbol check after input file parsing 2022-02-22 10:07:58 -08:00
InputSection.cpp [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
InputSection.h [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
LTO.cpp [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
LTO.h
LinkerScript.cpp [ELF] Check COMMON symbols for PROVIDE and don't redefine COMMON symbols edata/end/etext 2022-02-23 10:15:42 -08:00
LinkerScript.h [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
MapFile.cpp [ELF] Parse archives as --start-lib object files 2022-02-15 09:38:00 -08:00
MapFile.h [ELF] --cref: If -Map is specified, print to the map file 2021-11-29 14:14:53 -08:00
MarkLive.cpp [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
MarkLive.h
Options.td [ELF] Remove obscure -dp and GNU ld incompatible --[no-]define-common, ignore -d/-dc 2022-02-09 10:35:53 -08:00
OutputSections.cpp [ELF] Change (NOLOAD) section type mismatch error to warning 2022-02-18 11:20:36 -08:00
OutputSections.h [ELF] Support (TYPE=<value>) to customize the output section type 2022-02-17 12:10:58 -08:00
README.md
Relocations.cpp [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
Relocations.h [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
ScriptLexer.cpp [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
ScriptLexer.h [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
ScriptParser.cpp [ELF] Support (TYPE=<value>) to customize the output section type 2022-02-17 12:10:58 -08:00
ScriptParser.h [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
SymbolTable.cpp [ELF] Move duplicate symbol check after input file parsing 2022-02-22 10:07:58 -08:00
SymbolTable.h [ELF] Move duplicate symbol check after input file parsing 2022-02-22 10:07:58 -08:00
Symbols.cpp [ELF] Move duplicate symbol check after input file parsing 2022-02-22 10:07:58 -08:00
Symbols.h [ELF] Move duplicate symbol check after input file parsing 2022-02-22 10:07:58 -08:00
SyntheticSections.cpp [ELF] Replace uncompressed InputSectionBase::data() with rawData. NFC 2022-02-21 00:39:26 -08:00
SyntheticSections.h [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
Target.cpp [ELF] De-template getErrorPlace. NFC 2022-01-29 23:05:54 -08:00
Target.h [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
Thunks.cpp [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00
Thunks.h [lld] Add missing includes (NFC) 2021-06-03 18:55:18 +02:00
Writer.cpp [ELF] Check COMMON symbols for PROVIDE and don't redefine COMMON symbols edata/end/etext 2022-02-23 10:15:42 -08:00
Writer.h [ELF] Clean up headers. NFC 2022-02-07 21:53:34 -08:00

README.md

See docs/NewLLD.rst