Allow SIZEOF() command on nonexistent section.
authorRui Ueyama <ruiu@google.com>
Thu, 17 Nov 2016 20:27:10 +0000 (20:27 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 17 Nov 2016 20:27:10 +0000 (20:27 +0000)
commitedf75e799233d9de94bd7012cc2d90cf7d40d77a
tree5d0c91d983e4e3b1166a4d1c601703b50bf9e1a0
parente4521c35230e15939dec2133fc8fa89270958dde
Allow SIZEOF() command on nonexistent section.

Linker script doesn't create a section if it has no content. So the following
script doesn't create .norelocs section if it doesn't have any .rel* sections.

  .norelocs : { *(.rel*) }

Later, if you assert that the size of .norelocs is 0, LLD printed out
an error message, because it didn't allow calling SIZEOF() on nonexistent
sections.

This patch allows SIZEOF() on nonexistent sections, so that you can do
something like this.

  ASSERT(SIZEOF(.norelocs), "shouldn't contain .rel sections!")

Note that this behavior is compatible with GNU.

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

llvm-svn: 287257
lld/ELF/LinkerScript.cpp
lld/ELF/LinkerScript.h
lld/test/ELF/linkerscript/sizeof.s