Create an OutputSection for each non-empty OutputSectionCommand.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 26 Apr 2017 22:30:15 +0000 (22:30 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 26 Apr 2017 22:30:15 +0000 (22:30 +0000)
commit4f013bb3b2ea6a6b2df422bc3387662b26935525
tree9ee450cb2d9deac1e8e9a310125f4962bb41c764
parent8186cd43e2b28eeb6b2e3252049b2bc7cf835fcf
Create an OutputSection for each non-empty OutputSectionCommand.

We were already pretty close, the one exception was when a name was
reused in another SECTIONS directive:

SECTIONS {
  .text : { *(.text) }
  .data : { *(.data) }
}
SECTIONS {
  .data : { *(other) }
}

In this case we would create a single .data and magically output
"other" while looking at the first OutputSectionCommand.

We now create two .data sections. This matches what gold does. If we
really want to create a single one, we should change the parser so that
the above is parsed as if the user had written

SECTIONS {
  .text : { *(.text) }
  .data : { *(.data) *(other)}
}

That is, there should be only one OutputSectionCommand for .data and
it would have two InputSectionDescriptions.

By itself this patch makes the code a bit more complicated, but is an
important step in allowing assignAddresses to operate just on the
linker script.

llvm-svn: 301484
lld/ELF/LinkerScript.cpp
lld/ELF/OutputSections.cpp
lld/ELF/OutputSections.h
lld/test/ELF/linkerscript/sections.s