Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -82,7 +82,7 @@ std::vector Phdrs; - size_t FileSize; + uint64_t FileSize; uint64_t SectionHeaderOff; }; } // anonymous namespace @@ -2480,7 +2480,7 @@ // Open a result file. template void Writer::openFile() { uint64_t MaxSize = Config->Is64 ? INT64_MAX : UINT32_MAX; - if (MaxSize < FileSize) { + if (FileSize != size_t(FileSize) || MaxSize < FileSize) { error("output file too large: " + Twine(FileSize) + " bytes"); return; } @@ -2561,7 +2561,7 @@ return; // Compute a hash of all sections of the output file. - In.BuildId->writeBuildId({Out::BufferStart, FileSize}); + In.BuildId->writeBuildId({Out::BufferStart, size_t(FileSize)}); } template void elf::writeResult(); Index: lld/trunk/test/ELF/linkerscript/output-too-large-32bit.s =================================================================== --- lld/trunk/test/ELF/linkerscript/output-too-large-32bit.s +++ lld/trunk/test/ELF/linkerscript/output-too-large-32bit.s @@ -0,0 +1,11 @@ +# REQUIRES: x86 && !llvm-64-bits + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { .text : { . = 0x6fffffffffffffff; *(.text*); } }" > %t.script +# RUN: not ld.lld --no-check-sections --script %t.script %t.o -o /dev/null 2>&1 | FileCheck %s + +# CHECK: output file too large + +.global _start +_start: + nop Index: lld/trunk/test/lit.cfg.py =================================================================== --- lld/trunk/test/lit.cfg.py +++ lld/trunk/test/lit.cfg.py @@ -97,6 +97,9 @@ if config.have_dia_sdk: config.available_features.add("diasdk") +if config.sizeof_void_p == 8: + config.available_features.add("llvm-64-bits") + tar_executable = lit.util.which('tar', config.environment['PATH']) if tar_executable: tar_version = subprocess.Popen( Index: lld/trunk/test/lit.site.cfg.py.in =================================================================== --- lld/trunk/test/lit.site.cfg.py.in +++ lld/trunk/test/lit.site.cfg.py.in @@ -15,6 +15,7 @@ config.target_triple = "@TARGET_TRIPLE@" config.python_executable = "@PYTHON_EXECUTABLE@" config.have_zlib = @HAVE_LIBZ@ +config.sizeof_void_p = @CMAKE_SIZEOF_VOID_P@ # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. Index: llvm/trunk/utils/gn/secondary/lld/test/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/lld/test/BUILD.gn +++ llvm/trunk/utils/gn/secondary/lld/test/BUILD.gn @@ -53,6 +53,12 @@ } else { extra_values += [ "HAVE_LIBZ=0" ] # Must be 0. } + + if (current_cpu == "x64" || current_cpu == "arm64") { + extra_values += [ "CMAKE_SIZEOF_VOID_P=8" ] + } else { + extra_values += [ "CMAKE_SIZEOF_VOID_P=4" ] + } } write_lit_cfg("lit_unit_site_cfg") {