[llvm-branch-commits] [lld] 6166b91 - [ELF][NFCI] small cleanup to OutputSections.h

2021-01-12 Thread Bob Haarman via llvm-branch-commits

Author: Bob Haarman
Date: 2021-01-12T23:09:16Z
New Revision: 6166b91e83716fbe930b2dc4e2a2217c52ee31a7

URL: 
https://github.com/llvm/llvm-project/commit/6166b91e83716fbe930b2dc4e2a2217c52ee31a7
DIFF: 
https://github.com/llvm/llvm-project/commit/6166b91e83716fbe930b2dc4e2a2217c52ee31a7.diff

LOG: [ELF][NFCI] small cleanup to OutputSections.h

OutputSections.h used to close the lld::elf namespace only to
immediately open it again. This change merges both parts into
one.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D94538

Added: 


Modified: 
lld/ELF/OutputSections.h

Removed: 




diff  --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 39bf48c091ca..69b7944d946a 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -135,12 +135,6 @@ struct Out {
   static OutputSection *finiArray;
 };
 
-} // namespace elf
-} // namespace lld
-
-namespace lld {
-namespace elf {
-
 uint64_t getHeaderSize();
 
 extern std::vector outputSections;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] 8e0b179 - [ELF] report section sizes when output file too large

2021-01-21 Thread Bob Haarman via llvm-branch-commits

Author: Bob Haarman
Date: 2021-01-21T19:47:03Z
New Revision: 8e0b17931530e84f45586e31b58b031d6d68ee6c

URL: 
https://github.com/llvm/llvm-project/commit/8e0b17931530e84f45586e31b58b031d6d68ee6c
DIFF: 
https://github.com/llvm/llvm-project/commit/8e0b17931530e84f45586e31b58b031d6d68ee6c.diff

LOG: [ELF] report section sizes when output file too large

Fixes PR48523. When the linker errors with "output file too large",
one question that comes to mind is how the section sizes differ from
what they were previously. Unfortunately, this information is lost
when the linker exits without writing the output file. This change
makes it so that the error message includes the sizes of the largest
sections.

Reviewed By: MaskRay, grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D94560

Added: 


Modified: 
lld/ELF/Writer.cpp
lld/test/ELF/linkerscript/output-too-large.s

Removed: 




diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 0397dae8f891..f550e6a73335 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2872,7 +2872,13 @@ template  void Writer::writeHeader() {
 template  void Writer::openFile() {
   uint64_t maxSize = config->is64 ? INT64_MAX : UINT32_MAX;
   if (fileSize != size_t(fileSize) || maxSize < fileSize) {
-error("output file too large: " + Twine(fileSize) + " bytes");
+std::string msg;
+raw_string_ostream s(msg);
+s << "output file too large: " << Twine(fileSize) << " bytes\n"
+  << "section sizes:\n";
+for (OutputSection *os : outputSections)
+  s << os->name << ' ' << os->size << "\n";
+error(s.str());
 return;
   }
 

diff  --git a/lld/test/ELF/linkerscript/output-too-large.s 
b/lld/test/ELF/linkerscript/output-too-large.s
index d916a2e556bc..c496d99d3cef 100644
--- a/lld/test/ELF/linkerscript/output-too-large.s
+++ b/lld/test/ELF/linkerscript/output-too-large.s
@@ -21,14 +21,26 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t2.o
 # RUN: echo "SECTIONS { .text : { . = 0x8fff; *(.text*); } }" > 
%t2.script
 # RUN: not ld.lld -T %t2.script -M %t2.o -o /dev/null 2>&1 | \
-# RUN:   FileCheck --check-prefixes=MAP2,CHECK %s
+# RUN:   FileCheck --check-prefixes=MAP2,CHECK64 %s
 
 # MAP2:   VMA  LMA Size Align Out In  
Symbol
 # MAP2:  9000 90001 4 
{{.*}}.o:(.text)
 # MAP2-NEXT: 9000 90000 1 
_start
 
 # CHECK: error: output file too large
+# CHECK-NEXT: section sizes:
+# CHECK-NEXT: .text 4294967297
+# CHECK-NEXT: .data 1
 
+# CHECK64: error: output file too large
+# CHECK64-NEXT: section sizes:
+# CHECK64-NEXT: .text 10376293541461622785
+# CHECK64-NEXT: .data 1
+
+.data
+.byte 42
+
+.text
 .global _start
 _start:
   nop



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits