[PATCH] D68758: Improve error message for bad SHF_MERGE sections
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 01:35:00 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7ead5b58daf: Improve error message for bad SHF_MERGE sections (authored by ruiu).
Changed prior to commit:
https://reviews.llvm.org/D68758?vs=224268&id=224276#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68758/new/
https://reviews.llvm.org/D68758
Files:
lld/ELF/InputFiles.cpp
lld/ELF/InputFiles.h
lld/test/ELF/invalid/merge-invalid-size.s
lld/test/ELF/invalid/merge-writable.s
lld/test/ELF/writable-merge.s
Index: lld/test/ELF/invalid/merge-writable.s
===================================================================
--- lld/test/ELF/invalid/merge-writable.s
+++ lld/test/ELF/invalid/merge-writable.s
@@ -1,7 +1,7 @@
// REQUIRES: x86
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
-// CHECK: writable SHF_MERGE section is not supported
+// CHECK: merge-writable.s.tmp.o:(.foo): writable SHF_MERGE section is not supported
.section .foo,"awM", at progbits,4
.quad 0
Index: lld/test/ELF/invalid/merge-invalid-size.s
===================================================================
--- lld/test/ELF/invalid/merge-invalid-size.s
+++ lld/test/ELF/invalid/merge-invalid-size.s
@@ -1,7 +1,7 @@
// REQUIRES: x86
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
-// CHECK: SHF_MERGE section size must be a multiple of sh_entsize
+// CHECK: merge-invalid-size.s.tmp.o:(.foo): SHF_MERGE section size (2) must be a multiple of sh_entsize (4)
.section .foo,"aM", at progbits,4
.short 42
Index: lld/ELF/InputFiles.h
===================================================================
--- lld/ELF/InputFiles.h
+++ lld/ELF/InputFiles.h
@@ -259,7 +259,7 @@
InputSectionBase *createInputSection(const Elf_Shdr &sec);
StringRef getSectionName(const Elf_Shdr &sec);
- bool shouldMerge(const Elf_Shdr &sec);
+ bool shouldMerge(const Elf_Shdr &sec, StringRef name);
// Each ELF symbol contains a section index which the symbol belongs to.
// However, because the number of bits dedicated for that is limited, a
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -483,7 +483,8 @@
return signature;
}
-template <class ELFT> bool ObjFile<ELFT>::shouldMerge(const Elf_Shdr &sec) {
+template <class ELFT>
+bool ObjFile<ELFT>::shouldMerge(const Elf_Shdr &sec, StringRef name) {
// On a regular link we don't merge sections if -O0 (default is -O1). This
// sometimes makes the linker significantly faster, although the output will
// be bigger.
@@ -515,14 +516,16 @@
if (entSize == 0)
return false;
if (sec.sh_size % entSize)
- fatal(toString(this) +
- ": SHF_MERGE section size must be a multiple of sh_entsize");
+ fatal(toString(this) + ":(" + name + "): SHF_MERGE section size (" +
+ Twine(sec.sh_size) + ") must be a multiple of sh_entsize (" +
+ Twine(entSize) + ")");
uint64_t flags = sec.sh_flags;
if (!(flags & SHF_MERGE))
return false;
if (flags & SHF_WRITE)
- fatal(toString(this) + ": writable SHF_MERGE section is not supported");
+ fatal(toString(this) + ":(" + name +
+ "): writable SHF_MERGE section is not supported");
return true;
}
@@ -1033,7 +1036,7 @@
if (name == ".eh_frame" && !config->relocatable)
return make<EhInputSection>(*this, sec, name);
- if (shouldMerge(sec))
+ if (shouldMerge(sec, name))
return make<MergeInputSection>(*this, sec, name);
return make<InputSection>(*this, sec, name);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68758.224276.patch
Type: text/x-patch
Size: 3185 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/59bd4669/attachment.bin>
More information about the llvm-commits
mailing list