summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Writer.cpp6
-rw-r--r--lld/test/ELF/linkerscript/output-too-large-32bit.s11
-rw-r--r--lld/test/lit.cfg.py3
-rw-r--r--lld/test/lit.site.cfg.py.in1
-rw-r--r--llvm/utils/gn/secondary/lld/test/BUILD.gn6
5 files changed, 24 insertions, 3 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 09fe3c5a73f..3912da2503b 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -82,7 +82,7 @@ private:
std::vector<PhdrEntry *> Phdrs;
- size_t FileSize;
+ uint64_t FileSize;
uint64_t SectionHeaderOff;
};
} // anonymous namespace
@@ -2480,7 +2480,7 @@ template <class ELFT> void Writer<ELFT>::writeHeader() {
// Open a result file.
template <class ELFT> void Writer<ELFT>::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 @@ template <class ELFT> void Writer<ELFT>::writeBuildId() {
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<ELF32LE>();
diff --git a/lld/test/ELF/linkerscript/output-too-large-32bit.s b/lld/test/ELF/linkerscript/output-too-large-32bit.s
new file mode 100644
index 00000000000..a6224c4077a
--- /dev/null
+++ b/lld/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
diff --git a/lld/test/lit.cfg.py b/lld/test/lit.cfg.py
index 350b40a1008..267f8c51785 100644
--- a/lld/test/lit.cfg.py
+++ b/lld/test/lit.cfg.py
@@ -97,6 +97,9 @@ if config.llvm_libxml2_enabled:
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(
diff --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index 07ffc2303e1..02840f8d6a3 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ -15,6 +15,7 @@ config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
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.
diff --git a/llvm/utils/gn/secondary/lld/test/BUILD.gn b/llvm/utils/gn/secondary/lld/test/BUILD.gn
index b62fbc1555e..6af53eb37e1 100644
--- a/llvm/utils/gn/secondary/lld/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/lld/test/BUILD.gn
@@ -53,6 +53,12 @@ write_lit_cfg("lit_site_cfg") {
} 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") {
OpenPOWER on IntegriCloud