diff --git a/lld/lib/ReaderWriter/ELF/SectionChunks.h b/lld/lib/ReaderWriter/ELF/SectionChunks.h index f6ac670ae32680b8afc1241b2845f5092ab31cbf..1f32bba283b81de7bb1a4bbfb7d997bf9e050aff 100644 --- a/lld/lib/ReaderWriter/ELF/SectionChunks.h +++ b/lld/lib/ReaderWriter/ELF/SectionChunks.h @@ -288,6 +288,7 @@ const lld::AtomLayout &AtomSection::appendAtom(const Atom *atom) { case DefinedAtom::typeConstant: case DefinedAtom::typeData: case DefinedAtom::typeDataFast: + case DefinedAtom::typeZeroFillFast: case DefinedAtom::typeGOT: case DefinedAtom::typeStub: case DefinedAtom::typeResolver: @@ -312,7 +313,6 @@ const lld::AtomLayout &AtomSection::appendAtom(const Atom *atom) { break; case DefinedAtom::typeThreadZeroFill: case DefinedAtom::typeZeroFill: - case DefinedAtom::typeZeroFillFast: _atoms.push_back(new (_alloc) lld::AtomLayout(atom, mOffset, 0)); this->_msize = mOffset + definedAtom->size(); break; diff --git a/lld/test/elf/Hexagon/Inputs/sdata1.c b/lld/test/elf/Hexagon/Inputs/sdata1.c new file mode 100644 index 0000000000000000000000000000000000000000..77c2a54c36a1b8394248b32bb000a973e09e0ef2 --- /dev/null +++ b/lld/test/elf/Hexagon/Inputs/sdata1.c @@ -0,0 +1,3 @@ +static int a = 0; + +int b = 10; diff --git a/lld/test/elf/Hexagon/Inputs/sdata1.o b/lld/test/elf/Hexagon/Inputs/sdata1.o new file mode 100644 index 0000000000000000000000000000000000000000..bf908fed27e96cc8f57e764807b3e57a8b948c97 Binary files /dev/null and b/lld/test/elf/Hexagon/Inputs/sdata1.o differ diff --git a/lld/test/elf/Hexagon/Inputs/sdata2.c b/lld/test/elf/Hexagon/Inputs/sdata2.c new file mode 100644 index 0000000000000000000000000000000000000000..96b37271d7738b3a50ebcb09da824868f72be6b8 --- /dev/null +++ b/lld/test/elf/Hexagon/Inputs/sdata2.c @@ -0,0 +1,6 @@ +int sdata1 = 10; +int sdata2 = 20; +int sdata3 = 30; + +int sbss1 = 0; + diff --git a/lld/test/elf/Hexagon/Inputs/sdata2.o b/lld/test/elf/Hexagon/Inputs/sdata2.o new file mode 100644 index 0000000000000000000000000000000000000000..e4ec810866e513f5e09d25d523955adfba797e84 Binary files /dev/null and b/lld/test/elf/Hexagon/Inputs/sdata2.o differ diff --git a/lld/test/elf/Hexagon/zerofillquick-sdata.test b/lld/test/elf/Hexagon/zerofillquick-sdata.test new file mode 100644 index 0000000000000000000000000000000000000000..54703e144f038c1f43339bbffb442479436588fe --- /dev/null +++ b/lld/test/elf/Hexagon/zerofillquick-sdata.test @@ -0,0 +1,18 @@ +# This tests that a typeZeroFillFast atom is associated with a section that has +# the correct memory size. + +RUN: lld -flavor gnu -target hexagon %p/Inputs/sdata1.o %p/Inputs/sdata2.o \ +RUN: -o %t --noinhibit-exec -static +RUN: llvm-readobj -sections %t | FileCheck -check-prefix=CHECKSECTIONSANDSIZE %s + +CHECKSECTIONSANDSIZE: Section { +CHECKSECTIONSANDSIZE: Name: .sdata (13) +CHECKSECTIONSANDSIZE: Address: 0x1000 +CHECKSECTIONSANDSIZE: Offset: 0x1000 +CHECKSECTIONSANDSIZE: Size: 20 +CHECKSECTIONSANDSIZE: } +CHECKSECTIONSANDSIZE: Section { +CHECKSECTIONSANDSIZE: Name: .bss (20) +CHECKSECTIONSANDSIZE: Address: 0x1018 +CHECKSECTIONSANDSIZE: Offset: 0x1018 +CHECKSECTIONSANDSIZE: }