[PATCH] D58670: [LLD][ELF] - Improve "sh_addralign is not a power of 2" diagnostics.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 26 06:01:10 PST 2019
grimar created this revision.
grimar added a reviewer: ruiu.
Herald added subscribers: jdoerfert, arichardson, emaste.
Herald added a reviewer: espindola.
This patch removes the precompiled binary from inputs, replacing it with a YAML.
And teaches LLD to report a section name in case of such error.
https://reviews.llvm.org/D58670
Files:
ELF/InputSection.cpp
test/ELF/invalid/Inputs/section-alignment-notpow2.elf
test/ELF/invalid/section-alignment2.s
Index: test/ELF/invalid/section-alignment2.s
===================================================================
--- test/ELF/invalid/section-alignment2.s
+++ test/ELF/invalid/section-alignment2.s
@@ -1,5 +1,16 @@
-## section-alignment-notpow2.elf has section alignment
-## 0xFFFFFFFF which is not a power of 2.
-# RUN: not ld.lld %p/Inputs/section-alignment-notpow2.elf -o /dev/null 2>&1 | \
-# RUN: FileCheck %s
-# CHECK: section sh_addralign is not a power of 2
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o %tout 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}.o:(.text): section sh_addralign is not a power of 2
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x3
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -76,7 +76,7 @@
// no alignment constraits.
uint32_t V = std::max<uint64_t>(Alignment, 1);
if (!isPowerOf2_64(V))
- fatal(toString(File) + ": section sh_addralign is not a power of 2");
+ fatal(toString(this) + ": section sh_addralign is not a power of 2");
this->Alignment = V;
// In ELF, each section can be compressed by zlib, and if compressed,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58670.188357.patch
Type: text/x-patch
Size: 1438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190226/eb1b1f1b/attachment.bin>
More information about the llvm-commits
mailing list