diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1429,10 +1429,9 @@ uint64_t MergeInputSection::getParentOffset(uint64_t offset) const { // If Offset is not at beginning of a section piece, it is not in the map. // In that case we need to search from the original section piece vector. - const SectionPiece &piece = - *(const_cast(this)->getSectionPiece (offset)); - uint64_t addend = offset - piece.inputOff; - return piece.outputOff + addend; + const SectionPiece *piece = getSectionPiece(offset); + uint64_t addend = offset - piece->inputOff; + return piece->outputOff + addend; } template InputSection::InputSection(ObjFile &, const ELF32LE::Shdr &, diff --git a/lld/test/ELF/merge-string.s b/lld/test/ELF/merge-string.s --- a/lld/test/ELF/merge-string.s +++ b/lld/test/ELF/merge-string.s @@ -7,16 +7,16 @@ // RUN: ld.lld -O 0 %t.o -o %t.so -shared // RUN: llvm-readobj -S --section-data --symbols %t.so | FileCheck --check-prefix=NOMERGE %s - .section .rodata1,"aMS",@progbits,1 - .asciz "abc" + .section .rodata1,"aMS",@progbits,1 + .asciz "abc" foo: - .ascii "a" + .ascii "a" bar: .asciz "bc" .asciz "bc" .section .rodata2,"aMS",@progbits,2 - .align 2 + .p2align 1 zed: .short 20 .short 0