From 5f8e77afb5c05d23ae1c2c7ceee0e79207c5f3fb Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 5 Apr 2018 15:56:04 +0000 Subject: [PATCH] Initialize OutputOff to zero. We have a dedicated Live bit, so we don't need a special value and we were not accounting for in at least one place. llvm-svn: 329307 --- lld/ELF/InputSection.h | 2 +- lld/test/ELF/merge-gc-piece.s | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index d0f837989980..0a9eff62a2ba 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -200,7 +200,7 @@ private: // be found by looking at the next one). struct SectionPiece { SectionPiece(size_t Off, uint32_t Hash, bool Live) - : InputOff(Off), Hash(Hash), OutputOff(-1), + : InputOff(Off), Hash(Hash), OutputOff(0), Live(Live || !Config->GcSections) {} uint32_t InputOff; diff --git a/lld/test/ELF/merge-gc-piece.s b/lld/test/ELF/merge-gc-piece.s index 58947d15a5a7..329ba29b0be0 100644 --- a/lld/test/ELF/merge-gc-piece.s +++ b/lld/test/ELF/merge-gc-piece.s @@ -3,6 +3,15 @@ # RUN: ld.lld %t.o -o %t.so -shared --gc-sections # RUN: llvm-readobj -s -section-data %t.so | FileCheck %s + +# CHECK: Name: .foo +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_MERGE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x190 + # CHECK: Name: .bar # CHECK-NEXT: Type: SHT_PROGBITS # CHECK-NEXT: Flags [ @@ -15,7 +24,7 @@ # CHECK-NEXT: AddressAlignment: # CHECK-NEXT: EntrySize: # CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: 90010000 00000000 91010000 00000000 +# CHECK-NEXT: 0000: 91010000 00000000 92010000 00000000 # CHECK-NEXT: ) .section .foo,"aM",@progbits,8