[ELF] - Linkerscript: do not define _edata,_end,_etext if SECTIONS is used.
authorGeorge Rimar <grimar@accesssoftek.com>
Mon, 8 Aug 2016 08:42:48 +0000 (08:42 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Mon, 8 Aug 2016 08:42:48 +0000 (08:42 +0000)
commit28ac19c9ee0c486870b98ac00f074ceff5bbbe2a
treec93e4ad52474ccb8457f20021cc5f952b9cd52be
parent86db9e7b66b6f86ad8b249906a88af56c1aaac40
[ELF] - Linkerscript: do not define _edata,_end,_etext if SECTIONS is used.

I faced that when tried to link FreeBSD kernel.
It was "duplicate symbol: _edata in (internal) and (internal)" error.
_data was a shared symbol that came from hack.so. At first it was replaced with DefinedRegular by the code
disabled in this patch and later when script tried to define the same symbol - the error was shown.

In the same situation (as given in testcase) ld defines them as UND. gold defines as ABS with zero value.
Patch just disables any operations of creating these symbols if script do layout.

Differential revision: https://reviews.llvm.org/D23206

llvm-svn: 277986
lld/ELF/Writer.cpp
lld/test/ELF/end.s
lld/test/ELF/linkerscript/linkerscript-edata-etext.s [new file with mode: 0644]