Files
clang-p2996/lld/test/ELF/linkerscript/empty-section-size.test
George Rimar 0029f21482 [ELF] - Stop setting OutSecOff too early.
Currently LLD sets OutSecOff in addSection for input sections.
That is a fake offset (just a rude approximation to remember the order), 
used for sorting SHF_LINK_ORDER sections
(see resolveShfLinkOrder, compareByFilePosition).

There are 2 problems with such approach:

1. We currently change and reuse Size field as a value assigned. Changing size is
not good because leads to bugs. Currently, SIZEOF(.bss) for empty .bss returns 2
because we add two empty synthetic sections and increase size twice by 1. 
(See PR37011: https://bugs.llvm.org/show_bug.cgi?id=37011)

2. Such approach simply does not work when --symbol-ordering-file is involved,
because processing of the ordering file might break the initial section order.

This fixes PR37011.

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

llvm-svn: 329560
2018-04-09 13:01:50 +00:00

18 lines
524 B
Plaintext

# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t.o
# RUN: ld.lld %t.o --script %s -o %t1
# RUN: llvm-readobj -symbols %t1 | FileCheck %s
## We had a bug when LLD increased the size of the output section even
## if it was empty. That happened because of empty synthetic sections included.
## Here we check that size of empty output section is zero.
# CHECK: Name: foo
# CHECK-NEXT: Value: 0x0
SECTIONS {
. = 0x1000;
.bss : { *(.bss*) *(COMMON) }
foo = SIZEOF(.bss);
}