Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -813,7 +813,7 @@ expect(")"); return [=](uint64_t Dot) -> uint64_t { uint64_t Val = E(Dot); - return alignTo(Dot, Val) + (Dot & (Val - 1)); + return alignTo(Dot, Val); }; } if (Tok == "DATA_SEGMENT_END") { Index: test/ELF/linkerscript/linkerscript-locationcounter.s =================================================================== --- test/ELF/linkerscript/linkerscript-locationcounter.s +++ test/ELF/linkerscript/linkerscript-locationcounter.s @@ -288,7 +288,7 @@ # CHECK-NEXT: Flags [ # CHECK-NEXT: SHF_ALLOC # CHECK-NEXT: ] -# CHECK-NEXT: Address: 0x26008 +# CHECK-NEXT: Address: 0x26000 # CHECK-NEXT: Offset: # CHECK-NEXT: Size: # CHECK-NEXT: Link: