[PATCH] D45080: [ELF] - Provide a hint about --no-check-sections

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 30 02:34:50 PDT 2018


grimar created this revision.
grimar added reviewers: ruiu, espindola.
Herald added subscribers: arichardson, emaste.

This adds a hint about --no-check-sections option to the
sections overlapping error message.

One known legal use case for this option is OVERLAYS, 
which are not yet supported in LLD, though with --no-check-sections
it would be possible to write linker script equal by functionality to
OVERLAY syntax.


https://reviews.llvm.org/D45080

Files:
  ELF/Writer.cpp
  test/ELF/linkerscript/overlapping-sections.s


Index: test/ELF/linkerscript/overlapping-sections.s
===================================================================
--- test/ELF/linkerscript/overlapping-sections.s
+++ test/ELF/linkerscript/overlapping-sections.s
@@ -6,7 +6,7 @@
 # RUN:   .sec2 0x8800 : AT(0x8080) { sec2_start = .; *(.second_sec) sec2_end = .;} \
 # RUN: }" > %t-lma.script
 # RUN: not ld.lld -o %t.so --script %t-lma.script %t.o -shared 2>&1 | FileCheck %s -check-prefix LMA-OVERLAP-ERR
-# LMA-OVERLAP-ERR:      error: section .sec1 load address range overlaps with .sec2
+# LMA-OVERLAP-ERR:      error: section .sec1 load address range overlaps with .sec2; use --no-check-sections to ignore this check if you need overlays
 # LMA-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF]
 # LMA-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8080, 0x817F]
 
@@ -37,7 +37,7 @@
 # RUN:   .sec2 0x8020 : AT(0x8800) { sec2_start = .; *(.second_sec) sec2_end = .;} \
 # RUN: }" > %t-vaddr.script
 # RUN: not ld.lld -o %t.so --script %t-vaddr.script %t.o -shared 2>&1 | FileCheck %s -check-prefix VADDR-OVERLAP-ERR
-# VADDR-OVERLAP-ERR:      error: section .sec1 virtual address range overlaps with .sec2
+# VADDR-OVERLAP-ERR:      error: section .sec1 virtual address range overlaps with .sec2; use --no-check-sections to ignore this check if you need overlays
 # VADDR-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF]
 # VADDR-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8020, 0x811F]
 
@@ -65,13 +65,13 @@
 
 # RUN: not ld.lld -o %t.so --script %t-both-overlap.script %t.o -shared 2>&1 | FileCheck %s -check-prefix BOTH-OVERLAP-ERR
 
-# BOTH-OVERLAP-ERR:      error: section .sec1 file range overlaps with .sec2
+# BOTH-OVERLAP-ERR:      error: section .sec1 file range overlaps with .sec2; use --no-check-sections to ignore this check if you need overlays
 # BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x2000, 0x20FF]
 # BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x2040, 0x213F]
-# BOTH-OVERLAP-ERR:      error: section .sec1 virtual address range overlaps with .sec2
+# BOTH-OVERLAP-ERR:      error: section .sec1 virtual address range overlaps with .sec2; use --no-check-sections to ignore this check if you need overlays
 # BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF]
 # BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040, 0x813F]
-# BOTH-OVERLAP-ERR:      error: section .sec1 load address range overlaps with .sec2
+# BOTH-OVERLAP-ERR:      error: section .sec1 load address range overlaps with .sec2; use --no-check-sections to ignore this check if you need overlays
 # BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF]
 # BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040, 0x813F]
 
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1988,11 +1988,14 @@
     SectionOffset A = Sections[I - 1];
     SectionOffset B = Sections[I];
     if (B.Offset < A.Offset + A.Sec->Size)
-      errorOrWarn(
-          "section " + A.Sec->Name + " " + Name + " range overlaps with " +
-          B.Sec->Name + "\n>>> " + A.Sec->Name + " range is " +
-          rangeToString(A.Offset, A.Sec->Size) + "\n>>> " + B.Sec->Name +
-          " range is " + rangeToString(B.Offset, B.Sec->Size));
+      errorOrWarn("section " + A.Sec->Name + " " + Name +
+                  " range overlaps with " + B.Sec->Name +
+                  "; use --no-check-sections to ignore this check if you need "
+                  "overlays\n>>> " +
+                  A.Sec->Name + " range is " +
+                  rangeToString(A.Offset, A.Sec->Size) + "\n>>> " +
+                  B.Sec->Name + " range is " +
+                  rangeToString(B.Offset, B.Sec->Size));
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45080.140399.patch
Type: text/x-patch
Size: 3721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180330/7a2628a9/attachment.bin>


More information about the llvm-commits mailing list